swprintf fails with extended character codes
swprintf fails with extended character codes
- Subject: swprintf fails with extended character codes
- From: Ben Staveley-Taylor <email@hidden>
- Date: Fri, 9 Apr 2010 12:07:04 +0100
I'm working in some cross-platform code that uses wchar_t based strings and I'm struggling to understand how swprintf() is supposed to work.
Everything works fine if I use the wide string type as long as the actual character codes do not exceed 255. As soon as my wide string actually contains a true unicode character, swprintf() just returns -1 and an empty string.
Examples:
1) count = swprintf(buf, 256, L"Hello \%S World", L"\X" );
This works fine. count is 13 and buf == L"Hello X World".
2) // \u3060 is a valid Japanese character
count = swprintf(buf, 256, L"Hello \%S World", L"\u3060" );
count == -1, buf is empty.
3) I tried the extended local version too:
count = swprintf_l(buf, 256, LC_GLOBAL_LOCALE, L"Hello \%S World", L"\u3060" );
but same behaviour as #2.
Versions: Xcode 3.2.1; gcc 4.2.1
Tried both i386 and x64 builds. Both behave the same.
Can anyone see what I'm doing wrong here?
Thanks,
Ben Staveley-Taylor
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden