Subject: How to read/write chinese on Mule
From: [email-masked] (TAKAHASHI Naoto)
To: [email-masked]
Date: Thu, 23 Sep 93 20:23:05 JST

HOW TO READ/WRITE CHINESE ON MULE                               93/9/23

1. To display Chinese on screen

 1.1 Two character sets - GB and BIG5

   There are two character sets for Chinese, i.e. GB and BIG5.  GB is
   for the simplified characters used in P.R.C.  BIG5 is for the
   traditional characters used in Hong Kong and Taiwan.  Mule can
   handle both of them.  You can even make a file which contains both
   GB and BIG5, but care should be taken in this case.  See "1.3 About
   coding-system" if you want to make such files.

   [NOTE] BIG5 roughly corresponds to the first and second plains of
   CNS (Chinese National Standard) 11643 which defines the Chinese
   character sets.

 1.2 Fonts

   If you are running Mule under X window system, Chinese fonts are
   necessary to display Chinese texts.  Several Chinese fonts are
   distributed with cxterm, which is contributed to X11R5.

        cclib16fs.bdf           16x16 Fang Song style, GB encoding
        cclib16st.bdf           16x16 Song style, GB encoding
        cclib24st.bdf           24x24 Song style, GB encoding
        hku-ch16.bdf            16x16 Fang Song style, BIG5 encoding

   Two other fonts are available for BIG5.

        taipei15                16x15 Fang Song style, BIG5 encoding
        taipei24                24x24 Song style, BIG5 encoding

   You also need SiSheng fonts if you want to use cWnn to input
   Chinese.  (For cWnn, see 2.1)

        etl14-sisheng.bdf       7x14 SiSheng font for cWnn
        etl16-sisheng.bdf       8x16 SiSheng font for cWnn
        etl24-sisheng.bdf       12x24 SiSheng font for cWnn

   If these fonts have not been installed on your machine, ask your
   local X window administrator to install them.  The fonts are
   available via anonymous FTP from the following sites:

        etlport.etl.go.jp [192.31.197.99]: /pub/mule/fonts
        sh.wide.ad.jp [133.4.11.11]: /JAPAN/mule/mule-1.0/fonts
        ftp.mei.co.jp [132.182.49.2]:/public/free/gnu/emacs/Mule/fonts
        ftp.funet.fi [128.214.6.100]:/pub/gnu/emacs/mule/mule-1.0/fonts

 1.3 About coding-system

   When you read/write a file containing Chinese characters, you must
   specify what kind of format is used.  In the world of Mule, this
   format is called "coding-system".  Coding-system can be set in
   .emacs in your home directory.  In the following sections, we
   describe three different cases.

  1.3.1  To edit files containing GB and ASCII

   There are several ways to distinguish GB characters from ASCII
   characters.  The most frequently used method utilises the 8th bit
   as a flag.  If the 8th bit is set to 1, the character represents a
   GB.  Otherwise, an ASCII.  This method is adopted in cxterm. If you
   use exclusively GB and ASCII, this would be convenient.  To enable
   this coding-system, include the following line in your .emacs.

        (set-default-file-coding-system *euc-china*)

  1.3.2 To edit files containing BIG5 and ASCII

   Strictly speaking, there are some varients of BIG5.  The most
   widely used ones are BIG5-ETen and BIG5-HKU.  Besides that, NEWLINE
   in UNIX is different from that in DOS.  So you must specify
   appropriate coding-system depending on whether you are using Mule
   under UNIX or DOS.  Include one of the following lines in you
   .emacs.
   
   BIG5-HKU under UNIX
        (set-default-file-coding-system *big5-hku*)

   BIG5-ETen under UNIX
        (set-default-file-coding-system *big5-eten*)

   BIG5-HKU under DOS
        (set-default-file-coding-system *big5-hku-dos*)

   BIG5-ETen under DOS
        (set-default-file-coding-system *big5-eten-dos*)

   The selection between HKU and ETen is up to you.  The default is
   *BIG5-HKU*.

  1.3.3 To edit files containing GB, BIG5 and ASCII

   First of all, be aware of this fact: Mule seems to be the only one
   which can handle GB and BIG5 simultaneously.  You cannot display GB
   and BIG5 in a cxterm, for example.

   If you dare to put GB and BIG5 in a file, we recommend to include
   the following line in your .emacs.

        (set-default-file-coding-system *junet*)

   With this coding-system, you can include not only GB and BIG5, but
   also Japanese, Hangul, European languages, etc. in a single file.
   The coding-system *junet* inserts a special code, called "escape
   sequence", in the boundary of two different character sets.  The
   8th bit is always kept to zero.

   You can also use the next one instead of *junet*.

        (set-default-file-coding-system *euc-china*)

   In this case, GB characters are saved with their 8th bit set to
   one.  All other character sets are saved with their 8th bit set to
   zero and are distinguished from one another by escape sequences.

   Yet another alternative is the following.

        (set-default-file-coding-system *ctext*)

   Note that only one of these three should be included in your
   .emacs.  They are mutually exclusive.

