You are not logged in.

#1 2020-11-29 15:45:23

NachoGoro
Member
Registered: 2020-10-31
Posts: 21

[SOLVED] Console programs not displaying Spanish characters correctly

"ls" and "find" inside bash are having trouble showing the actual name of files and directories which use non-English characters (in particular Spanish characters such as á, ó, ñ...).

Autocomplete of commands works fine, so it's not like the shell is incapable of displaying those symbols.

Example: I have a directory with two directories in it: "Diseño" and "english-name", and this is the output of "ls":

$ ls
'Dise'$'\303\261''o'   english-name

This is the output of "find":

$ find
.
./Dise??o
./english-name

If I type "cd D" and then press tab for autocompletion I get this:

$ cd Diseño/

So clearly the shell can handle those characters. The "cd" command succeeds too using the name with Spanish symbols. If inside that directory I type "pwd" I get the output printed correctly:

$ cd Diseño/
$ pwd
/home/user/test/Diseño

The output of "locale -a" is:

$ locale -a
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_COLLATE to default locale: No such file or directory
C
POSIX
en_US.utf8

I have tried uncommenting "es_ES@euro ISO-8859-15" in "/etc/locale.gen", running "sudo locale-gen" and logging out, but that didn't fix it.

Thanks in advance!

Last edited by NachoGoro (2020-11-29 17:23:26)

Offline

#2 2020-11-29 15:54:31

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,447
Website

Re: [SOLVED] Console programs not displaying Spanish characters correctly

What else is uncommented in your locale.gen?  You think you'll need a UTF-8 locale.  But I suspect the issue is not the generated locales, but your locale.conf or other setting overriding it.  Please post the output of each of the following:

localectl
locale
cat /etc/locale.conf
env | grep LC

"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2020-11-29 16:53:02

NachoGoro
Member
Registered: 2020-10-31
Posts: 21

Re: [SOLVED] Console programs not displaying Spanish characters correctly

$ localectl
   System Locale: LANG=en_US.UTF-8
       VC Keymap: uk
      X11 Layout: gb

$ locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=an_ES.UTF-8
LC_CTYPE="an_ES.UTF-8"
LC_NUMERIC="an_ES.UTF-8"
LC_TIME="an_ES.UTF-8"
LC_COLLATE="an_ES.UTF-8"
LC_MONETARY="an_ES.UTF-8"
LC_MESSAGES="an_ES.UTF-8"
LC_PAPER="an_ES.UTF-8"
LC_NAME="an_ES.UTF-8"
LC_ADDRESS="an_ES.UTF-8"
LC_TELEPHONE="an_ES.UTF-8"
LC_MEASUREMENT="an_ES.UTF-8"
LC_IDENTIFICATION="an_ES.UTF-8"
LC_ALL=

$ cat /etc/locale.conf 
LANG=en_US.UTF-8

$ env | grep LC

$ 

Nothing else is uncommented in my /etc/locale-gen. I believe the reason there are a bunch of an_ES.UTF-8 settings is because of having changed the regional settings in KDE (Regional Settings/Formats/Region: Spain):

$ grep -v '^#' /etc/locale.gen
en_US.UTF-8 UTF-8  

Last edited by NachoGoro (2020-11-29 17:04:55)

Offline

#4 2020-11-29 17:22:45

NachoGoro
Member
Registered: 2020-10-31
Posts: 21

Re: [SOLVED] Console programs not displaying Spanish characters correctly

Fixed it! Indeed, having modified the regional settings in KDE was screwing things up.
After switching them again to "Default (no change)" the terminal works fine now:

$ localectl
   System Locale: LANG=en_US.UTF-8
       VC Keymap: uk
      X11 Layout: gb

$ locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

Proof that it works:

$ ls
Diseño  english-name

$ find
.
./english-name
./Diseño

I've had to sacrifice having the clock show the date in the American format, which makes no sense to me, but I'll see how to change it without playing with the regional settings.

Offline

#5 2020-11-29 18:35:22

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,447
Website

Re: [SOLVED] Console programs not displaying Spanish characters correctly

I don't know anything about KDE, but I suspect you could change the regional settings as long as you change it to a locale that you had generated.  But you were trying to set an_US.UTF-8 when you had only generated en_US.UTF-8 and, allegedly, es_ES@euro ISO-8859-1.

But if you really just want to change the clock format, you can just set TZ and not mess with any other locale settings.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

Board footer

Powered by FluxBB