创建工作区时,中文目录路径被截断(Windows native picker) #295
Unanswered
shiqiangxin-maker
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
dsh 0.1.0-rc.6 在 Windows 上创建工作区时,部分中文目录路径会被截断。
复现:用 native 文件夹选择对话框选一个名字里含"开""国""年""发""高"
等字的目录(这些字在 UTF-16 LE 编码里低字节为 0x00),dsh 报
workspace-invalid-path,错误里的路径比实际少 4 字节。
根因:packages/host/directory-picker/native/lib/worker.cjs 的
readUtf16(源文件 src/win32-dialog-bindings.ts)按 2 字节步进扫
NUL 终止符,但只检查低字节:
while (end + 1 < bytes.length && bytes[end] !== 0) end += 2;
触发汉字的低字节是 0x00(如"开" = U+5F00 = LE 00 5F),被误判为
字符串结束。
修复:
while (end + 1 < bytes.length && (bytes[end] !== 0 || bytes[end + 1] !== 0)) end += 2;
All reactions