This fixes the issue in the question, but the real way to convert UTF16 to UTF8 is in Remy's answer below.
dest is a pointer to a random space in memory, because you are not initializing it. In debug builds, it probably points to 0, but in versions it can be anywhere. You tell UnicodeToUtf8 that dest is a 256-character buffer.
try it
char dest[256]; // room for 256 characters UnicodeString src = L"Test this"; UnicodeToUtf8( dest, 256, src, src.Length() );
But actually you can use it easier:
char dest[256]; // room for 256 characters UnicodeString src = L"Test this"; UnicodeToUtf8( dest, src, 256 );
source share