Skip to content

uucore: fix C.UTF-8 locale incorrectly detected as ASCII#12525

Open
mufeedali wants to merge 3 commits into
uutils:mainfrom
mufeedali:locale-fix
Open

uucore: fix C.UTF-8 locale incorrectly detected as ASCII#12525
mufeedali wants to merge 3 commits into
uutils:mainfrom
mufeedali:locale-fix

Conversation

@mufeedali
Copy link
Copy Markdown

C.UTF-8 was treated as a byte-comparison locale because of an early return that matched on "C" before checking the ".UTF-8" encoding suffix. This caused ls to escape non-ASCII filename characters and expr to use byte-level operations on multi-byte data.

Remove the early return so C.UTF-8 and POSIX.UTF-8 are correctly detected as UTF-8 encoding. Add a locale-name guard to init_locale_collation() so sort still uses byte comparison for these locales (C/POSIX collation rules apply regardless of encoding).

C.UTF-8 was treated as a byte-comparison locale because of an early
return that matched on "C" before checking the ".UTF-8" encoding suffix.
This caused ls to escape non-ASCII filename characters and expr to use
byte-level operations on multi-byte data.

Remove the early return so C.UTF-8 and POSIX.UTF-8 are correctly
detected as UTF-8 encoding. Add a locale-name guard to
init_locale_collation() so sort still uses byte comparison for these
locales (C/POSIX collation rules apply regardless of encoding).
@sylvestre
Copy link
Copy Markdown
Contributor

could you please add tests to make sure we don't regress? thanks

@mufeedali
Copy link
Copy Markdown
Author

Makes sense, will add

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 30, 2026

GNU testsuite comparison:

Skip an intermittent issue tests/date/resolution (fails in this run but passes in the 'main' branch)
Congrats! The gnu test tests/cp/link-heap is now passing!
Congrats! The gnu test tests/rm/many-dir-entries-vs-OOM is now passing!
Note: The gnu test tests/env/env-signal-handler was skipped on 'main' but is now failing.

@mufeedali
Copy link
Copy Markdown
Author

Added regression tests.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 31, 2026

Merging this PR will improve performance by 3.11%

⚡ 1 improved benchmark
✅ 318 untouched benchmarks
⏩ 46 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation sort_long_line[10000] 422.9 µs 410.2 µs +3.11%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing mufeedali:locale-fix (9bd6d60) with main (b77733c)

Open in CodSpeed

Footnotes

  1. 46 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

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.

2 participants