Linux – Spanish Characters in Linux Server Bash Shell

bashcharsetlinuxUbuntu

I have a database that contains Spanish words in it. It contains words like sueño which have "special characters" in them. The MySQL database collation is set to utf-8-general-ci which supports foreign characters, so the database should be fine.

I have a python script that I run in the bash shell and it returns all words in the database, including the word sueño. The problem is that the bash shell doesn't display the word "sueño" properly. The n (with the tilde over it) is garbled when displayed in the bash shell. All other English words with no special characters are displayed properly.

Is there any way to enable foreign character (special character) support in the bash shell?

Thanks,
PR

Best Answer

Can you show the output of the locale command?

example:

LANG=en_CA.UTF-8
LANGUAGE=en_CA:en
LC_CTYPE="en_CA.UTF-8"
LC_NUMERIC="en_CA.UTF-8"
LC_TIME="en_CA.UTF-8"
LC_COLLATE="en_CA.UTF-8"
LC_MONETARY="en_CA.UTF-8"
LC_MESSAGES="en_CA.UTF-8"
LC_PAPER="en_CA.UTF-8"
LC_NAME="en_CA.UTF-8"
LC_ADDRESS="en_CA.UTF-8"
LC_TELEPHONE="en_CA.UTF-8"
LC_MEASUREMENT="en_CA.UTF-8"
LC_IDENTIFICATION="en_CA.UTF-8"
LC_ALL=

If you change the LANG and LANGUAGE env variables you will be able to display those chars in your terminal. You can do a simple test like this:

LANG=en_CA.UTF-8; LANGUAGE=en_CA:en; echo ñ;

If that works you might want to permanently change your locale to a UTF-8 based one.