Windows 如何识别非 Unicode 应用程序?
我正在构建一个 MFC C++ 应用程序,并在 Visual Studio 中选择“使用 Unicode 字符集”。我定义了 UNICODE,我的 CString 是 16 位,我处理其中包含日语字符的文件名,等等。但是,当我将包含日语字符的 Unicode 字符串放入 CComboBox 中(使用 AddString)时,它们显示为 ?????? 。
我正在运行 Windows XP Professional x64(英文)。如果我使用 Windows 控制面板“区域和语言选项”、“高级”选项卡,并将非 Unicode 程序的语言设置为日语,则我的组合框看起来是正确的。
因此,我希望我的组合框看起来正确,并且我想了解为什么“非 Unicode 程序的语言”设置正在改变我的 Unicode 程序的行为。我还应该做些什么来告诉 Windows 我的应用程序是 Unicode 应用程序吗?
感谢您的帮助!
I am building an MFC C++ application with "Use Unicode Character Set" selected in Visual Studio. I have UNICODE defined, my CStrings are 16-bit, I handle filenames with Japanese characters in them, etc. But, when I put Unicode strings containing Japanese characters in a CComboBox (using AddString), they show up as ?????.
I'm running Windows XP Professional x64 (in English). If I use Windows Control Panel Regional and Language Options, Advanced Tab, and set the Language for non-Unicode programs to Japanese, my combo box looks right.
So, I want my combo box to look right, and I want to understand why the "Language for non-Unicode programs" setting is changing the behavior of my Unicode program. Is there something else I should do to tell Windows my application is a Unicode application?
Thanks for any help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Windows 通过调用的函数来区分 Unicode 和非 Unicode 程序。大多数 Windows API 函数有两种变体,一种以 A 结尾表示非 Unicode,另一种以 W 结尾表示 Unicode。定义这些函数的包含文件将使用编译器设置自动为您选择其中一个。
这些字符可能无法正确显示,因为您选择的字体不包含这些字符作为默认 UI 字体。
Windows knows the difference between Unicode and non-Unicode programs by the functions they call. Most Windows API functions will come in two variants, one ending in A for non-Unicode and one ending in W for Unicode. The include files that define these functions will use the compiler settings to pick one or the other for you automatically.
The characters might not be coming out properly because you've selected a font that doesn't include them to be your default UI font.
你从哪里得到字符串?
如果它们被硬编码在您的 C 源代码中,那么在您调用 AddString 时它们(很可能)已经损坏。
没有什么可以阻止人们获取某些 Unicode 字符串,例如将其“挤压”到 std::string 中并损坏它。即使应用程序被编译为 Unicode。
Where do you get the strings from?
If they are hard-coded in your C sources, then at the time you call AddString they are (most likely) already damaged.
Nothing prevents one from taking some Unicode string, "squeeze" it in a std::string, for instance, and damage it. Even if the applications is compiled as Unicode.