Thursday, April 20, 2006

Unicode and Locale

Running "locale" shows that my system is using something called POSIX. Changing my system locale to Unicode:
1. Compile NLS UTF8 into the kernel.
2. Check that the locale I want (en_US.UTF-8) is availaibe in "/etc/locales.build".
3. Enter this line
###
LC_ALL="en_US.UTF-8"
###

into this file: /etc/env.d/02locale

- Note that running "locale -a" will show "en_US.utf8" (Note lowercase and absence of hyphen. And I quote the sentences from the Gentoo Forums:

locale -a lists the encoding part of the locale in lower case without any hyphens but these instructions always use UTF-8. The reason is that while glibc understands both forms of the name many other programs don't. The most common example of which is X. So it is best to always use UTF-8 in preference to utf8.

4. Make sure that in /etc/rc.conf the line UNICODE="yes" is uncommented.
5. Run "env-update && source /etc/profile"
6. Sometimes certain error messages may appear when running certain programmes:
a.
Gdk-WARNING **: locale not supported by Xlib (GTK/Gnome app)
b. Qt: Locales not supported on X server
(Qt/KDE app)
- Make sure the current system locale is listed in "
/usr/X11R6/lib/X11/locale/locale.dir"

The Gentoo Forum mentioned this: (But I still don't understand it, therefore have not done anything about it yet)

Where to set the environment variables is the next problem. Ideally every user on the whole system should use the same encoding i.e. UTF-8. However using a locale other than the "C" or "POSIX" locale for root is asking for trouble on Gentoo. The reason is that it can break emerges as the semantics of scripts etc can change.

The Gentoo way to set environment variables is to set it in /etc/env.d. The Desktop Configuration Guide suggests setting the locale there. But this doesn't support setting a different locale for root. Some suggest suggest changing the locale in /etc/profile. It is possible to set the locale differently in /etc/profile for root and other users as is done with the PATH environment variable. Otherwise you can set them in $HOME/.bashrc or $HOME/.xinitrc if you only want the locale set under X.



No comments: