I'm trying to change encoding in the urxvt current session by changing LANG
variable. Howerever, it seems like it doesn't apply immediately. Here is what I do:
Available locales:
$ locale -a
C
en_US.utf8
POSIX
ru_RU.koi8r
ru_RU.utf8
Before setting new locale:
$ echo "а" | od -t x1
0000000 d0 b0 0a # good! UTF-8
# | a ||NL|
After:
$ export LANG=ru_RU.KOI8-R
$ echo "а" | od -t x1
0000000 d0 b0 0a # hm..expect 'c1 0a'
Fork new urxvt instance by running $ urxvt &
and finally get what I want:
$ echo "а" | od -t x1
0000000 c1 0a
Why doesn't LANG
change the behavior in the first place?
There are two factors:
LANG
is not the first environment variable checked. According tolocale(7)
,LC_ALL
andLC_CTYPE
would be checked first:For the latter, look at the output from the
locale
command, which lists all of the environment variables which would be used:Just changing
LANG
should not change the other variables, but changingLC_ALL
generally does that.