MFC LoadStringW 未从字符串表中正确加载日语字符串 [英] MFC LoadStringW Is not not loading Japanese string properly from the string table

查看:78
本文介绍了MFC LoadStringW 未从字符串表中正确加载日语字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 MFC 应用程序中,字符集设置为多字节",我尝试使用 LoadStringW 函数加载字符串表中存储的日语字符串以从字符串表加载字符串,但它总是读取垃圾字符.

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 you see any problem in my approach?

我不想将字符集更改为 Unicode.

I don't want to change character set to Unicode.

更有趣的是,我创建了另一个示例应用程序,并将主项目中的一个日语字符串粘贴到新示例应用程序的字符串表中,然后尝试使用 LoadStringW 加载日语字符串,然后它就可以工作了(示例应用程序的字符集是多字节.)

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);

推荐答案

请确保您保存的是 utf-16 格式的资源文件,而不是 ANSI.Visual Studio 可以很好地处理这些文件.

Make sure you save the resource file utf-16 format, not ANSI. Visual Studio can handle those files just fine.

要像这样保存它,请在 Visual Studio 中将文件作为文本打开.然后在文件菜单中选择Advanced Save Options,然后在对话框中指定Unicode - Codepage 1200.

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.

然后再次保存文件.

之后,您的资源字符串将按预期工作.

After that, your resource strings will work as expected.

这篇关于MFC LoadStringW 未从字符串表中正确加载日语字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