You are not logged in.

#1 2017-05-29 16:49:44

kiljacken
Member
Registered: 2017-05-29
Posts: 4

Locale encoding goes to lowercase.

Hello!

I'm having a weird issue with setting my locale, that cropped up when trying a new piece of software.

In /etc/locale.gen I have both en_DK.UTF-8 and en_US.UTF-8 enabled and built, and thusly I set LANG=en_DK.UTF-8 in /etc/locale.conf.

locale-ctl correctly returns en_DK.UTF-8, but locale returns en_DK.utf8 (notice the lowercase and lack of dash).

Has anybody seen something like this before, and can point me in the right direction?

Cheers.

Offline

#2 2017-05-29 19:01:21

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,346

Re: Locale encoding goes to lowercase.

"locale" should print en_DK.UTF-8, but "locale -a" should print "en_DK.utf8" - that is normal expectable.

In case of worries, post the outputs of
locale
locale -a
localectl
cat /etc/locale.conf

Online

#3 2017-05-29 19:15:46

kiljacken
Member
Registered: 2017-05-29
Posts: 4

Re: Locale encoding goes to lowercase.

Okay. Does the following look right then?

kiljacken@exheater ~> locale
LANG=en_DK.utf8
LC_CTYPE="en_DK.utf8"
LC_NUMERIC="en_DK.utf8"
LC_TIME="en_DK.utf8"
LC_COLLATE="en_DK.utf8"
LC_MONETARY="en_DK.utf8"
LC_MESSAGES="en_DK.utf8"
LC_PAPER="en_DK.utf8"
LC_NAME="en_DK.utf8"
LC_ADDRESS="en_DK.utf8"
LC_TELEPHONE="en_DK.utf8"
LC_MEASUREMENT="en_DK.utf8"
LC_IDENTIFICATION="en_DK.utf8"
LC_ALL=

kiljacken@exheater ~> locale -a
C
en_DK.utf8
en_US.utf8
POSIX

kiljacken@exheater ~> localectl 
   System Locale: LANG=en_DK.UTF-8
       VC Keymap: dk-latin1
      X11 Layout: dk
       X11 Model: pc105
     X11 Variant: nodeadkeys

kiljacken@exheater ~> cat /etc/locale.conf 
LANG=en_DK.UTF-8

What about the $LANG environment variable? I assume it should be the one set in locale.conf, but on my system:

kiljacken@exheater ~> echo $LANG
en_DK.utf8

Offline

#4 2017-05-29 19:41:27

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,346

Re: Locale encoding goes to lowercase.

No - "printenv" output?
What kind of session is this and what's the rep. output when logging into a console (ctrl+alt+f2) and notably when logging in as root there?

Online

#5 2017-05-29 21:01:45

Ropid
Member
Registered: 2015-03-09
Posts: 1,069

Re: Locale encoding goes to lowercase.

I see the same behavior here. I use lightdm and i3. In i3 I use gnome-terminal.

When I log into a console, this does not happen. At a bash prompt there, I see this:

$ echo $LANG
en_IE.UTF-8

And in X at a bash prompt run through gnome-terminal, I see this:

$ echo $LANG
en_IE.utf8

I also checked xterm and urxvt started by i3 through a launcher tool, and those also get "utf8".

When I inspect the environment of different processes in htop by selecting them and hitting the "e" key, I see that the parent lightdm process is "LANG=en_IE.UTF-8", but its child i3 process is "LANG=en_IE.utf8". For programs I start through i3 (Firefox etc.), I see "utf8".

The gnome-terminal program is weird in that it makes a process "gnome-terminal-server" show up as a child of a "systemd --user" process. The "systemd --user" process has "UTF-8" in its variable, but gnome-terminal-server has "utf8".

I tried to find out if there's a script that sets this "LANG=...utf8", but found nothing. I scrolled through the output of these commands here:

sudo ack LANG /etc
rg LANG= /usr   # rg = "ripgrep" here because ack was very slow for /usr
rg --hidden LANG= ~   # needs --hidden or it won't look at .bashrc or .config/

The only script that might write to $LANG at login for me is a file /etc/profile.d/locale.sh that sets LANG=C if it is not defined. It also sources a file ~/.config/locale.sh if it exists, but I don't have a file like that.

