Repository navigation
fix: 修复已有 AD 库追加时的名称编码与存储映射 - #9
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 52411bcf98
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| result[key.removeprefix('%UTF8%').upper()] = value.decode( | ||
| 'utf-8' if unicode_value else 'cp1252', errors='strict' if unicode_value else 'surrogateescape') |
There was a problem hiding this comment.
Parse GBK trail bytes before splitting parameter fields
When a legacy SchLib contains a GBK/GB18030 parameter value whose multibyte character has 0x7c as a trail byte (for example, 東 is 96 7c in GBK), parameters() has already split the block on every b'|' before this new fallback decoding runs. LIBREF0 is therefore truncated to 0x96, so storage_spellings() cannot recover 東 and LibraryIndex still rejects the valid 東/Data storage with the same missing-entry error; the parameter delimiters need to be parsed in an MBCS-aware way while preserving the raw value.
Useful? React with 👍 / 👎.
已有
.SchLib/.PcbLib中的中文、Ω、±或*、?名称会导致“追加”配置被错误拒绝,提示:本修复在不重命名旧器件、不改写旧器件数据的前提下恢复追加。报告者已经实际运行修复构建,并反馈验证正常。
复现与原因
0603_10kΩ ±1%、中文封装名,或包含*/?的名称。现有读取器将 ANSI 索引统一按 cp1252 解释,而 CFB 存储名称是 Unicode。GBK/UTF-8 名称因此与实际存储目录不匹配;cp1252 未定义的字节还可能直接触发解码错误。另一个不匹配来自
*/?未按 AD 的目录命名方式转换为_。修改位置与行为
app/lcsc3d/eda/library_merge.py*/?的目录;补充读取和解析诊断。app/lcsc3d/eda/altium.py*/?到_的转换;通过 surrogateescape 保留 ANSI 中 cp1252 未定义字节的往返能力。app/tests/test_legacy_library_names.py名称回退只改变查找方式。旧索引名称字节、既有组件、模型和未知数据流保持原样;新内容仍通过现有备份、原子写入及取消恢复流程提交。
验证
test_library_integration.py:12/12 通过。--self-test-export:17 个导出/合并/追加/工程流程通过。全量回归在当前 Windows 环境运行 841 项,仍有 12 个 failure 和 2 个 error,未声称全量通过:其中 12 个失败项在未修改的上游源码中也可复现,涉及路径长度、字体及界面时序;另外 2 项在上游和修复版分别单独重跑均通过。未在本次 PR 中扩展修复这些问题。
没有将报告者的库文件、个人路径、登录信息、日志或 EXE/源码 ZIP 提交到仓库,也未修改版本号或发布 Release。