On 22/11/2017 at 06:29, xxxxxxxx wrote:
User Information:
Cinema 4D Version: R19
Platform: Windows ;
Language(s) : C++ ;
---------
Hello,
I'm trying to get a wide string out of the C4D String class, but I'm getting garbage at the end of it.
// const Filename &name
// contains "C:\myfile.txt"
String str = name.GetFileString();
maxon::BaseArray<Utf16Char> arr;
if(str.GetUtf16(arr)) {
const wchar_t *ptr = (const wchar_t * )arr.GetFirst();
wprintf(L"ptr: %s\n", ptr );
}
It prints:
C:\myfile.txt <garbage chars at end>
What am I doing wrong? Is it bad to assume that GetUtf16 arrays are always terminated by a NULL?
I also would like to convert a wide string to String:
wchar_t wfilename[256] = L"C:\\myfile.txt";
String str;
str.SetUtf16( (const Utf16Char * )wfilename, -1 );
Is this correct as well?
Using C4D C++ SDK.