perl-unicode

Re: UTF8 Terminal Detection

2001-11-13 01:27:26
Hi,

At Mon, 12 Nov 2001 23:24:20 +0100 (CET),
Markus Kuhn wrote:

I don't think, this is feasible or useful. Environment variables can only
be set by a parent process for its children. In the case of a pty terminal
emulator that starts applications as child processes (e.g., xterm), we
have already the locale variables providing the encoding information to
both the terminal emulator (e.g., xterm) and its children (shell,
applications). In other connections, terminal and applications are just
connected by some byte-serial communications channel that doesn't transmit
environment variables. Modifying all communications channels to do that is
further of then using UTF-8 everywhere, so why bother?

I have been using ~/.bashrc including the following line for long time.

if [ "$TERM" = "linux" -o "${TERM%-*}" = "xterm" ]
then
  LANG=C
else
  LANG=ja_JP.eucJP
fi

This works for terminals which I usually use
 - terminals without Japanese (EUC-JP) support
   Linux console, Linux framebuffer console, and xterm
 - terminals with Japanese support
   "kon" console, "jfbterm" console, rxvt compiled with Kanji support,
   kterm, Tera Term Pro, and shell mode in emacs on X11

For terminals which support Japanese, I'd like to set LANG=ja_JP.eucJP
so that I can use Japanese.  However, using LANG=ja_JP.eucJP in other
terminals will cause mojibake.  For example,
   http://www.debian.or.jp/~kubota/mojibake/xterm.png
Such mojibake can be avoided by setting LANG=C (English messages will
be displayed, which can be read using English-Japanese dictionary).

Because it is really bothering to set LANG or to invoke screen manually
each time I start a new terminal, I am now almost happy with the above
setting.

However, "looking TERM" way does not work well for every cases nor
is a right way.  Also, this way does not work for non-Japanese languages
as well as for Japanese, because "TERM=kterm" is available and is
widely used for Japanese-capable terminals while there are no
replacement for Korean, Chinese, Thai, nor other languages.
For example, Hanterm sets TERM=xterm.

You may think why I have to use terminals without Japanese support.
Setting LANG=ja_JP.eucJP and using Japanese-capable terminals only
would make me happy.  However, everyone have chance to use Linux 
(or BSD, ...) console.  And, many softwares invokes xterm directly.

Anyway, using TERM variable for this purpose is not reliable,
though this has been a real daily need for us for long years.

---
Tomohiro KUBOTA <kubota(_at_)debian(_dot_)org>
http://www.debian.or.jp/~kubota/
"Introduction to I18N"  http://www.debian.org/doc/manuals/intro-i18n/

<Prev in Thread] Current Thread [Next in Thread>