September 2004 - Posts

Bug of the post editor of this blog

If your post contains "<" or ">", then sometimes after you re-edit your post, "<" in the source file will be changed to "&lt;", while the ">" will be changed to "&lt;".
posted by wenyang with 0 Comments

How to use Chinese characters in Athena: (3) Settings for Emacs (cont.)

Input Chinese characters in Emacs

Once your Emacs can display Chinese characters correctly, you can try to use the MULE (Multilingual Environment) for Emacs to input Chinese characters in Emacs. It can be done in two simple steps:

  1. Set languange environment to Chinese (GB or GBK).

    If you use menu, click Options->MULE->Set Language Environment->Chinese->Chinese-GB

    Note: If you haven't set coding system correctly in your .emacs file, you might need to set it manually at this time.

  2. Toggle input method to a Chinese input method. (You can find it in the MULE menu, too.)

Alternatively, to make these two steps easier, you can write a elisp function in your .emacs file, and bind it to a hotkey, e.g., Ctrl-Space.

(defun my-chinese-mode ()
(interactive)
(set-language-environment 'Chinese-GB)
; or (set-language-environment 'Chinese-GBK)
(set-input-method 'chinese-py-punct)
)

(global-set-key (kbd "C-SPC") 'my-chinese-mode)

Then when you press Ctrl-Space in your Emacs, it will switch to Chinese input method.


Note: You would probably feel the chinese-py-punct input method is quite naive if you, like me, have been used to some "advanced" input methods such as Ziguang Pinyin. Anyway, it provides a simple way to input most frequently used Chinese characters, without installing other software in your system.

Other use of Emacs (BBS client, etc.)

Emacs has a built-in terminal-emulator, in which you can telnet to remote servers that support ANSI colors. "M-x ansi-term" will start a terminal-emulator in a new buffer. This is particularly useful and convenient, if you ever want to connect to a BBS in your Emacs. Of course you have to make sure your Emacs can display Chinese characters properly before you connect to a Chinese BBS site. If you want many BBS-specific features (such as anti-idle), however, you might turn to some "professional" telnet clients. As far as I know, qterm is a good choice under Linux.

For more setting about Emacs, you might want to try the following resources (many other useful documents can be found online, try google!):

posted by wenyang with 0 Comments

How to use Chinese characters in Athena: (2) Settings for Emacs

Display Chinese Characters in Emacs

Usually, if you modify your Emacs config file (i.e., ~/.emacs or ~/.emacs.el) properly, you will be able to display the GB2312 character set, provided that your workstation has at least one Chinese font available. (If you are to check whether the system has provided Chinese fonts or not, try fc-list or xfontsel.)

The following elisp commands will, at least in most cases, enable the display of Chinese characters:

(set-terminal-coding-system 'chinese-iso-8bit)
(set-keyboard-coding-system 'chinese-iso-8bit)
(set-language-environment 'Chinese-GB)
(setq locale-coding-system 'chinese-iso-8bit)
(setq current-language-environment "Chinese-GB")

If your system has fonts that support GBK or GB18030, you may think of using a package called "chinese-gbk" to let Emacs support GBK fonts. If so, instead of setting to language environment to Chinese-GB, you would probably need to set it to Chinese-gbk, by adding the following commands in your .emacs file:

(load "chinese-gbk") ; need to download and install corresponding elisp files
(set-keyboard-coding-system 'chinese-gbk)
(set-selection-coding-system 'chinese-gbk)
(set-keyboard-coding-system 'chinese-gbk)
(set-language-environment 'chinese-gbk)
(setq locale-coding-system 'chinese-gbk)
(setq current-language-environment "Chinese-GBK")

After changing .emacs file, you would need to let Emacs re-evaluate the settings to make it take effect. Either runs the command eval-current-buffer for your .emacs file, or close/kill your current Emacs and then run it again.

Try to open a text file with Chinese characters. If, instead of displaying the Chinese fonts properly, you see a bunch of "boxes", this means either your system does not have an Chinese font available, or your Emacs cannot find a proper fontset to display the characters. Try to specify a useful fontset for your Emacs. For example, in the Linux version of Athena, if SimSun and Ming (a Traditional Chinese font) are available, you can use:

(if (not (member '("-*-tahoma-normal-r-*-*-16-*-*-*-c-*-fontset-chinese"
. "fontset-gbk") fontset-alias-alist))
(progn
(create-fontset-from-fontset-spec
"-*-tahoma-normal-r-*-*-16-*-*-*-c-*-fontset-gbk,
ascii:-*-*-medium-r-normal-*-16-*-*-*-*-*-iso8859-1,
chinese-gb2312:-*-simsun-medium-r-normal-*-16-160-*-*-*-*-gb2312*-*,
korean-ksc5601:-*-medium-r-normal-*-*-*-ksc5601*-*,
chinese-cns11643-5:-*-simsun-medium-r-normal-*-16-160-*-*-*-*-gbk*-0,
chinese-cns11643-6:-*-simsun-medium-r-normal-*-16-160-*-*-*-*-gbk*-0,
chinese-cns11643-7:-*-simsun-medium-r-normal-*-16-160-*-*-*-*-gbk*-0,
chinese-big5-1:-*-Ming(for ISO10646)-*-*-*-*-16-160-*-*-*-*-big5*-*,
chinese-big5-2:-*-Ming(for ISO10646)-*-*-*-*-16-*-*-*-*-*-big5*-*" t)
)
)

(setq default-frame-alist
(append
'((font . "fontset-gbk"))
default-frame-alist))

posted by wenyang with 0 Comments

How to use Chinese characters in Athena: (1) Foreword

MIT provides for its community a powerful computing environment: Athena.

As a non-native speaker of English, sometimes I still feel it necessary to use Chinese characters -- to read mails (and reply), to surf the internet with a browser (or hang around the BBS), or to take notes -- when I use Athena.

Unfortunately, most Athena workstations, which use either Red Hat Linux or Sun OS (Solaris), have (by default) poor support for the use of Chinese characters. None of them provides a easy-to-use tool to setup an environment that enables the display and input of Chinese words.

As I myself am a novice of Linux, it is not easy for me to have a deep insight of this problem. Therefore I began to search a solution from the internet. I found a few potential tricks, then I tried them. Some of them work! Here is a brief summary:

  • Most Athena workstations have a built-in Chinese font which has a limited supports of the GB2312 character set. Some programs (e.g. Mozilla) can make use of this font. But GB2312 is somewhat outdated, since many commonly used characters are missing in this national standard, which was firstly accepted in the year of 1980.
  • The one editor, GNU Emacs with MULE (Multilingual Environment) can be config to provide a primitive (but good enough!) way to view and input Chinese characters.
  • By installing new fonts and do some configurations, we will be able to use the GBK (or even GB18030) character set, both in console and in X environment.
  • We can install a Chinese input method for Linux, such as fcitx, which works as good as, if not better than, the UNISPY (ZiGuang PinYin) in MS Windows.
posted by wenyang with 0 Comments