Finally, I spent a hole day, but I can't solve my problem.
Here is a piece of code to write a Memory block to a file :
static bool writeKeyFile(String& JSON_Keys)
MemoryBlock Mb(JSON_Keys.toUTF8(), JSON_Keys.getNumBytesAsUTF8());
size_t S1 = Keys.getSize(); // it returns the size of memory block
return Out.write(&Keys, Keys.getSize());
I don't understand what am I doing wrong. The following piece of code has the following unexpected results :
- the keys.getSize() returns a value less than the actual size of its content (i.e. the actual size of data is 253 chars, the .getSize() returns a value of 203 ( chars).
- As a result, the data written to Out file, has a length of 203 chars instead of its actual size.
- Even though the MemoryBlock's data seem to be ok, after turned them to UTF8 format , unfortunatelly, when I read back the data, the following jassert (CharPointer_UTF8::isValidString (buffer, bufferSizeBytes)), interrupts the proccess of reading..
Any idea please ?