您可以尝试 system("cmd /c lambdabath") 或 system("lambdabath") 示例:
//Save As UTF-8 withput BOM signature
#include <stdlib.h>
#include <windows.h>
int main() {
SetConsoleOutputCP(CP_UTF8);
//system("cmd /c lambdabath");
system("lambdabath");
}
lambdabath.bat(也保存为没有 BOM 签名的 UTF-8):
chcp 65001
echo Ιλιάδα
但如果问题是:如何将国际字符发送到 Windows 控制台?
然后你可以尝试不同的编码。不需要使用函数 system()。
Windows 1253 编码:
//Save As Windows 1253
#include <stdio.h>
#include <windows.h>
int main()
{
SetConsoleOutputCP(1253);
char *ansichar_ = "Ιλιάδα";
unsigned char lambda1253char = 'λ';
printf("ansichar_: %s\n", ansichar_);
printf("λ %#x\n", lambda1253char);
}
结果:
ansichar_: Ιλιάδα
λ 0xeb
UTF-16 编码:
//Save As UTF16 (Unicode)
#include <stdio.h>
#include <io.h>
#include <fcntl.h>
#include <wchar.h>
int main()
{
_setmode(_fileno(stdout), _O_U16TEXT);
wchar_t *wchar_ = L"Ιλιάδα";
wchar_t lambdaWchar = L'λ';
wprintf(L"wchar_: %s\n", wchar_);
wprintf(L"λ %#x\n", lambdaWchar);
}
结果:
wchar_: Ιλιάδα
λ 0x3bb
UTF-8 编码:
//Save As UTF8 without BOM signature
#include <stdio.h>
#include <windows.h>
int main()
{
SetConsoleOutputCP(65001);
char *utf8char_ = "Ιλιάδα";
int lambdaUTF8char = 'λ';
printf("utf8char_: %s\n", utf8char_);
printf("λ %#x\n", lambdaUTF8char);
}
结果:
utf8char_: Ιλιάδα
λ 0xcebb
无论如何,设置默认的控制台字体:Lucida Console。