String to memeoryBlock


#1

Hi there,

Maybe this is a stupid question... but how can I convert a String to memeryBlock? my goal is to use the base64 encoding.

Thanks!


#2

MemoryBlock::fromBase64Encoding ?


#3

Ok, but I need to create first the memory block with the string, and there I have my problem :(


#4
String myString("This is my string");

MemoryBlock mb(myString.toUTF8(), myString.length());


Create the string, then use it's toUTF8() method and cast it to a void * pointer in a memory block
 


#5

Is that getNumBytesAsUTF8( ) is not safer in case of UTF8 characters?

String myText(CharPointer_UTF8("P\xc3\xa9p\xc3\xa9 p\xc3\xa8te en ao\xc3\xbbt!"));

MemoryBlock myBlock(myText.toRawUTF8( ), myText.getNumBytesAsUTF8( ) + 1); 

#6

Thanks!