When you output a wchar_t type of Chinese characters to a terminal or console, you need to call the setlocale () function for locale, because typically the terminal, console environment itself does not support the UCS series's character set encoding, and when you use the Stream action function (such as printf ()), the standard/ The interior of the RT library implementation converts the UCS character to the appropriate local ANSI encoded character, which is based on the activity locale set by setlocale (), and finally passes the result character sequence to the terminal, which is exactly the opposite of the input stream from the terminal.
SetLocale (Lc_ctype, "CHS");/set Chinese character
wchar_t *p = L "English";
wprintf (L "%s\n", p);
Note that when using wprintf () under Linux, you want to use%ls to represent a wchar_t string.
C Console output wide characters
SetLocale (Lc_ctype, "");
wchar_t *t = L "abc Hello 123";
wprintf (L "%s\n", t);
C + + console output wide characters
Using Std::locale;
Wcout.imbue (locale (locale (), "", Lc_ctype));
wchar_t *t = L "abc Hello 123";
Wcout << T << Endl;
Reprint Source: http://www.cnblogs.com/hnrainll/archive/2011/05/07/2039700.html