I have some file / folder names which are not 7-bit clean and they are not displayed correctly in my openSUSE system.

Example for the folder /music/Gabriel_Fauré:

# ls -1d /music/Gabriel_Faur?

Perhaps the locale for LC_CTYPE is not set to some UTF-8 value?

# locale
locale: Cannot set LC_ALL to default locale: No such file or directory

Well, that's a nice LC_CTYPE for Unicode, I think! What does the error message say?

Funnily enough, setting LC_ALL to the exact value of LC_CTYPE will work:

# setenv LC_ALL en_US.UTF-8
# ls -1d /music/Gabriel_Faur?

However, I do NOT want to set LC_ALL to en_US.UTF-8 (or anything, really) because it messes up some other settings! It would be no fix but only a bad workaround for me.

Also, why is LC_CTYPE ignored by /bin/ls and/or my shell when printing characters to the screen?

In Arch Linux I would check whether locales are generated but I found nothing on the subject in openSUSE. Also, the locale does seem to exist.


# ls -1d /music/Gabriel_Faur? | hexdump -C
00000000  2f 6d 75 73 69 63 2f 47  61 62 72 69 65 6c 5f 46  |/music/Gabriel_F|
00000010  61 75 72 c3 a9 0a                                 |aur...|

So it's correct UTF-8 (as far as I can tell).


# locale -a | grep en_US
# locale -a | wc -l

EDIT3 (after correct Answer):

# unsetenv LC_PAPER
# unsetenv LC_ALL
# ls -1d /*/Gabriel_Faur?

The LC_PAPER=a4 variable prevents UTF-8 encoded Unicode characters from being printed (no pun intended) on screen!

  • What does echo /music/Gabriel_Faur?|hexdump -C print? Aug 9 '19 at 20:15

What that locale: Cannot set LC_ALL to default locale: No such file or directory message tells you is that one of the locales you're trying to use doesn't exist. It's not about the $LC_ALL environment variable, locale is just reporting an error when the setlocale(LC_ALL, "") call it does to initialise localisation based on environment variables returns NULL indicating a locale configured via one of the various LC_*/LANG variables cannot be found.

Here, since it works with LC_ALL=en_US.UTF-8 which overrides all the other ones, the problem must be with LC_PAPER=a4. a4 is not the name of a valid locale on your system and is causing setlocal(LC_ALL, "") to fail.

When setlocale() fails, the behaviour defaults to the C locale, where the character encoding is ASCII. In the C locale, every byte is a character but 0xc3 and 0xa9 are unknown ones as they are not in ASCII, so ls -q (and -q is enabled when the output goes to a terminal) renders them as ?.

You can see the list of available locales on your system with:

locale -a

You probably won't find a a4 in there. If you want the paper size to be A4, where locale -k LC_PAPER outputs:


You'll probably want to use a European locale for $LC_PAPER, something like en_GB.UTF-8.

  • Thanks! I edited the Question, please look at the output. Still: Why does LC_ALL setting work?
    – Ned64
    Aug 9 '19 at 20:33
  • @Ned64. OK I had missed that. That's most probably caused by that LC_PAPER, see edit. Aug 9 '19 at 20:45
  • You are right, it is the paper size - but why do the UTF-8 characters not appear when the printer's paper size is a4?
    – Ned64
    Aug 9 '19 at 22:18
  • 1
    @Ned64, It's not about the printer paper size being a4, it's about one of the LC_* variables being set to an invalid (unknown) locale (here LC_PAPER set to a4). There is no locale on your system called a4. Locales are typically not named after paper types. locale -a | grep -x a4 will return nothing. As I said use LC_PAPER=en_GB.UTF-8 or any other locale where the paper size is that of A4, not LC_PAPER=a4. Aug 9 '19 at 22:20
  • Thanks, now I get it. It did seem illogical but of course I know it wasn't as this is a computer, after all.
    – Ned64
    Aug 9 '19 at 22:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.