关于“字符集". Visual Studio中的选项 [英] About the "Character set" option in Visual Studio

查看:209
本文介绍了关于“字符集". Visual Studio中的选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Visual Studio中的字符集"选项有疑问.字符集选项为:

I have an inquiry about the "Character set" option in Visual Studio. The Character Set options are:

  • 未设置
  • 使用Unicode字符集
  • 使用多字节字符集

我想知道字符集"中三个选项之间的区别是什么?

I want to know what the difference between three options in Character Set?

如果我选择其中的一些,还会影响对除英语之外的其他语言(如RTL语言)的支持吗?

Also if I choose something of them, will affect the support for languages ​​other than English (like RTL languages)?

推荐答案

这是一个兼容性设置,适用于为未启用Unicode的Windows的旧版本编写的旧代码. Windows ME是Windows 9x家族的最后一个版本,被广泛忽略.选中未设置"或使用多字节字符集"后,所有将字符串作为参数的Windows API函数都被重新定义为一个小的兼容性帮助程序函数,该函数将char*字符串转换为wchar_t*字符串(API的本机)字符串类型.

It is a compatibility setting, intended for legacy code that was written for old versions of Windows that were not Unicode enabled. Versions in the Windows 9x family, Windows ME was the last and widely ignored one. With "Not Set" or "Use Multi-Byte Character Set" selected, all Windows API functions that take a string as an argument are redefined to a little compatibility helper function that translates char* strings to wchar_t* strings, the API's native string type.

此类代码严重取决于默认的系统代码页设置.代码页将8位字符映射到Unicode,后者选择字体字形.仅当运行您的代码的计算机具有正确的代码页时,您的程序才会产生正确的文本.如果代码页不匹配,则值> = 128的字符将呈现错误.

Such code critically depends on the default system code page setting. The code page maps 8-bit characters to Unicode which selects the font glyph. Your program will only produce correct text when the machine that runs your code has the correct code page. Characters whose value >= 128 will get rendered wrong if the code page doesn't match.

对于现代代码,始终选择使用Unicode字符集".尤其是当您想支持从右到左布局的语言,而您的开发机器上没有选择阿拉伯语或希伯来语代码页时.在代码中使用std::wstringwchar_t[].要获得实际的RTL布局,需要在CreateWindowEx()调用中打开WS_EX_RTLREADING样式标志.

Always select "Use Unicode Character Set" for modern code. Especially when you want to support languages with a right-to-left layout and you don't have an Arabic or Hebrew code page selected on your dev machine. Use std::wstring or wchar_t[] in your code. Getting actual RTL layout requires turning on the WS_EX_RTLREADING style flag in the CreateWindowEx() call.

这篇关于关于“字符集". Visual Studio中的选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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