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

Visual StudioUnicodeVisual C++

Visual Studio Problem Overview


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?

Visual Studio Solutions


Solution 1 - Visual Studio

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: https://stackoverflow.com/questions/9349342/about-the-character-set-option-in-visual-studio-2010

Solution 2 - Visual Studio

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

Solution 3 - Visual Studio

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

Solution 4 - Visual Studio

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

Solution 5 - Visual Studio

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

Solution 6 - Visual Studio

use #undef UNICODE at the top of your main file.

Solution 7 - Visual Studio

you can go to project properties --> configuration properties --> General -->Project default and there change the "Character set" from "Unicode" to "Not set".

Solution 8 - Visual Studio

None of the above solutions worked for me. But

#include <Windows.h>

worked fine.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionCheesoView Question on Stackoverflow
Solution 1 - Visual StudioNemanja BoricView Answer on Stackoverflow
Solution 2 - Visual StudioEllis MillerView Answer on Stackoverflow
Solution 3 - Visual StudioAhmedView Answer on Stackoverflow
Solution 4 - Visual StudioJuan RojasView Answer on Stackoverflow
Solution 5 - Visual StudioKANJICODERView Answer on Stackoverflow
Solution 6 - Visual StudioDTdevView Answer on Stackoverflow
Solution 7 - Visual Studiouser5042278View Answer on Stackoverflow
Solution 8 - Visual StudiochatcjaView Answer on Stackoverflow