Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

这个现状应当说明一下 #27

Open
HaujetZhao opened this issue Nov 27, 2021 · 1 comment
Open

这个现状应当说明一下 #27

HaujetZhao opened this issue Nov 27, 2021 · 1 comment

Comments

@HaujetZhao
Copy link

阻碍中文编程发展的,主要是编码规范不统一的问题。

国内 Windows 系统是强制 gbk 编码(国家强制要求),国际通用是 UTF-8 编码。Linux 和 MacOS 是 UTF-8 编码。

即使国家取消强制 GBK 编码,Windows 也会因沉重的历史兼容性包袱不能轻易改成 UTF-8,因为那样会使许多旧软件出现问题。

用 utf-8 编码编写的 c/c++ 源码,进行编译后,在 Linux 控制台输出正常。但同一份源码,在国内 Windows 编译后,控制台的输出中文就是乱码。

如果用 GBK 编码保存源码,在国内 win 输出可以正常,但同一份源码在 Linux 下编译后, Linux 控制台输出中文就是乱码。

总之,由于两种编码冲突,输出中文乱码现象很严重,难以保证同一份源代码在所有系统上都输出正确的中文,甚至是不能识别正确的中文输入、中文路径。

一些文件元数据存储文字也跟随 win 系统,windows 使用 gbk,例如 CSV 的默认格式就是 GBK,如果读取 UTF-8 的 CSV 文件,就会有乱码。

在国内 Windows 系统上为照片修改元数据、标签,就是以 GBK 储存,许多国际软件(例如 exiftool exiv2)都只做了 utf-8 支持,读取的结果就出现了乱码。​

另外,有的软件读取目录,使用 UTF-8 编码,但 Windows 给它传递 GBK 编码,结果就找不到文件。典型:pngquant

如果在源文件名中使用了中文,GCC 的 C++ 编译器也无法正常工作。

@nobodxbodon
Copy link
Member

你好,感谢分享中文命名实践中遇到的技术问题。
鉴于此repo主要是知乎专栏的文章源码,还请移步到 overview 切磋。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants