You are not logged in.

#1 2012-06-23 04:55:08

mitch_feaster
Member
From: San Diego, CA
Registered: 2011-02-27
Posts: 55
Website

LOCALE woes... LANG, UTF-8 in gnome-terminal, etc

I'm having some weird localization issues. When I set up my laptop I chose `C' for the locale, but recently decided to switch to `en_US.UTF-8'. However, LANG is not being set the way I would expect... It's set to "C" when I open gnome-terminal initially, but then gets set to "en_US.UTF-8" when I run bash as a login shell (`bash -l') or run `tmux' (which is weird enough on its own) but then UTF chars quit working!

Here's the output of `locale' when I open gnome-terminal initially:

$ locale
LANG=C
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=

However, when I run bash as a login shell (`bash -l'), LANG and friends get set to what I expect:

$ 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=

Here's my `locale -a':

$ locale -a
C
en_US
en_US.iso88591
en_US.utf8
POSIX

rc.conf: http://sprunge.us/ILdd
locale.gen: http://sprunge.us/fLfG

Ironically, UTF-8 characters only seem to be working when I launch gnome-terminal initially (i.e. when $LANG=="C")! When I run bash as a login shell (with the `-l' argument) UTF-8 doesn't work anymore (see http://i.imgur.com/63Hwx.png and http://i.imgur.com/9MEhp.png).


I've done `locale-gen', several reboots, re-installed initscripts, tried fiddling with LC_ALL, scrubbed my various bash init files, etc. but to no avail... Any ideas???

Offline

#2 2012-06-23 16:57:06

MadTux
Member
Registered: 2009-09-20
Posts: 553

Re: LOCALE woes... LANG, UTF-8 in gnome-terminal, etc

Not sure if that makes any difference, but on my system it reads

LOCALE=en_US.utf8

instead of

LOCALE="en_US.UTF-8"

So, I don't have quotes around the locale, which is consistent with the Beginner's Guide:

https://wiki.archlinux.org/index.php/Be … ON_section

Offline

#3 2012-06-23 16:59:17

headkase
Member
Registered: 2011-12-06
Posts: 1,983

Re: LOCALE woes... LANG, UTF-8 in gnome-terminal, etc

When setting up my locale, which I always forget to do during installation so I do it after, I always use this: Guide.

Offline

#4 2012-06-23 17:56:29

mitch_feaster
Member
From: San Diego, CA
Registered: 2011-02-27
Posts: 55
Website

Re: LOCALE woes... LANG, UTF-8 in gnome-terminal, etc

Well, I tried switching between the various spellings for LOCALE/LANG (en_US.UTF-8, en_US.utf8), and tried moving things around between /etc/rc.conf and /etc/locale.conf, getting rid of everything in my .bashrc and .bash_profile, getting rid of all bash-completion stuff, but still no dice...

I've also been using grawity's locale-check script to help debug. It looks like my terminal always has LANG=C, even when my shell's LANG looks good (after running another bash login shell or starting tmux). Here's the before and after:

$ ./locale-check 
 * Shell:     2220 bash
 * Terminal:  2213 gnome-terminal
warning: (shell) LANG: non-UTF8 locale "C"
warning: (term) LANG: non-UTF8 locale "C"

problem: Your current locale is using a legacy charset.
 * Change your locales to their UTF-8 variants.

$ bash -l
$ ./locale-check 
 * Shell:     3842 bash -l
 * Terminal:  2220 bash
warning: (term) LANG: non-UTF8 locale "C"

problem: Your current locale is using a legacy charset.
 * Change your locales to their UTF-8 variants.

I'm still trying to understand why my LOCALE only gets set when I run a login shell... After reading the INVOCATION section of BASH(1) I don't think think /etc/profile.d/locale.sh will be sourced on an `interactive  shell that  is  not a  login shell'. However, when I run it as a login shell, /etc/profile.d/locale.sh gets sourced and LANG gets set. Maybe /etc/profile.d/locale.sh isn't getting sourced in whatever environment launches gnome-terminal? (I'm just launching it with gnome-shell or with synapse).

Offline

Board footer

Powered by FluxBB