Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
本 PR 将多个插件通道的序列化编码从旧的 SourceCode(Cork 转义 ASCII)迁移为原生 UTF-8,并在核心转换层统一 "auto" 的编码解析行为,以消除插件交互时的乱码与编解码不对称问题。
Changes:
- 将 Python/Julia/Goldfish/Autosave/Quiver/TikZ 插件的
texmacs->code序列化编码改为"utf-8" - Julia 自动补全输出通道从
"scheme:"切换到"scheme_u8:"以支持 UTF-8 Scheme 树还原 - 调整
verbatim.cpp中"auto"编码解析并补充对应单元测试覆盖
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Data/Convert/Verbatim/verbatim.cpp | 调整 verbatim 输入端 "auto" 的编码解析路径以更贴近 UTF-8 插件协议 |
| tests/Data/String/converter_test.cpp | 增加 verbatim_to_tree(..., "auto") 的 CJK/多行覆盖测试 |
| TeXmacs/plugins/python/progs/init-python.scm | Python 插件序列化编码切换为 UTF-8 |
| TeXmacs/plugins/julia/progs/init-julia.scm | Julia 插件序列化编码切换为 UTF-8 |
| TeXmacs/plugins/julia/julia/MoganJulia.jl | Julia 自动补全输出通道改为 scheme_u8: |
| TeXmacs/plugins/goldfish/progs/init-goldfish.scm | Goldfish 插件序列化编码切换为 UTF-8 |
| TeXmacs/plugins/autosave/progs/init-autosave.scm | Autosave 插件序列化编码切换为 UTF-8 |
| TeXmacs/plugins/quiver/progs/init-quiver.scm | Quiver 插件序列化编码切换为 UTF-8 |
| TeXmacs/plugins/tikz/progs/init-tikz.scm | TikZ 插件序列化编码切换为 UTF-8 |
| devel/0803.md | 增加任务说明与测试/基准验证文档 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
297
to
301
| encode (string s, string enc) { | ||
| if (enc == "auto") return western_to_cork (s); | ||
| else if (enc == "utf-8") return utf8_to_cork (s); | ||
| if (enc == "auto") enc= get_locale_charset (); | ||
| if (enc == "utf-8" || enc == "UTF-8") return utf8_to_cork (s); | ||
| else if (enc == "iso-8859-1") return tm_encode (s); | ||
| else if (enc == "SourceCode") return sourcecode_to_cork (s); |
Comment on lines
+42
to
+53
| void | ||
| TestConverter::test_verbatim_to_tree_auto () { | ||
| // 单个中文字符 | ||
| tree t1 = verbatim_to_tree ("中", false, "auto"); | ||
| qcompare (as_string (t1), "<#4E2D>"); | ||
|
|
||
| // 多行中文字符以及特殊标点符号 | ||
| tree t2 = verbatim_to_tree ("你好\n世界!", false, "auto"); | ||
| qcompare (N (t2), 2); | ||
| qcompare (as_string (t2[0]), "<#4F60><#597D>"); | ||
| qcompare (as_string (t2[1]), "<#4E16><#754C>!"); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[0803] 将插件中编码协议从SourceCode改为UTF-8
1 相关文档
2 任务相关的代码文件
src/Data/Convert/Verbatim/verbatim.cpp— 统一输入端"auto"映射至 Locale(UTF-8),修复编解码不对称tests/Data/String/converter_test.cpp— 扩展test_verbatim_to_tree_auto单元测试,补充多行 CJK 边界覆盖TeXmacs/plugins/julia/julia/MoganJulia.jl— 升级自动补全通道为 UTF-8 的"scheme_u8:",消灭乱码TeXmacs/plugins/julia/progs/init-julia.scm— 将序列化编码由"SourceCode"变更为"utf-8"TeXmacs/plugins/python/progs/init-python.scm— 将序列化编码由"SourceCode"变更为"utf-8"TeXmacs/plugins/goldfish/progs/init-goldfish.scm— 将序列化编码由"SourceCode"变更为"utf-8"TeXmacs/plugins/autosave/progs/init-autosave.scm— 将序列化编码由"SourceCode"变更为"utf-8"TeXmacs/plugins/quiver/progs/init-quiver.scm— 将序列化编码由"SourceCode"变更为"utf-8"TeXmacs/plugins/tikz/progs/init-tikz.scm— 将序列化编码由"SourceCode"变更为"utf-8"3 如何测试
3.1 确定性测试(单元测试)
xmake b converter_test && xmake r converter_test3.2 非确定性测试(文档验证)
进入插件会话,新建Python、Julia或Goldfish会话,输入中文,不会出现乱码(验证本次协议迁移不会带来字体解析问题)
3.3 基准测试(量化优化效率)
4 What
5 Why
旧版使用
SourceCode(Cork转义ASCII)传输数据,内存带宽高且效率低下6 How
verbatim.cpp的encode映射,统一输入输出端"auto"行为。在输入端通过get_locale_charset ()降级为"UTF-8"匹配utf8_to_cork"SourceCode"变更为"utf-8"MoganJulia.jl的自动补全格式从"scheme:"通道更替为具有 Scheme 树级 UTF-8 还原能力的"scheme_u8:"接口