When developing C console applications on English Windows systems using Visual Studio 2008, users may encounter challenges in displaying UTF-8 encoded content correctly through cout or wcout. Here's how to overcome this issue:
Solution:
The solution involves setting the console's output code page to support UTF-8. Follow these steps:
Code Example:
#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"); }
Additional Tips:
The above is the detailed content of How to Print UTF-8 from C Console Applications on Windows?. For more information, please follow other related articles on the PHP Chinese website!