I am attempting to write the following character out in windows command prompt: ュ (U+FF6D).
I am able to see the character get written out using WriteConsoleW. I am also able to see the character if i use WideCharToMultiByte using the CP_ACP code page (chcp returns 932: Japanese). However, when I attempt to use regular wcout on the same string which WriteConsoleW successfully prints, it chokes.
When I execute setlocale(LC_ALL, “”) it prints English_UnitedStates.1252 (the default code page that I had when I installed).
Why is wcout failing when the others are succeeding?
Note: I rebooted the machine to change its system locale to Japan Japanese
The default locale for C++ iostreams is always the "C" locale. From the C++03 standard, §27.4.2.3/4:
From §22.1.1.2/1-2:
From §22.1.1.5/4-6:
As
std::coutandstd::wcouthave static storage duration, they are guaranteed to be initialized beforemainis called, and consequently will always have the "C" locale at application startup; i.e., there is no point early enough in execution that one can calllocale::globaland change the default locale forstd::coutandstd::wcout. Thus, you must always imbue the global streams yourself if you want to use a non-default code page.