visual-studio 如何在 VC++ 项目中关闭 Unicode?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1319461/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I turn off Unicode in a VC++ project?
提问by Cheeso
I have a VC++ project in Visual Studio 2008.
我在 Visual Studio 2008 中有一个 VC++ 项目。
It is defining the symbols for unicode on the compiler command line (/D "_UNICODE" /D "UNICODE"), even though I do not have this symbol turned on in the preprocessor section for the project.
它在编译器命令行 ( /D "_UNICODE" /D "UNICODE")上定义了 unicode 的符号,即使我没有在项目的预处理器部分打开这个符号。
As a result I am compiling against the Unicode versions of all the Win32 library functions, as opposed to the ANSI ones. For example in WinBase.h, there is:
因此,我针对所有 Win32 库函数的 Unicode 版本进行编译,而不是 ANSI 版本。例如在 WinBase.h 中,有:
#ifdef UNICODE
#define CreateFile CreateFileW
#else
#define CreateFile CreateFileA
#endif // !UNICODE
Where is the unicode being turned on in the VC++ project, how can I turn it off?
VC++项目中unicode在哪里开启,如何关闭?
回答by Nemanja Boric
Have you tried: Project Properties - General - Project Defaults - Character Set?
您是否尝试过:项目属性 - 常规 - 项目默认值 - 字符集?
See answers in this question for the differences between "Use Multi-Byte Character Set" and "Not Set" options: About the "Character set" option in visual studio 2010
有关“使用多字节字符集”和“未设置”选项之间的区别,请参阅此问题中的答案:关于 Visual Studio 2010 中的“字符集”选项
回答by Ellis Miller
Burgos has the right answer. Just to clarify, the Character Set should be changed to "Not Set".
布尔戈斯给出了正确的答案。只是为了澄清,字符集应该更改为“未设置”。
回答by Ahmed Said
project properities -> configuration properities -> general -> charater set
项目属性 -> 配置属性 -> 常规 -> 字符集
回答by J.M.I. MADISON
For whatever reason, I noticed that setting to unicode for "All Configurations" did not actually apply to all configurations.
无论出于何种原因,我注意到“所有配置”的 unicode 设置实际上并不适用于所有配置。
To confirm this, I would open the .vcxproj and confirm the correct token is in all 4 locations. In this photo, I am using unicode. So the string I am looking for is "Unicode". For you, you likely want it to say "MultiByte".
为了确认这一点,我将打开 .vcxproj 并确认所有 4 个位置都包含正确的令牌。在这张照片中,我使用的是 unicode。所以我要找的字符串是“Unicode”。对您来说,您可能希望它说“MultiByte”。
回答by Juan Rojas
回答by DTdev
use #undef UNICODEat the top of your main file.
#undef UNICODE在主文件的顶部使用。
回答by user5042278
you can go to project properties --> configuration properties --> General -->Project default and there change the "Character set" from "Unicode" to "Not set".
您可以转到项目属性 --> 配置属性 --> 常规 --> 项目默认值,然后将“字符集”从“Unicode”更改为“未设置”。
回答by chatcja
None of the above solutions worked for me. But
以上解决方案都不适合我。但
#include <Windows.h>
worked fine.
工作正常。


