Reputation: 967
I have the below program, which tries to print Unicode characters on a console by enabling the _O_U16TEXT
mode for the console:
#include <iostream>
#include <fcntl.h>
#include <io.h>
int main()
{
_setmode(_fileno(stdout), _O_U16TEXT);
wprintf(L"test\n \x263a\x263b Hello from C/C++\n");
return 0;
}
What is unclear to me is that, I have seen many C++ projects (with the same code running on Windows and Linux) and using a macro called _UNICODE
. I have the following questions:
_UNICODE
macro?_UNICODE
macro mean I need to separate the ASCII related code by using #ifdef _UNICODE
? In case of the above program, do I need to put any #ifdef UNICODE
and the ASCII code processing in #else
?_UNICODE
macro?_UNICODE
macro, how does the code know whether it uses UTF-8, UTF-16 or UTF-32? How do I decide between these Unicode types?Upvotes: 0
Views: 218