Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I turn off Unicode in a VC++ project?

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.

alt text

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?

like image 381
Cheeso Avatar asked Aug 23 '09 20:08

Cheeso


People also ask

How to change Unicode in Visual Studio?

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.

How do I enable Unicode in C++?

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.


5 Answers

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

like image 75
Nemanja Boric Avatar answered Oct 15 '22 20:10

Nemanja Boric


Burgos has the right answer. Just to clarify, the Character Set should be changed to "Not Set".

like image 45
Ellis Miller Avatar answered Oct 15 '22 20:10

Ellis Miller


project properities -> configuration properities -> general -> charater set

like image 23
Ahmed Avatar answered Oct 15 '22 19:10

Ahmed


From VS2019 Project Properties - Advanced - Advanced Properties - Character Set enter image description here

Also if there is _UNICODE;UNICODE Preprocessors Definitions remove them. Project Properties - C/C++ - Preprocessor - Preprocessor Definition enter image description here

like image 21
Juan Rojas Avatar answered Oct 15 '22 18:10

Juan Rojas


For whatever reason, I noticed that setting to unicode for "All Configurations" did not actually apply to all configurations.

Picture: Setting Configuragion In IDE

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: Confirming changes in configuration file

like image 30
twitchdotcom slash KANJICODER Avatar answered Oct 15 '22 20:10

twitchdotcom slash KANJICODER