Skip to content

fix(ls): keep printable Unicode literal without POSIX locale - #1887

Merged
caomengxuan666 merged 1 commit into
mainfrom
fix/1883-ls-unicode-quoting
Nov 27, 2026
Merged

caomengxuan666 merged 1 commit into
mainfrom
fix/1883-ls-unicode-quoting

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Summary

  • Treat an unset POSIX locale as UTF-8 on Windows for ls filename printability, matching the UTF-8 filename/argv boundary instead of falling into C-locale octal escaping.
  • Keep explicit POSIX locale overrides authoritative, so LC_ALL=C still produces GNU-style escaped bytes.
  • Add Rust and integration regression coverage for CJK shell-escape rendering.

Fixes #1883

Test plan

  • cargo test --manifest-path rust2/Cargo.toml -p winux-cmds ls::tests
  • scripts/build-with-vs.ps1
  • cd build-vs && ctest --output-on-failure -R '^ls\.' (226/226 passed)
  • Manual probe: default output is 中文; LC_ALL=C keeps the octal escaped form

Generated with Devin

Windows filenames cross the narrow boundary as UTF-8 regardless of the
legacy system locale, while interactive ls defaults to shell-escape
quoting. Treating an unset POSIX locale as the C locale made ordinary
CJK names render as octal byte splices for typical Windows users.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@caomengxuan666

Copy link
Copy Markdown
Member Author

CAPTAIN-VERIFY — 达合入门,队长合入。

运行时证据(X299,head 41a638cb):

  • cargo test -p winux-cmds --lib 1091 passed / 0 failed,本 PR 新增两钉(unset locale 时 CJK 字面 / 显式 LC_ALL=C 仍转义)均在列且 ok。
  • 26 例探针与云端 tarball GNU ls 9.4 逐字节比(env 配对:Rust unset ↔ GNU C.UTF-8、Rust LC_ALL=C ↔ GNU C),23/26 一致;本 PR 核心面全过:shell-escape 下 unset/C.UTF-8 时 CJK 字面、操作数形 ls 中文 字面、LC_ALL=C 回转义形;-Q/-b/-N 与各 quoting 档、--version 全一致。25-help 仅差 argv[0] 路径前缀,属调用产物、非分歧。
  • 只读面:改动极窄(utf8_locale() 无 POSIX locale 时于 Windows 返回 true,唯一调用点 ls.rs:4264;显式 locale 仍权威),manifest 的 activeCodePage UTF-8 依据已核实;配套测试改显式 LC_ALL=C 是对的。

一条观察(不阻塞,已另立单跟进):shell-escape 在 C locale 下对多字符不可打印串的 $'...' 分段与 GNU 不同(GNU 整串并一段,本实现逐字一段;单字串一致)——已证为 base 既有 #1646 面,本 PR 未触 apply_quoting、该函数在 C locale 下改前改后同为 false。本 PR 新增单测断言的正是这个既有形,作为「显式 C 仍转义」的回归钉成立,但注释称之为 GNU 形不准确,后续修 #1646 面时一并正名。

@caomengxuan666
caomengxuan666 merged commit 363d7a0 into main Nov 27, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ls 中文显示成了转义字符

1 participant