I have a VC++ project in Visual Studio 2008.
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.
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:
#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?
Set the option in Visual Studio or programmatically Select the Configuration Properties > C/C++ > Command Line property page. In Additional Options, add the /utf-8 option to specify your preferred encoding. Choose OK to save your changes.
Under Visual Studio, you can choose between several options Multi-Bytes, Unicode, and a third. Select Unicode, Apply and Close. Now rebuild the project, and it will work.
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
Burgos has the right answer. Just to clarify, the Character Set should be changed to "Not Set".
project properities -> configuration properities -> general -> charater set
From VS2019 Project Properties - Advanced - Advanced Properties - Character Set
Also if there is _UNICODE;UNICODE Preprocessors Definitions remove them. Project Properties - C/C++ - Preprocessor - Preprocessor Definition
For whatever reason, I noticed that setting to unicode for "All Configurations" did not actually apply to all configurations.
Picture:
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".
Picture:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With