1

I am using a server (by ssh) and as I am French I would like to be able to use characters such as "à", "ç" and "é". However they simply can't be printed in the standard output, whether when I press the corresponding key on my keyboard (it simply ignores the key), or when I run a script supposed to print them. For example a Python script will raise:

UnicodeEncodeError: 'ascii' codec can't encode characters in position 1-3: ordinal not in range(128)

Following some advices I looked at the locale:

$ locale
LANG=C
LANGUAGE=
LC_CTYPE="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_COLLATE="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_PAPER="C"
LC_NAME="C"
LC_ADDRESS="C"
LC_TELEPHONE="C"
LC_MEASUREMENT="C"
LC_IDENTIFICATION="C"
LC_ALL=

So I opened the /etc/default/locale file, and changed it from:

LANG="C"

to

LANG=fr_FR.UTF-8

It still doesn't work, but a call to locale now tells me:

$ 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=fr_FR.UTF-8
LANGUAGE=
LC_CTYPE="fr_FR.UTF-8"
LC_NUMERIC="fr_FR.UTF-8"
LC_TIME="fr_FR.UTF-8"
LC_COLLATE="fr_FR.UTF-8"
LC_MONETARY="fr_FR.UTF-8"
LC_MESSAGES="fr_FR.UTF-8"
LC_PAPER="fr_FR.UTF-8"
LC_NAME="fr_FR.UTF-8"
LC_ADDRESS="fr_FR.UTF-8"
LC_TELEPHONE="fr_FR.UTF-8"
LC_MEASUREMENT="fr_FR.UTF-8"
LC_IDENTIFICATION="fr_FR.UTF-8"
LC_ALL=

Any ideas how I could fix this ?

Zanna
  • 70,465
Anne Aunyme
  • 121
  • 5
  • hmm... strange that LANGUAGE is unset. Have you installed French? Try running sudo update-locale LANGUAGE=fr_FR:fr? – Zanna Oct 12 '16 at 08:56
  • it doesn't seem to change anything. – Anne Aunyme Oct 12 '16 at 09:08
  • Actually it did, but only after I started a nex ssh session. Should I do that AND manually edit /usr/default/locale ? (presently I reverted this back to initial state) – Anne Aunyme Oct 12 '16 at 09:42
  • no, update-locale updates /etc/default/locale for you (that's what it's supposed to do anyway. You can edit it yourself instead though.) – Zanna Oct 12 '16 at 09:44
  • Ok, I solved the problem by typing: LANGUAGE=fr_FR.UTF-8, LANG=fr_FR.UTF-8 and the problem seems to be fixed. @FlorianDiesch: your link seems to be a similar problem but not exactly the same. – Anne Aunyme Oct 12 '16 at 12:19
  • @AnneAunyme put that as an answer. – TheWanderer Oct 12 '16 at 13:39

2 Answers2

1

The problem was solved by the following commands:

sudo update-locale LANGUAGE=fr_FR.UTF-8
sudo update-locale LANG=fr_FR.UTF-8
Zanna
  • 70,465
Anne Aunyme
  • 121
  • 5
1

You need to get rid of those locale errors too by generating the fr_FR.UTF-8 locale:

sudo locale-gen fr_FR.UTF-8
Gunnar Hjalmarsson
  • 33,540
  • 3
  • 64
  • 94
  • Actually I didn't seem to need that. What is it supposed to do? Modify /etc/default/locale ? Something else ? – Anne Aunyme Oct 13 '16 at 07:42
  • @AnneAunyme: As I said, it generates the locale which you tells the system in /etc/default/locale to use. Setting LANGUAGE may be sufficient for certain aspects of GNU compatible programs, but you really should get rid of those error messages when running the locale command. – Gunnar Hjalmarsson Oct 13 '16 at 08:27
  • Those errors only occurred when I manually modified the file. For now (after reverting back to the initial file and applying my answer), everything seems to be fine. – Anne Aunyme Oct 13 '16 at 08:42
  • @AnneAunyme: That sounds odd, but ok, in that case all is well. :) – Gunnar Hjalmarsson Oct 13 '16 at 08:51