$ LC_ALL=zh_CN.gb2312 application_name
LC stands for locale. We don't have to use LC_ALL, which is too radical for purists. LANG=zh_CN.gb2312 would do the job. You might have guessed what zh_CN.gb2312 is already.
Logging on Chinese BBS or reading mails using Pine, we rely on a Chinese savvy console to display Chinese. The console programs coming with Gnome (gnome-terminal) and KDE (konsole) are both I18N aware. To make them display Chinese:
$ LC_ALL=zh_CN.gb2312 gnome-terminal
My personal favorite is rxvt, simply because I've been using it for quite a while. The good old xterm knows about multi-byte languages, but not GB2312 (now I'm talking about encoding), AFAIK. You'll need a UTF8 font to use Chinese in xterm and I see no reason for such trouble.
Talking about fonts, I have some bitmap Chinese fonts installed in /u/bh/fonts and some truetype fonts in /u/bh/fonts/truetype. The SongTi comes with Windows (simsun.ttf) looks not bad, though I've seen much better ones. To use these fonts, add the following to your .xsession
xset fp+ /u/bh/fonts,/u/bh/fonts/truetype
Recent versions of Mozilla display Chinese very well. The department version is built with XFT. If you want to use truetype fonts, add
<dir>/u/bh/fonts/truetype</dir>
to your ~/.fonts.conf.
The case for PostScript is a little complicated. The good news is that you can actually open the file and edit it. PostScript treats Chinese (somewhat) like western languages. You still use findfont to specify a font and show to put the characters on paper (screen). An example would be
%!PS
/SimSun-Medium-GBK-EUC-V findfont 60 scalefont setfont
500 700 moveto (°µ³¾ËÄÁ²Â¥¹Ûåijö) show
showpage
What complicates matters is that there are multiple encodings for Chinese. When we talk about GB2312, which is a national standard of character set, we usually imply an EUC encoding. We also have different writing conventions (horizontal and vertical). Hence the EUC and V in the above font specifier. Now the good news is that if you don't have SimSun-Medium, you can edit the file and change it to a font you have, say STSong-Light, which, BTW, is a light-weight Song font cast by Sinotype, a foundry in Changzhou, Jiangsu and which is more pleasing than SimSun. The substituter must have the same char-map as the substitute-e.
If you have a PostScript file with Chinese characters in it and you can't see them correctly, I can probably help.
PDFs are easier than PostScript. Try acroread in /u/bh/linux/Acrobat5/bin/.
$ mount -o iocharset=gb2312 /mnt/cdrom
You'll need the root privilege to do that, though.
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/u/bh/linux/lib:/u/bh/linux/lib/unicon2
$ LC_ALL=zh_CN.gb2312 /u/bh/linux/bin/chinput
$ export XMODIFIERS=@im=Chinput
Now you if want to input Chinese in any I18N compliant application, say Mozilla, you do
$ LC_ALL=zh_CN.gb2312 mozilla
CTRL-SPACE activates the input window.
Rxvt doesn't understand the XMODIFIERS directive. You need to tell it through command line:
$ LC_ALL=zh_CN.gb2312 /u/bh/linux/bin/rxvt -im Chinput
Other choices of input methods include XCIN, Fcitx and Scim. Do an Internet search if you want to try them out.
I have a very out-of-date page about CJK-LaTeX. It needs significant updating, especially how to use truetype Chinese fonts.
Mozilla (and its offspring Firefox) does printing by converting the web page into a PostScript file first, which makes printing Chinese in Mozilla the same as printing Chinese PS files. Look at /usr/lib/mozilla-version/defaults/pref/unix.js, you'll see a line like the following
pref("print.postscript.nativefont.zh-CN", "MSungGBK-Light-GBK2K-H");
If you've read the above description about PS fonts, you know that Mozilla uses the font MSungGBK-Light with the CMap GBK2K-H (H meaning horizontal). And if you open the PS file generated by Mozilla, you'll find
/Unicode2NativeDictzh-CN 0 dict def
/zh-CN_ls {
/NativeFont /MSungGBK-Light-GBK2K-H def
/UCS2Font /Courier def
/Unicode2NativeDict Unicode2NativeDictzh-CN def
/unicodeshow1 { real_unicodeshow } bind def
/unicodeshow2 { real_unicodeshow_native } bind def
} bind def
That's how Mozilla uses the font. Unfortunately, this font name is configured to point to an uninstalled TTF font,as of this writing. We need to override the font, say to Song-Medium, which is a font I installed. To make a long story short, do the following.
Add export GS_LIB=/u/bh/fonts/truetype/; to your .profile. In your Mozilla profile directory, create user.js if it's not there (don't edit prefs.js directly) and put
pref("print.postscript.nativefont.zh-CN", "Song-Medium-GBK2K-H");
in it. You still can't print directly from Mozilla though, because the Chinese fonts are not embedded in the PS file generated by Mozilla. You need to use ps2ps to transform the PS file and send the transformed one to the printer. If you print Chinese a lot, which I doubt, you might want to write a script as your printing command for the browser.
Konquerer behaves similarly.