[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Testing for UTF-8 tty mode



Andries Brouwer writes:

> fprintf (f, "\030\032" "\r\357\200\240" "\033[6n\033D");
> Simple, you said? It is terrible, dirty, wrong.
> If there is no easy way to ask the kernel whether it is
> in UTF8 mode, then we must add an ioctl, preferably a nice
> generic one, so that we won't have to add one every week.

There are two problems with an ioctl: It applies only to the console,
not to xterm or other ttys. It is specific to Linux and will not aid
portability of applications between Linux, FreeBSD, NetBSD and other
Unices.

Applications already have a way to test for UTF-8 mode: the LC_CTYPE
environment variable. (Sample code at
ftp://ftp.ilog.fr/pub/Users/haible/utf8/utf8locale.c.)
This is what POSIX has foreseen, it is designed to work across Unix
systems.

Another way to indicate UTF-8 tty mode would be to set the TERM
environment variable to, say, "linux-utf8" or "xterm-utf8", and
define a new ncurses attribute for UTF-8 mode.

Why do we need a third way to indicate UTF-8 tty mode, specific to
consoles?

                      Bruno
-
Linux-UTF8:   i18n of Linux on all levels
Archive:      http://mail.nl.linux.org/lists/