It is not so easy on Windows. Even when you manage to get text on the Windows console, you still need to configure cmd.exe to display Japanese characters.
#include <iostream> int main() { std::cout << "γγγ«γ‘γ―δΈη\n"; }
This works great on any system where:
- Source and compiler runtime encodings include characters.
- The output device (for example, the console) expects the text in the same encoding as the encoding of the compiler execution.
- A font with appropriate characters is available (usually this is not a problem).
Most platforms today use UTF-8 by default for all of these encodings and therefore can support the entire Unicode range with code similar to the one above. Unfortunately, Windows is not one of these platforms.
wcout << L"γγγ«γ‘γ―δΈη\n";
On this line, the string literal data (at compile time) is converted from the source encoding to wide-encoding, and then (at run time) wcout uses the locale in which it is embedded to convert the wchar_t data to char data for output. Where everything went wrong, the default locale is only required to support characters from the base character set of the source, which doesn't even include all ASCII characters, not to mention non-ASCII characters.
Thus, the conversion results in an error, putting wcout in a bad state. The error must be cleared before wcout functions again, so the second print request does not print anything.
You can get around this for a limited range of characters by creating a wcout language version that successfully converts characters. Unfortunately, the encoding needed to support the entire Unicode range is UTF-8; Although Microsoft's threading implementation supports other multibyte encodings, it very specifically does not support UTF-8.
For example:
wcout.imbue(std::locale(std::locale::classic(), new std::codecvt_utf8_utf16<wchar_t>())); SetConsoleOutputCP(CP_UTF8); wcout << L"γγγ«γ‘γ―δΈη\n";
Here wcout will correctly convert the string to UTF-8, and if the output was written to a file instead of the console, then the file will contain the correct UTF-8 data. However, the Windows console, although configured here to receive UTF-8 data, simply will not accept UTF-8 data written this way.
There are several options:
Avoid the standard library:
DWORD n; WriteConsoleW(GetStdHandle(STD_OUTPUT_HANDLE), L"γγγ«γ‘γ―δΈη\n", 8, &n, nullptr);
Use a non-standard magic spell that breaks the standard code:
#include <fcntl.h> #include <io.h> _setmode(_fileno(stdout), _O_U8TEXT); std::wcout << L"γγγ«γ‘γ―δΈη\n";
After setting this mode std::cout << "Hello, World"; will fail.
Use the low I / O API and manual conversion:
#include <codecvt> #include <locale> SetConsoleOutputCP(CP_UTF8); std::wstring_convert<std::codecvt_utf8_utf16<wchar_t>, wchar_t> convert; std::puts(convert.to_bytes(L"γγγ«γ‘γ―δΈη\n"));
Using any of these methods, cmd.exe will display the correct text to the best of its ability, and I mean that it will display unreadable fields. Seven small boxes for a given string.

You can copy the text from cmd.exe to the notepad.exe file or something else to see the correct glyphs.