lorniu / go-translate

Translator on Emacs. Supports multiple engines such as Google, Bing, deepL, ChatGPT, StarDict, Youdao and so on.
GNU General Public License v3.0
274 stars 37 forks source link

Windows平台 gts-engine-startdict 出现乱码 #57

Closed Eason0210 closed 1 year ago

Eason0210 commented 1 year ago

@lorniu

大佬,我在 Windows 11 下使用 gts-engine-startdict 时,发现会出现乱码,如图:

image

我在 https://github.com/lorniu/go-translate/blob/master/gts-engine-stardict.el#L49 加了 “--utf8-output” 参数,让 sdcv输出utf8 格式就正常了。如图:

image

同时,我在 macOS 平台也测试了, “--utf8-output” 参数也可以正常工作。

不知道是否可以直接加上这个 “--utf8-output”参数,或者加一个选项,让用户自己定义? 或者你有其他更好的建议?

我的 sdcv (version 0.5.4)是通过 msys2 的 mingw64 安装:

pacman -S  mingw64/mingw-w64-x86_64-sdcv

测试的 Emacs 版本是 GNU Emacs 30.0.50 (build 1, x86_64-w64-mingw32, git sha1 30892cbd330) of 2023-04-30

PS: 汉语转英语时在 Windows 平台也会有问题,完全没结果。估计也是编码问题。 把49行的参数改为这样,让输入也用 utf-8 格式,可以解决:

(list "--non-interactive" "-1" "-0" "--color" text)
lorniu commented 1 year ago

请测试。

Please update and have a try.

Eason0210 commented 1 year ago

@lorniu 更新后,现在可以正常使用了。谢谢

另外提醒下,用 startdict 汉转英时,Windows 平台还要在个人的 Emacs 配置中加入下面的设置:

(setq default-process-coding-system '(utf-8-dos . chinese-iso-8bit-dos))
lorniu commented 1 year ago

(setq default-process-coding-system '(utf-8-dos . chinese-iso-8bit-dos))

我没测试,估计应该没有问题。不过这里最好改成为 sdcv 单独设置编码:

(add-to-list 'process-coding-system-alist '("sdcv" utf-8-dos . chinese-iso-8bit-dos))
Eason0210 commented 1 year ago

(add-to-list 'process-coding-system-alist '("sdcv" utf-8-dos . chinese-iso-8bit-dos))

确实,这样设置更好。谢谢