UNICODE环境下Win32 GUI重音字符显示异常问题及解决方法
Windows API(MSVC 2022)控件显示é字符编码问题解决办法
我在使用MSVC 2022基于Windows API开发GUI程序时,遇到控件无法正常显示é字符的编码问题,显示效果异常。
我尝试使用宽字符串和TEXT宏编写控件代码:
CreateWindowW( L"STATIC", // Predefined class; Unicode assumed L"éééé", // text WS_VISIBLE | WS_CHILD, // Styles 10, // x position 10, // y position 250, // Button width 50, // Button height hWnd, // Parent window NULL, // No menu. hInst, NULL); // Pointer not needed. CreateWindowW( L"BUTTON", // Predefined class; Unicode assumed TEXT("réééé"), // Button text WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, // Styles 300, // x position 10, // y position 250, // Button width 50, // Button height hWnd, // Parent window (HMENU)ID_OK, // No menu. hInst, NULL); // Pointer not needed.
排查过程中已确认以下配置:
- 项目启用UNICODE,定义了
UNICODE和_UNICODE宏 - 文件参数设置为UNICODE
但问题仍存在,经评论区John提示找到解决方案:将保存为UTF-8编码的CPP文件,通过「另存为」菜单修改编码为UTF-16(Unicode),修改后é字符可正常显示。
内容的提问来源于stack exchange,提问作者Nathan
相关产品推荐
相关产品推荐

