这是我现在得到的wprintf:
1?????1????????????
Run Code Online (Sandbox Code Playgroud)
Windows不支持utf8吗?
不,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)
| 归档时间: |
|
| 查看次数: |
1643 次 |
| 最近记录: |