Files
youle_cocos/cocoscreator_projects/framework-tests/legacy-layer-migration/_smoke-iconv.mjs
T
Claude 9a695878ba feat(scripts): legacy-layer 转换器脚手架 + fixtures + 解码 smoke test
- 添加 iconv-lite + @xmldom/xmldom 依赖 (YouleNexus + 顶层)
- 创建 framework-tests/legacy-layer-migration/ 目录结构
- 复制 Game_Surface_3 gameabc_Image.json / Layer00002.xml / Login_Layer.prefab 作 fixtures
- spirit-semantics.json 骨架 (Task 5 完整化)
- _smoke-iconv.mjs 验证解码可读中文 Spirit 名

注意: 顶层 package.json 也加了 iconv-lite/@xmldom/xmldom
(转换工具将在 cocoscreator_projects/scripts/ 跑, smoke test 也从
cocoscreator_projects 跑; 只装 YouleNexus 无法解析 iconv-lite).
另: 实际 Layer00002.xml 是 UTF-8 (XML 头声明 + 字节验证), 不是
spec/brief 假设的 GB18030 - smoke test 用 UTF-8 解码才能读到
'微信登录背景'. 转换工具后续 Task 应支持自动检测 (XML 声明优先,
fallback GB18030).
2026-09-02 07:41:53 +08:00

11 lines
656 B
JavaScript

import { readFileSync } from 'node:fs';
import iconv from 'iconv-lite';
const buf = readFileSync('framework-tests/legacy-layer-migration/fixtures/Layer00002.xml');
// NOTE: 实际 Layer00002.xml 是 UTF-8 编码 (XML 头声明 + 字节验证),
// spec/brief 要求的 GB18030 在该文件上会乱码 (微信登录背景 不可读).
// 转换工具应支持两种编码, 优先按 XML 声明, 否则按 GB18030 fallback.
const text = iconv.decode(buf, 'utf8');
console.log('decoded length:', text.length);
console.log('contains 微信登录背景:', text.includes('微信登录背景'));
console.log('contains Login_Layer:', text.includes('Login_Layer'));