Last edited by Ropid (2017-05-29 21:03:35)

Offline

#6 2017-05-29 21:06:42

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,346

Re: Locale encoding goes to lowercase.

I see that the parent lightdm process is "LANG=en_IE.UTF-8", but its child i3 process is "LANG=en_IE.utf8".

I bet on lightdm. Try startx or xdm.

Online

#7 2017-05-29 21:31:12

kiljacken
Member
Registered: 2017-05-29
Posts: 4

Re: Locale encoding goes to lowercase.

I run lightdm too, that could definitely be the cause. Back to startx, who needs GUIs anyways.

Offline

#8 2017-05-29 22:31:02

Ropid
Member
Registered: 2015-03-09
Posts: 1,069

Re: Locale encoding goes to lowercase.

I just checked, and it really seems it's lightdm. It doesn't happen when using startx. Trying to search about the problem online, I found people complaining about this. For some reason it's translating the name to what it's like in the output of "locale -a".

I decided to keep the weirdo lightdm and work around it by changing the utf8 to UTF-8 in ~/.xprofile like this:

export LANG="${LANG/utf8/UTF-8}"

This should hopefully never break something in the future if I forget about the line.

Offline

#9 2017-05-29 23:29:44

loqs
Member
Registered: 2014-03-06
Posts: 19,100

Re: Locale encoding goes to lowercase.

Offline

#10 2017-05-30 00:19:11

Ropid
Member
Registered: 2015-03-09
Posts: 1,069

Re: Locale encoding goes to lowercase.

loqs wrote:

I'm guessing this isn't it because that "locale_var_names[]" array has entries for things like LC_COLLATE, LC_TIME, etc., and those are all being kept like I've set them in /etc/locale.conf. Only LANG is getting changed.

Offline

#11 2017-05-30 07:04:57

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,346

Re: Locale encoding goes to lowercase.

http://bazaar.launchpad.net/~lightdm-te … age.c#L180 looks fishy - lightdm_get_language tries LANG but returns something that's fished out of a "locale -a" subprocess (it really actually runs "locale -a". several times. please use xdm, one can configure it to be not ugly; "pacman -S xdm-archlinux" has a nice pattern on this. suboptimal color choice but a start ;-)

Online

#12 2017-05-30 07:20:46

justasug
Member
Registered: 2014-08-03
Posts: 174

Re: Locale encoding goes to lowercase.

I might be missing something, but is the only problem you are having the inconsistency regarding the case? As in: .utf8 instead of UTF-8?
Because I've been having the same behaviour for years now and never experienced any bugs that I could connect with this. It's not really giving me any problems.

Offline

#13 2017-05-30 07:50:43

kiljacken
Member
Registered: 2017-05-29
Posts: 4

Re: Locale encoding goes to lowercase.

justasug wrote:

I might be missing something, but is the only problem you are having the inconsistency regarding the case? As in: .utf8 instead of UTF-8?
Because I've been having the same behaviour for years now and never experienced any bugs that I could connect with this. It's not really giving me any problems.

Well, I'm using an in-development cross-platform code editor, and apparently querying X's for an input method using the lowercase version of the locale doesn't work.
So the key issue lies there. (Or well, perhaps in the creator loads am IM from X, perhaps another api call could fix it)

Offline

#14 2017-05-30 11:05:33

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,346

Re: Locale encoding goes to lowercase.

The IANA code is "UTF-8", everything is else "wrong".
However, putting a hyphen/dash in there caused a lot of trouble (because of its special meaning in all sorts of code syntax) so "utf8" became common (notably also on OtherOS™)

Therfore every code is doing "smart" in expecting any case insensitive variant of
* UTF-8
* utf8
* Utf 8
but the "legal" code is "UTF-8" and if a DM just changes that export on the fly (away btw. from an explicit user export ...) that DM simply has a bug.


---
Henceforce (and henceforth as well), 8-bit unicode shall be known as "UTF-8".
Wrongspelling shall be punishable by decapitation or the eternal usage of DOS.
So let it be written. So let it be done.
                                              -- Seth, Dictator of the world

See how easy that is?

Online

Board footer

Powered by FluxBB