这是我的代码的样子:
#include <windows.h>
#include <stdio.h>
int main()
{
SetConsoleCP(CP_UTF8);
SetConsoleOutputCP(CP_UTF8);
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
CONSOLE_FONT_INFOEX cfie;
ZeroMemory(&cfie, sizeof(cfie));
cfie.cbSize = sizeof(cfie);
lstrcpyW(cfie.FaceName, L"Lucida Console");
SetCurrentConsoleFontEx(hStdOut, 0, &cfie);
fprintf(stderr, "нијe\n");
}
输出是这个:
��ијe
当打印行替换为:printf("нијe\n");
预期的输出:
нијe
我可能应该提到我是用MinGW-GCC编译并在CMD中运行的。
使用STD_ERROR_HANDLE
代替STD_OUTPUT_HANDLE
。