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#include #pragma execution_character_set("utf-8") int main() { SetConsoleOutputCP(65001); printf("Testing unicode -- English -- Ελληνικά -- Español -- Русский. aäbcdefghijklmnoöpqrsßtuüvwxyz\n"); }
Additional Tips:
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3