Chinese Computing

First get the latest version of GNU Emacs. There is a Windows 95/NT version of GNU Emacs. Get the latest version, 20.6 (20.4 and above should work).

Fonts

For Microsoft Windows you can get a set of Microsoft Chinese fonts which work great with Emacs. These are available at this page. You can get just the Traditional and/or the Simplified Chinese pack, depending on what type of Chinese you work with. Be sure to get not just the IME's but also the Language packs. You will end up with fonts called "MS Song" and "MS Hei" for simplified Chinese and "MingLiU" for traditional Chinese. See the section on the .emacs file below for information on how to tell Emacs to use these fonts.

Loading Files

To tell Emacs that the following command (loading a file, saving a file, selecting a block of text) will use a Chinese codeset, type "C-x Enter c" (where C- means hold the control key while pressing "x") and then cn-big5 or cn-gb-2312. So to load a text file encoded in Big5, first type "C-x Enter c", "cn-big5", hit return, type "C-x C-f" and the file name.

Copying Text

When cutting, copying or pasting text, whether inside Emacs or with other programs, set the selection encoding to either GB or Big5. This is done by typing: "M-x set-selection-coding-system", hitting return and then typing either "cn-big5" or "cn-gb-2312", depending on the original encoding of the file. You only need to select the encoding system once when you open Emacs. Emacs will not convert between GB and Big5.

Inputting Chinese

To type in Chinese, get the Emacs International input methods (LEIM). A precompiled version of this is available in a zip file. Unzip in the lisp/international subdirectory under the main Emacs directory and make sure to keep the directory structure in the zip file. Unfortunately, the current version of Emacs does not work with Microsoft's Chinese IME's.

You can select the specific input method to use by typing "M-x set-input-method", hitting Enter and then hitting the tab key to get a list of all available input methods. I often use "chinese-py-b5". You can turn on and off the input method by pressing C-\ (the control and the backslash key).

.emacs File

Below is a sample .emacs file to enable Chinese and to tell it to use the Chinese fontset. The (load-b5) tells Emacs to assume all documents are in Big5 (Traditional Chinese). You can take it out if desired. You can do something similar for GB by substituting cn-gb-2312.

(create-fontset-from-fontset-spec
      "-*-courier new-normal-r-*-*-13-*-*-*-c-*-fontset-chinese,
      chinese-gb2312:-*-MS Song-normal-r-*-*-16-*-*-*-c-*-gb2312*-*,
      chinese-big5-1:-*-MingLiU-normal-r-*-*-16-*-*-*-c-*-big5*-*,
      chinese-big5-2:-*-MingLiU-normal-r-*-*-16-*-*-*-c-*-big5*-*" t)


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

(defun load-b5 () 
  (set-language-environment 'chinese-big5) ; or 'chinese-gb
  (set-selection-coding-system 'cn-big5-dos)
  (set-terminal-coding-system 'cn-big5-dos)
  (set-w32-system-coding-system 'cn-big5-dos) ; for Chinese Windows users
)


(load-b5) ; or substitute gb for big5 in load-b5 and call (load-gb)

Unicode

Emacs also offers some limited Unicode support through supplementary programs. If you are just interested in working with UTF-8, then Otfried Cheong's Unicode encoding for GNU Emacs package works very well. The package relies on Mule-UCS, a solution that also works with UTF-7 and UTF-16, but I have not personally used it. The next major version of Emacs (v 21) will unfortunately not use Unicode as its internal encoding and but will have better Unicode support.

More Information

Finally, you can keep track of current questions and developments relating to Emacs and Chinese by searching for Chinese at the NT-Emacs mailing group. There is also an excellent page on international character set support in Emacs and a Chinese page that talks about Emacs. Also see "Emacs - Viewing and Editing Chinese".

Thanks to Jason Rumney for his comments on this page.