ls on Linux displays non-ASCII characters as escape sequences when LC_ALL is not set
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 24.1k
- Forks
- 2k
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 365
Description
My locale-related environment variables:
chaordinator@thelema testdir :) locale
LANG=uk_UA.UTF-8
LANGUAGE=uk_UA:ru_UA:ru_RU:en_EN
LC_CTYPE=uk_UA.UTF-8
LC_NUMERIC=uk_UA.UTF-8
LC_TIME=C.UTF-8
LC_COLLATE=C.UTF-8
LC_MONETARY=uk_UA.UTF-8
LC_MESSAGES=uk_UA.UTF-8
LC_PAPER=uk_UA.UTF-8
LC_NAME=uk_UA.UTF-8
LC_ADDRESS=uk_UA.UTF-8
LC_TELEPHONE=uk_UA.UTF-8
LC_MEASUREMENT=uk_UA.UTF-8
LC_IDENTIFICATION=uk_UA.UTF-8
LC_ALL=
In a directory with files that contain non-ASCII characters in filenames, ls produces output like this:
chaordinator@thelema testdir :) ls -1
''$'\303\266'' '$'\303\246'' '$'\303\251'' latin umlauts UTF-8'
''$'\320\272\320\270\321\200\320\270\320\273\321\226\321\207\320\275\320\260'' '$'\320\275\320\260\320\267\320\262\320\260'' '$'\320\262'' UTF-8'
''$'\342\247\270'' '$'\313\220'' '$'\342\200\242'' '$'\302\261'' '$'\342\202\254'' '$'\342\202\264'' misc symbols UTF-8'
But with a specified LC_ALL variable it works as expected:
chaordinator@thelema testdir :) LC_ALL=uk_UA.UTF-8 ls -1
'ö æ é latin umlauts UTF-8'
'кирилічна назва в UTF-8'
'⧸ ː • ± € ₴ misc symbols UTF-8'
chaordinator@thelema testdir :) LC_ALL=en_US.UTF-8 ls -1
'ö æ é latin umlauts UTF-8'
'кирилічна назва в UTF-8'
'⧸ ː • ± € ₴ misc symbols UTF-8'
My locale-related environment variables are set to uk_UA.UTF-8 except for LC_TIME and LC_COLLATE (that are set to C.UTF-8) but these two seem to have no effect:
chaordinator@thelema testdir :) LC_TIME=uk_UA.UTF-8 LC_COLLATE=uk_UA.UTF-8 ls -1
''$'\303\266'' '$'\303\246'' '$'\303\251'' latin umlauts UTF-8'
''$'\320\272\320\270\321\200\320\270\320\273\321\226\321\207\320\275\320\260'' '$'\320\275\320\260\320\267\320\262\320\260'' '$'\320\262'' UTF-8'
''$'\342\247\270'' '$'\313\220'' '$'\342\200\242'' '$'\302\261'' '$'\342\202\254'' '$'\342\202\264'' misc symbols UTF-8'
I tried a couple of other locales that I have in my system (i.e. ru_UA.UTF-8 and pl_PL.UTF-8) and behavior of ls is always like this.
I'm on Ubuntu 26.04 if this matters:
chaordinator@thelema testdir :) which ls
/usr/bin/ls
chaordinator@thelema testdir :) dpkg -S /usr/bin/ls
coreutils-from-uutils: /usr/bin/ls
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the shown locale environment and filenames, comparing ls -1 with and without LC_ALL. Then locate the repository's ls implementation and its locale or filename-display path; done means non-ASCII filenames display normally when LC_ALL is unset, while the existing locale behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli, localization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100