Home >Backend Development >C++ >How to Display UTF-8 Characters in a Windows C Console Application?
Displaying UTF-8 in a Windows Console Application with C
This question explores the challenge of printing UTF-8 encoded Japanese characters to the console in a C console application running on Windows using cout or wcout.
Solution
To print UTF-8 characters correctly, a few steps are necessary:
Sample Code
#include <cstdio> #include <windows.h> #pragma execution_character_set( "utf-8" ) int main() { SetConsoleOutputCP( 65001 ); printf( "Testing unicode -- English -- Ελληνικά -- Español -- Русский. aäbcdefghijklmnoöpqrsßtuüvwxyz\n" ); }
The above is the detailed content of How to Display UTF-8 Characters in a Windows C Console Application?. For more information, please follow other related articles on the PHP Chinese website!