Gnome Terminal and Character Encodings

Since upgrading to GNOME 2.14, I have been revisited by an annoying
problem with gnome-terminal. Gnome-terminal sets your character encoding
to being the same as your locale by default, which unfortunately was
being detected as ANSI_X3.4-1968, while I had my $LANG set to
en_GB.UTF-8 in my ~/.bash_profile. The reason it wasn’t being
detected was because nothing between logging in and starting
gnome-terminal looked at that file, so gnome-terminal thought the locale
was C.

The result was corrupt
display when programs attempted to display unicode characters. I could
fix it by changing the character encoding using the menu, but I’d have
to do this for every tab, which quickly becomes annoying. Time to find a
fix.

Turns out that you need to tell gdm to set the right locale, which
you can do by configuring ~/.dmrc. Mine now looks like:

[Desktop]
Session=gnome
Language=en_GB.UTF-8

Obviously, the important section is the Language line. You
need to set it to a locale that exists on your system, which you can
find using locale -a. Once
you’ve set that and logged in again, everything should be working
correctly.

One thought on “Gnome Terminal and Character Encodings

  1. Celada
    on said:

    You’ve highlighted a much more important problem than just your locale: you have nothing that reads and sets up your environment when you log in. Your .bash_profile might do a lot more than configure your locale. It may set up environment variables to set your favorite pager, editor, your PATH, your local timezone (if different from the host’s globally configured timezone). It might load your SSH key (prompting you for the passphrase) or log you into a corporate environment or do just about anything else you can think of. You really ought to have this file executed when you log in!

    Actually I am not sure how gdm is supposed to make sure your .profile/.bash_profile/.login/.zlogin/.zprofile (depending on your shell) gets read. I have code in my .xsession that detects whether it has been done incorrectly and restarts itself under a login shell (by using the shell’s -l option) if so but I’m sure there’s a better way.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.