Set of lxd containers stopped displaying norwegian special characters ø æ å

I run a server at Scaleway which contains 7 containers (zfs+lxd), in the past I was able to insert special characters remotely (ø,æ,å) and those characters were able to get displayed correctly at web pages.
Now, the recent 2 months it stopped, special characters won’t display via terminal or at web pages, for example at a website instead of Bærum - Høvik it displays BÃærum - Høvik , I can type those at the host server but not at the lxds.
When I type ø it displays “(arg: 8)”, the other 2 å,æ won’t display nothing.

Thank you in advance for any suggestions

Make sure that you have any relevant language pack installed in the container.
If that’s the case, then the trick is usually to set the LANG and LANGUAGE environment variables in the container to match what’s expected for your particular locale/language.

I’m not sure why things would have suddenly changed though.

One thing that may catch some people off guard is that ssh will do a whole bunch of that for you, effectively reading your client’s locale and attempting to set it on the remote server.

“lxc exec” doesn’t do that, so you have to manually set those environment variables, either directly, or through .bashrc/.profile or you can set those keys for the container’s environment through LXD with:

lxc config set NAME environment.LANG en_US.UTF-8
lxc config set NAME environment.LANGUAGE en_US:en

Which will then have LXD automatically set those whenever you use “lxc exec” against that particular container.

If you run

locale

in a container, it should show you the default shell encoding for this container.
If the output is like

LANG=
LANGUAGE=
LC_CTYPE=“POSIX”
LC_NUMERIC=“POSIX”
LC_TIME=“POSIX”
LC_COLLATE=“POSIX”
LC_MONETARY=“POSIX”
LC_MESSAGES=“POSIX”
LC_PAPER=“POSIX”
LC_NAME=“POSIX”
LC_ADDRESS=“POSIX”
LC_TELEPHONE=“POSIX”
LC_MEASUREMENT=“POSIX”
LC_IDENTIFICATION=“POSIX”
LC_ALL=

then you get the problem that you describe above. The POSIX locale has a 7-bit encoding and only supports Latin (English) characters.

One way to go around this issue, is to

lxc exec mycontainer -- sudo --user ubuntu --login

Then, the output of the locale command would be

LANG=en_US.UTF-8
LANGUAGE=
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=

which is fine.

Right and the environment.* keys I mentioned earlier will make it so that even “lxc exec mycontainer bash” will have the right locales set.

I tried that and the output is this

blades@scw-82oof3e:~$ lxc config set meteo enviroment.LANG=en_US.UTF-8
error: Bad server config key: 'meteo'
blades@scw-82oof3e:~$ lxc config set meteo environment.LANGUAGE=en_US:en
error: Bad server config key: 'meteo

lxd --version 2.0.9
I don’t know what Iam doing wrong.

You want:

lxc config set meteo enviroment.LANG en_US.UTF-8
lxc config set meteo environment.LANGUAGE en_US:en

I’ve corrected my previous post to match.

1 Like

You did it, thank you for supporting such an “off topic”.
I wish for the best