In my MFC application, character set is set to "Multi-byte", I am trying to load a Japanese string stored in string table using LoadStringW function to load the string from the string table but it always reads junk characters.
Do yo开发者_StackOverflow中文版u see any problem in my approach?
I don't want to change character set to Unicode.
One more interesting thing is, I created another sample application and pasted one of the Japanese string from main project to new sample application's string table then tried to load Japanese string with LoadStringW then it works (character set is Multibyte for sample application.)
WCHAR wBuf[1024];
int rc;
// load the string from resource file into a wide character array.
rc = LoadStringW(hInstance,iResourceID, wBuf, 1024);
Make sure you save the resource file utf-16 format, not ANSI. Visual Studio can handle those files just fine.
To save it like that, open the file in Visual Studio as text. Then in the file menu, choose Advanced Save Options
and then in the dialog specify Unicode - Codepage 1200
.
Then save the file again.
After that, your resource strings will work as expected.
精彩评论