Skip to content

ls on Linux displays non-ASCII characters as escape sequences when LC_ALL is not set #13964

Description

@chaocrator

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions