If I know the unicode codepoint of this 2 chinese character 你好 in str
How can I convert this char * str codepoint to chinese character and assign it to wchar_t * wstr ?
char * str = "4F60 597D";
wchar_t * wstr;
I know that I can directly assign like this and problem solved.
wchar_t * wstr = L"\u4F60\u597D";
But my problem is more complicated than that, my situation does not allow that.
How can I do the conversion from literal codepoint to wchar_t * ?
Thanks.
I am using MS Visual C with charset set to MBCS, assume that I cannot use UNICODE charset.
UPDATE : Sorry, just corrected the wchar_t wstr to wchar_t * wstr
UPDATE The char * str contain sequence of UTF-8 code units, for the 2 chinese character 你好
char * str = "\xE4\xBD\xA0\xE5\xA5\xBD";
size_t len = strlen(str) + 1;
wchar_t * wstr = new wchar_t[len];
size_t convertedSize = 0;
_locale_t local = _create_locale( LC_ALL , "Chinese");
_mbstowcs_s_l(&convertedSize, wstr, len, str, _TRUNCATE, local);
MessageBoxW( NULL, wstr , (LPCWSTR)L"Hello", MB_OK);
Why is the MessageBox printing out Japanese character ? Instead of chinese ? What is the right locale name to use ?