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

是否要将代码页从 GBK 切换到 UTF-8?(只支持 Windows 10 和 11) #73

Closed
larryli opened this issue Mar 1, 2024 · 5 comments

Comments

@larryli
Copy link
Owner

larryli commented Mar 1, 2024

中文 Windows 默认都是采用 GBK 代码页 936。而从 Windows 10 开始,支持默认代码页设置为 UTF-8(Windows 区域设置为”Beta版:使用 Unicode UTF-8 提供全球语言支持“)(参见知乎问题)。

所以会存在当前打包的 PuTTY 在 UTF-8(代码页 65001)下乱码的情况,参见 #64

对于 Windows 10/11 来说,应用程序可以指定代码页为 UTF-8 来兼容代码页为 GBK(或是其他代码页)的系统。

这样,对于 PuTTY 这种基于 Code Page 而 Unicode 的应用程序,也能在不同代码页的 Windows 不产生乱码。但缺点是只支持 Windows 10 和 11。

@larryli larryli changed the title 是否要将默认代码页从 GBK 切换到 UTF-8?(只支持 Windows 10 和 11) 是否要将代码页从 GBK 切换到 UTF-8?(只支持 Windows 10 和 11) Mar 1, 2024
@larryli larryli pinned this issue Mar 1, 2024
@larryli
Copy link
Owner Author

larryli commented Mar 1, 2024

另外,如果不切换代码页。那么从下一版本开始,会利用 activeCodePage 解决 Windows 11 下非 GBK 936 代码页的乱码问题。

@larryli
Copy link
Owner Author

larryli commented Apr 7, 2024

目前来说,两个方案都存在问题:

  1. Legacy 方案,参见 https://github.com/fobrs/listview_win32 在开启 UTF-8 环境下会部分乱码
  2. UTF-8 方案,staticwrap 函数下 GetTextExtentExPoint 对于 UTF-8 字符串计算有误

@larryli
Copy link
Owner Author

larryli commented Apr 9, 2024

更新了 utf-8 分支,调整 ActiveCodePage 为 UTF-8,修正了 GetTextExtentExPoint 返回值为字符数而不是字节数的 bug。

对于命令行程序,即 plink、pscp、psftp 目前的处理方式是直接设定 ConsoleCP 和 ConsoleOutCP 为 CP_UTF8。

@larryli
Copy link
Owner Author

larryli commented Apr 10, 2024

😂 遇到第二个坑:UTF-8 代码页下 GetMenuItemInfo 返回中文不完成。

@larryli
Copy link
Owner Author

larryli commented Apr 19, 2024

0.81 增加了 UTF-8 版本发布。

@larryli larryli closed this as completed Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant