Void GetBytes ( char *charbuffer, ulong buffersize, ulong position = 0, ulong size = kSize End, Encoding encoding = kEncoding Native ) const
From FM Plugin Wikipedia
Get the text as an array of char's
const fmx::Text& outText = dataVect.AtAsText( 0 ); // get the original Encoding_Native text ulong maxLength = outText.GetSize() * 2; // UTF16 needs two chars for each character char * dataToWrite = new char [ maxLength ]; // get the original text (UTF-16 encoded ???), NULL terminated outText.GetBytes( dataToWrite, maxLength, 0, fmx::Text::kSize_End, fmx::Text::kEncoding_Native );
Or, alternatively
fmx::TextAutoPtr outText; outText->Assign( "This is some text" ); ulong maxLength = outText->GetSize() + 1; char * dataToWrite = new char [ maxLength ]; // get the original text, NULL terminated outText->GetBytes( dataToWrite, maxLength, 0, fmx::Text::kSize_End, fmx::Text::kEncoding_UTF8 );
If you want to get the text formatted another way, then modify the text encoding to suit.
const fmx::Text& outText = dataVect.AtAsText( 0 ); // get the original Encoding_Native text ulong maxLength = outText.GetSize() * 2; // UTF8 needs a single char for ascii 0 - 127 characters, but can need up to 4 chars char * dataToWrite = new char [ maxLength ]; // convert original text to UTF-8 text, NULL terminated outText.GetBytes( dataToWrite, maxLength, 0, fmx::Text::kSize_End, fmx::Text::kEncoding_UTF8 );
Or as plain ASCII characters
const fmx::Text& outText = dataVect.AtAsText( 0 ); // get the original Encoding_Native text ulong maxLength = outText.GetSize(); // UTF8 needs a single char for ascii 0 - 127 characters, but can need up to 4 chars char * dataToWrite = new char [ maxLength + 1 ]; // convert original text to ASCII, NULL terminated outText.GetBytes( dataToWrite, maxLength, 0, fmx::Text::kSize_End, fmx::Text::kEncoding_ASCII_Windows );