Ric*_*dle 6

不,Windows不支持将UTF-8打印到控制台.

当Windows显示"Unicode"时,它表示UTF-16.您需要使用MultiByteToWideChar将UTF-8转换为UTF-16.像这样的东西:

char* text = "My UTF-8 text\n";
int len = MultiByteToWideChar(CP_UTF8, 0, text, -1, 0, 0);
wchar_t *unicode_text = new wchar_t[len];
MultiByteToWideChar(CP_UTF8, 0, text, -1, unicode_text, len);
wprintf(L"%s", unicode_text);
Run Code Online (Sandbox Code Playgroud)