Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why both UNICODE and _UNICODE?

I've been looking at the command line generated by Visual Studio, and for one of my project it defines two symbols: _UNICODE and UNICODE. Now if I understand this document this rather old document, the _UNICODE symbol is a VC++ thing that causes certain standard functions to use wchar_t instead of char in their interfaces.

But what does the UNICODE without an underscore mean?

like image 209
Adrian Ratnapala Avatar asked Oct 31 '11 11:10

Adrian Ratnapala


People also ask

What is Unicode programming model?

In text processing, Unicode takes the role of providing a unique code point—a number, not a glyph—for each character. In other words, Unicode represents a character in an abstract way and leaves the visual rendering (size, shape, font, or style) to other software, such as a web browser or word processor.

How do I disable Unicode in Visual Studio?

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


1 Answers

Raymond Chen explains it here: TEXT vs. _TEXT vs. _T, and UNICODE vs. _UNICODE:

The plain versions without the underscore affect the character set the Windows header files treat as default. So if you define UNICODE, then GetWindowText will map to GetWindowTextW instead of GetWindowTextA, for example. Similarly, the TEXT macro will map to L"..." instead of "...".

The versions with the underscore affect the character set the C runtime header files treat as default. So if you define _UNICODE, then _tcslen will map to wcslen instead of strlen, for example. Similarly, the _TEXT macro will map to L"..." instead of "...".

Looking into Windows SDK you will find things like this:

#ifdef _UNICODE #ifndef UNICODE #define UNICODE #endif #endif 
like image 172
Roman R. Avatar answered Sep 21 '22 19:09

Roman R.