c - Windows 控制台中的希腊字母

标签 c windows unicode utf-8 console-application

我正在用 C 编写一个程序,当我在 cmd.exe 中运行它时,我想在菜单中包含希腊字符。有人说,为了包含希腊字符,您必须使用如下所示的 printf:

 printf(charset:IS0-1089:uffe);      

但他们不确定。

有人知道怎么做吗?

最佳答案

假设是 Windows,您可以:

此代码打印γειì σου:

#include "windows.h"

int main() {
  SetConsoleOutputCP(1253); //"ANSI" Greek
  printf("\xE3\xE5\xE9\xDC \xF3\xEF\xF5");
  return 0;
}

当编码为 windows-1253 时,十六进制代码表示 γειì σου .如果您使用将数据保存为 windows-1253 的编辑器,则可以改用文字。另一种方法是使用 OEM 737 (这确实是一种 DOS 编码)或使用 Unicode。

我使用 SetConsoleOutputCP 设置控制台代码页,但您可以在运行程序之前键入命令 chcp 1253

关于c - Windows 控制台中的希腊字母,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6168474/

相关文章:

unicode - 如何在 Go 中将 unicode 字符串从数据库转换为 utf 字符串?

c - 如何将 char[n][length+1] 转换为 C 中的常量字符串数组?

windows - Visual Studio 2017 构建工具未安装在 Windows Server 2012 上

windows - 找不到 term/w32-win.el

python - 处理 unicode 中的阿拉伯字符

python - Unicode编码错误: 'latin-1' codec can't encode when trying to write hebrew to a PDF

c - 在 C 中使用多字符定界符拆分 char 字符串

c - 如何在C中为矩阵的特定位置赋值?

c - CSV文件读/写的严格定义

windows - 使用不同的进程名称执行批处理文件