Jan Sporbeck wrote:
Hallo,
while porting a friends windows code, i encountered the following:
WideCharToMultiByte returns incorrect string length when using CP_UTF8 for conversion
the following code snippet correctly sets nLen1 to 2 but sets nLen2 only to 1
int nLen1 = WideCharToMultiByte(CP_UTF8, 0, L"Ü", 1, NULL, 0, NULL, NULL); // query buffer size int nLen2 = WideCharToMultiByte(CP_UTF8, 0, L"Ü", 1, szUtf, nLen1, NULL, NULL); // do conversion
I tested this with Wine <=20030408
am I missing something?
the L"" constructs are not yet supported while porting code (which I assume you're doing) if you're using a recent gcc, try using the -fshort-wchar option (in gcc), it might help (for a bit of explanation, unicode strings are stored as unsigned short in Windows, and by default, unsigned long by gcc, hence some issues)
A+