String to memeoryBlock


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.



MemoryBlock::fromBase64Encoding ?


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

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


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);