ls: use LC_CTYPE (not LC_COLLATE) to determine display encoding#12016
Draft
sylvestre wants to merge 4 commits intouutils:mainfrom
Draft
ls: use LC_CTYPE (not LC_COLLATE) to determine display encoding#12016sylvestre wants to merge 4 commits intouutils:mainfrom
sylvestre wants to merge 4 commits intouutils:mainfrom
Conversation
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
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
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.
|
GNU testsuite comparison: |
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.
xtqqczze
reviewed
Apr 26, 2026
| 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())); |
Contributor
There was a problem hiding this comment.
it would be nice if we could use std::env::var_os
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #12011