Skip to content

ls: use LC_CTYPE (not LC_COLLATE) to determine display encoding#12016

Draft
sylvestre wants to merge 4 commits intouutils:mainfrom
sylvestre:issue-12011
Draft

ls: use LC_CTYPE (not LC_COLLATE) to determine display encoding#12016
sylvestre wants to merge 4 commits intouutils:mainfrom
sylvestre:issue-12011

Conversation

@sylvestre
Copy link
Copy Markdown
Contributor

fixes #12011

LC_COLLATE governs sort order, not character classification. Using it
to decide whether filename bytes are printable caused UTF-8 names to
be escaped whenever LC_COLLATE=C, even with a UTF-8 LC_CTYPE/LANG.

Fixes uutils#12011
@oech3

This comment was marked as outdated.

@oech3

This comment was marked as outdated.

init_locale_collation() went through get_locale_encoding(), which now
reads LC_CTYPE. Collation must follow LC_COLLATE, so read the encoding
off get_collating_locale() directly. Otherwise LC_COLLATE=fr_FR.UTF-8
combined with LC_CTYPE=C would skip the ICU collator and fall back to
byte comparison.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 26, 2026

GNU testsuite comparison:

Skipping an intermittent issue tests/cut/bounded-memory (passes in this run but fails in the 'main' branch)
Skipping an intermittent issue tests/tail/follow-name (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/unexpand/bounded-memory is now passing!
Skip an intermittent issue tests/pr/bounded-memory (was skipped on 'main', now failing)

Add the explicit LC_CTYPE=UTF-8 LC_COLLATE=C reproducer from the PR
review (Japanese filename for ls; byte-order sort) so both the display
fix and the collator-init fix have direct regression coverage.
let locale_var = ["LC_ALL", locale_name, "LANG"]
.iter()
.find_map(|&key| std::env::var(key).ok());
.find_map(|&key| std::env::var(key).ok().filter(|v| !v.is_empty()));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be nice if we could use std::env::var_os

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: LC_COLLATE impacts display

3 participants