2. How to input Chinese

 2.1 cWnn

   The primary method for inputing Chinese is to communicate with
   cserver of cWnn via Egg system.  cserver is a network-wide
   pinyin-hanzi conversion server.  It gets pinyin and returns hanzi.

   To use cserver, cWnn (version 4.108 or later) should have been
   installed.  cWnn is bound to Wnn, and available from FTP sites of
   Mule.  You also need SiSheng fonts (see "1.2 Fonts").

   Note that the current version of Egg supports only GB characters.
   If you want to input BIG5, or if you cannot use cWnn for some
   reason, see "2.2 quail" below.

   To use cserver, you must specify the name of the machine on which
   cserver is running.  Add the following lines in your .emacs.

        (require 'chinese)
        (set-cserver-host-name "hostname")

   "hostname" must be replaced by the name of the machine on which
   cserver is really running.

   To input chinese, type C-\.  Make sure that mode-line has changed.
   Now you can enter pinyin.  You may type several words at once.
   Then hit the space bar to convert what you entered.  If the result
   is different from what you want, hit the space bar again.  Each
   time you hit the space bar, cserver returns another alternative.
   Here are some important key bindings in the conversion mode.

        space   get another alternative
        RET     confirm
        C-f     move to next word
        C-b     move to previous word
        C-i     make current word shorter
        C-o     make current word longer
        C-g     quit

   At the very first time of usig cserver, you may be asked if you
   want to make dictionaries.  Just type "yes" to all questions.

   To quit from Chinese input mode, type C-\ again.

   See doc/EGG for the detail.

 2.2 quail

   For those who want to input BIG5 or who cannot use cserver for some
   reason, Mule provides another input method called "quail".  quail
   is included in the standard distribution of Mule.  If you are
   familiar with cxterm, it would be very easy to use quail, as quail
   supports all of the input method provided by cxterm.

   To use an input method called XXX.tit in cxterm, include the
   following lines in your .emacs;

        (load "quail/XXX")
        (quail-use-package "XXX")

   where XXX is one of the following;

        py, tonepy, sw, punct, qj, ccdospy, ctcps3, etzy,
        py-b5, zozy, qj-b5, punct-b5

   [NOTE] If all of the following three conditions are fulfilled, the
   line (load "quail/XXX") is not necessary.

        1) Mule was built without defining a macro symbol EGG.
        2) Mule was built with chinese.el preloaded.
        3) XXX in "quail/XXX" is either py, qj or punct.

   Including (load "quail/XXX") slightly slows down the starting up of
   Mule, but it does nothing wrong other than that.  We recommend you
   to include the line first, then ask your system administrator
   afterwards.

   In the document of cxterm, each input method is explained as follows.
   (Quoted from cxterm/dict/tit/README.)

   name        coding  description
   ---------   ------  ----------------------------------------
   PY          GB      Standard PinYin input method
   TONEPY      GB      Standard PinYin input method with tone 1-5
   SW          GB      CCDOS style ShouWei input method (first & last part)
   
   Punct       GB      Punctuation marks input table.
   QJ          GB      Quan Jiao -- double-byte ASCII in GB coding
   CCDOSPY     GB      CCDOS style abbreviated PinYin input method
   CTCPS3      GB      Cantonese Phonetic CPS3 scheme
                       (by Fung-Fung Lee <[email-masked]>, see
                       june.cs.washington.edu:~ftp/pub/yeung/cantonese.shar)
   
   ETZY        BIG5    ETen ZhuYin (phonetic) input in ETen keyboard layout
               (HKU)   (by Susie Chu <[email-masked]>)
   PY-b5       BIG5    Standard PinYin input method with tones for HKU BIG5.
               (HKU)   (by Stephen G Simpson <[email-masked]>)
   ZOZY        BIG5    ETen ZhuYin (phonetic) input in second keyboard layout
               (HKU)   as in ZeroOne, DACHEN system, etc.
   QJ-b5       BIG5    Quan Jiao -- double-byte ASCII in  BIG5 coding
   Punct-b5    BIG5    Punctuation marks input table.
   
   -------------------

   In quail, you can toggle ASCII input mode and Chinese input mode by
   typing C-].  M-z in quail-mode shows a help.  It would be useful.

 2.3 PIG-mode

   PIG-mode is a very convenient system.  It converts several
   characters at once, accepts abbreviated pinyin input, etc.  It is
   available via anonymous FTP from the following sites.

        etlport.etl.go.jp [192.31.197.99]: /pub/mule/contrib
        sh.wide.ad.jp [133.4.11.11]: /JAPAN/mule/mule-1.0/contrib
        ftp.mei.co.jp [132.182.49.2]:/public/free/gnu/emacs/Mule/contrib
        ftp.funet.fi [128.214.6.100]:/pub/gnu/emacs/mule/mule-1.0/contrib

   A useful readme file is included.

   According to [email-masked], the definition of the following
   function is missing.

   (defun pig-parse-cz (string)
    (let ((indx 0) list)
     (while (string-match "\\([^0-5]+[0-5]\\)-*" string indx)
      (setq list (cons (substring string (match-beginning 1) (match-end 1))
                       list)) 
      (setq indx (match-end 0)))
     (nreverse list)))

 2.4 Other input methods

   If you want to use the input method of cxterm itself, follow the
   instruction below.

   1) Add the following two lines in your .emacs.

        (set-default-display-coding-system *euc-china*)
        (set-default-keyboard-coding-system *euc-china*)

   2) In a cxterm window, execute the following command.

        % mule -nw

   Now you can use the input method of cxterm itself.  Note that you
   cannot input BIG5 with this method.  Only GB can be entered.

