看板FreeBSD
标 题Re: screen with utf8.
发信站Dept. of Computer & Information Science, NC (Sun May 12 20:01:31 2002)
转信站Ptt!news.ntu!freebsd.ntu!news.cis.nctu!not-for-mail
> On Tue, 7 May 2002 14:48:33 +0000 (UTC), [email protected] wrote:
screen 自 3.9.11 起,提供了一项 encoding transaltion 的新功能。
简单的说,就是让使用者可以在 screen 里,显示不同的内码。
举个例子,我们可以在 window 1 连上繁体中文 BBS, window 2 以
w3m/lynx 观看简体中文网站,并在 window 3 中阅读日文文件等等。
不过,在使用这项功能前,建议先抓下面这个档:
http://linux.nctu.edu.tw/~yjchou/work/screen/18
备份 {/usr,/usr/local}/share/screen/utf8encoding/18 以後覆盖过去。
这样,日文假名才能正确转译。
接着,找一个支援 utf8 的 terminal emulator。如 utf8 xterm。
MS Window 上则可使用 PuTTY。将字型与字集调整好就完成准备工作。
在 screen 中,有两种 encoding type。一种是 display encoding;
也就是输出到萤幕上的编码方式,同时也是使用者由 terminal 输入
的编码方式。另一种是 internal encoding。使用 encoding transaltion
时,必须将 display encoding 设为 utf8,而 internal encoding 则
可以视当时的需要动态的改变。
所以,在初始化 screen 时,请先在 ${HOME}/.screenrc 内加上
defencoding big5
表示预设的 internal encoding 为 big5;并在启动时加上 -U 的参数,
代表 utf8 display encoding。 (e.g % screen -DRU )
这样子,启动後应该能够正常的显示(繁体)中文。就如同一般使用的情况。
而当有需要观看、浏览 gb2312、euc-jp/jis、utf8 编码的内容时,可以
用 <CMD> :encoding (ENCODING_NAME) 来动态更改目前所在 window 的
internal encoding。目前可用的编码有 big5, utf8, eucJP, eucCN,
eucKR 等等。
除了 internal/display encoding 设为 big5/utf8 的方式之外,这个
功能还有另外一种用法;即利用 <CMD> :encoding utf8 big5
将 internal/display encoding 设为 utf8/big5 (也就是反过来用)
这可以让一般以 big5 字集/编码为主的 terminal client 使用,透过
这个功能,让 screen 将 utf8 的内容转为 big5 的编码,使 client
可以看到正确的字。(不过,只限於 big5 吃的下的转换。jp/cn/kr的
法亦同)
那除了 big5 <-> utf8, eucCN <-> utf8, eucJP <-> utf8 以外,能够
做 big5 <-> eucCN, 甚至 big5 <-> eucJP 吗? 很抱歉,目前只能做至
一种 encoding 与 utf8 的转换。
最後,解释一下 screen 的 encoding translating table 机制。
当使用/切换新的 encoding 时, screen 会到
${prefix}/share/screen/utf8encoding/
下找寻对应的 table (01 for gb2312, 02 for jis-x-0208, 03 for kr,
04 for jis-x-0212, 18 for big5)
以 big5 table 来说,table 内基本上是多组 (big5, utf8) 的 pair.
转码时会搜寻 table 来做 big5 <-> utf8 互相转换的工作。理论上,
应该可以做到 big5 <-> eucJP 时,利用 utf8 作为中间产物来达成,
不过目前 screen 没有做,有需要的人可以自己改,或是等下个版本,
看看有没有支援:
在修改 big5 table 时,写了一支小程式帮忙。在
http://linux.nctu.edu.tw/~yjchou/work/screen/
下可以找到。
用法:
% perl conv.pl < table.big5 > ${prefix}/share/screen/utf8encoding/18
同目录下我放了另一个合并了 big5.eten 与 big5e 的 table, table.big5e .
不过遗撼的是,screen 似乎将 0x80 - 0x9f 当作 seqeuence char , 所以
big5e 新增的 0x8040 - 0xa0fe 中,只有 0xa040 - 0xa0fe 可以正常转译。
因此,我作的 big5 table (18) 就没有放 big5e 进去。
--
周 业 及 (Chou Yeh-Jyi)
======================= Don't feel as if you're Bible salesmen.
[email protected] The world has too many of those already.