开发者

MFC LoadStringW Is not not loading Japanese string properly from the string table

开发者 https://www.devze.com 2023-04-12 17:35 出处:网络
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 a

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号