3. How to get hardcopy of Chinese text

   A program called m2ps is bound to Mule.  m2ps works as a filter and
   converts the internal code of Mule to PostScript.  To print a file,
   say, chinese.txt, follow the instruction below.

   1) Type "C-x C-f chinese.txt RET" to read the file in.
      (RET means return key.)

   2) Type "C-u C-x C-w tmp RET *internal* RET" to save the content of
      the file with the internal representation of Mule.

   3) Return to a shell.  Then type the following command.

        % m2ps < tmp | lpr

   If your default printer does not accept PostScript, specify the
   name of a PostScript printer with -P option.  For example, if the
   name of your PostScript printer is "lw", it should be as follows.

        % m2ps < tmp | lpr -Plw

   A new version of m2ps, which directly converts from GB or BIG5 to
   PostScript will be included in the next release of Mule.

4. To read news in Chinese

   Using GNUS and gnusutil.el under Mule makes it possible to read the
   articles posted to alt.chinese.text and alt.chinese.text.big5.
   gnusutil.el is included in contrib/lisp.tar.gz in the FTP directory
   of Mule.  (It is not included in the standard distribution set.)

   gnusutil.el should be saved in a directory specified by the
   variable "load-path".  The directory where gnus.el resides would be
   nice.

   Then add the following two lines in your .emacs and restart Mule.

        (setq gnus-Group-mode-hook 'gnusutil-initialize)
        (autoload 'gnusutil-initialize "gnusutil")

   Now you can read alt.chinese.text and alt.chinese.text.big5 in
   hanzi.

   Once you install gnusutil.el, no special procedure is required to
   post an article to those newsgroups.  You can write your article in
   hanzi and can post it as if it were written in ASCII.  gnusutil
   automatically converts your hanzi article to appropriate format.
   Use a GB input method for alt.chinese.text, and a BIG5 input method
   for alt.chinese.text.big5.

   [NOTE] You should be carefull when you post an article saved in a
   file.  The article should have been saved with appropriate
   coding-system.  Use the following save/read commands.

   + To save an article which will be posted to alt.chinese.text
    C-u C-x C-w filename RET *hz* RET

   + To read an article which will be posted to alt.chinese.text
    C-u C-x C-f filename RET *hz* RET

   + To save an article which will be posted to alt.chinese.text.big5
    C-u C-x C-w filename RET *big5-eten* RET

   + To read an article which will be posted to alt.chinese.text.big5
    C-u C-x C-f filename RET *big5-eten* RET

5. To send mail written in Chinese

   [
     We do not know what is the standard format for sending Chinese
     mail.  Among the alternatives listed below, which one is most
     widely used?

     1. Use *euc-china* or *big5-??* believing that the 8th bits are not
        striped by sendmail.
     2. Use *junet* or *ctext*.
     3. Use MIME.
     4. Use HZ.
     5. Use other format.
   ]