是否可以在Win32资源文件中使用Unicode字符? [英] Is it possible to use unicode characters in a Win32 resource file?
问题描述
我有一个Win32程序,其中主窗口是一个对话框,因此我可以使用resource.rc文件创建所有控件.我仍然坚持使用Unicode字符创建按钮.它可以与CreateWindowEx()函数一起使用,但不能在资源文件中使用.为什么会这样?
I have a Win32 program where the main window is a dialog box, so I can create all the controls using the resource.rc file. I'm stuck at creating a button using a unicode character though. It works with using the CreateWindowEx() function, but not in the resource file. Why is that?
我在资源文件中尝试了以下代码行:
I've tried the following lines of code in my resource file:
#include <wchar.h> // tried with and without this header file
// also tried defining UNICODE but i got an error saying it was already defined
CONTROL "\u2190", IDC_BACK //...more stuff
CONTROL L"\u2190", IDC_BACK //...more stuff
推荐答案
要在资源中使用非ASCII字符,您可以将.rc文件与BOM一起保存在UTF-16中,也可以将其保存在Ansi中并使用#pragma codepage
指令指示文件的代码页.我建议使用UTF-16.无论哪种方式,都可以使用实际字符代替使用"\u"
:
To use non-ASCII characters in a resource, you can either save the .rc file in UTF-16 with a BOM, or else save the file in Ansi and use a #pragma codepage
directive to indicate the file's codepage. I would suggest UTF-16. Either way, you can then use the actual character instead of using "\u"
:
CONTROL "←", IDC_BACK
这篇关于是否可以在Win32资源文件中使用Unicode字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!