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

[ctex] 是否统一文档编码的初始值为 UTF8? #446

Closed
muzimuzhi opened this issue Aug 12, 2019 · 12 comments
Closed

[ctex] 是否统一文档编码的初始值为 UTF8? #446

muzimuzhi opened this issue Aug 12, 2019 · 12 comments
Milestone

Comments

@muzimuzhi
Copy link
Contributor

  1. 当前,pdftex 时,编码的初始值为 GBK;其他引擎下则为 UTF8。

    ctex-kit/ctex/ctex.dtx

    Lines 3282 to 3287 in dce0e53

    % (pdf)\LaTeX{} 初始化编码为 GBK,其它则是 UTF8。
    % \begin{macrocode}
    \tl_new:N \l_@@_encoding_tl
    \tl_set:Nx \l_@@_encoding_tl
    { \sys_if_engine_pdftex:TF { GBK } { UTF8 } }
    % \end{macrocode}
  2. 自 texlive 2018,latex2e 格式统一为所有引擎使用 UTF8 编码,见 https://www.texdev.net/2018/03/25/latex2e-utf-8-as-standard/

是否也将 ctex 默认使用的文档编码,统一为 UTF8,而仅当 pdftex 且用户设置为 GBK 时,才使用 GBK?

@stone-zeng
Copy link
Member

这一设定的意图应该是为了兼容用旧版 ctex 宏包编写的文档,使得旧文档在不做任何修改的情况下也可以编译通过。但使用较新的发行版的用户应该很少会有编译旧文档的需求,而且 LaTeX kernel 也默认用了 UTF8,所以我也觉得现在默认改用 UTF8 没什么问题。

@Liam0205
Copy link
Contributor

@stone-zeng 我支持。

@zepinglee
Copy link
Member

支持!

@muzimuzhi
Copy link
Contributor Author

如果统一为 utf8 了,文档中应该也可以去掉 并显式指定 \opt{UTF8} 选项 的描述:

ctex-kit/ctex/ctex.dtx

Lines 907 to 916 in dce0e53

% \begin{function}[rEXP]{GBK, UTF8}
% 指明编写文档时使用的编码格式。\CTeX{} 宏集无法检测用户编写文档时使用的编码格式,因此
% 需要用户自行指定编码。\emph{我们建议用户总是使用 UTF-8 编码,并显式指定 \opt{UTF8}
% 选项,并使用 \XeLaTeX、\LuaLaTeX{} 或 \upLaTeX{} 编译。}
%
% 使用 \XeLaTeX、\LuaLaTeX{} 或 \upLaTeX{} 编译时,\CTeX{} 宏集强制使用 UTF-8
% 编码,此时 \opt{GBK} 选项无效。
% 使用 (pdf)\LaTeX{} 编译时,\CTeX{} 宏集默认启用 \opt{GBK} 选项;不过,用户也可以
% 显式声明 \opt{UTF8} 选项,使 \CTeX{} 宏集工作在 UTF-8 编码下。
% \end{function}

@zepinglee
Copy link
Member

我觉得可以根据 kernel 版本选择是否默认 utf8

@Liam0205
Copy link
Contributor

@zepinglee 有种多此一举的感觉。就算要把现在的 ctex 装到老版本的 TeX 上去也是不可能的事情了。

@Liam0205
Copy link
Contributor

Liam0205 commented Aug 13, 2019

这个改动作为 breaking changes,不与先前的版本兼容,但考虑以 warning report 的方式向未指定编码的 (pdf)LaTeX 用户进行提示。也就是说,新的行为:

  • XeLaTeX/LuaLaTeX:强制 UTF-8 编码。
  • (pdf)LaTeX:默认 UTF-8 编码;当用户未显式指定 UTF-8 的情况,在 warning message 里告知用户,若使用 GBK 编码应当显式指定。

大家评估一下?

@muzimuzhi
Copy link
Contributor Author

我同意。

@Liam0205
Copy link
Contributor

@qinglee @leo-liu 看一下?

@qinglee
Copy link
Member

qinglee commented Oct 5, 2019

我也支持。

@Liam0205
Copy link
Contributor

Liam0205 commented Oct 8, 2019

这一改动计划将于今年 12 月中旬合并到主干分支,并提交到 CTAN。

周知 post:https://zhuanlan.zhihu.com/p/85643988

@saysin
Copy link

saysin commented Oct 19, 2019

同意

@stone-zeng stone-zeng added this to the ctex 2.5 milestone Nov 7, 2019
@stone-zeng stone-zeng mentioned this issue Jan 10, 2020
25 tasks
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

6 participants