Can std::cout work with UTF-8 on Windows?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to make std::cout print an UTF-8 literal. This seems to be an easy task with gcc, but an extremely difficult one with Windows. The code that I'm trying to get to work is: Environment: Windows 10, Visual Studio 2015 Default encoding: 1251 Console encoding: 866 Source encoding: UTF-8 with BOM Requirements: No changes to the line of code itself must be made Full Unicode range support Some setup code may be added in the beginning of main() What I've tried: #pragma execution_character_set("utf-8") SetConsoleCP(CP_UTF8); SetConsoleOutputCP