Sailor Family

Home

Sailor At Work

Firefox
Java
Rubik Cube
Toto/4D

Html
Perl
Chinese

Web Tools
Emacs/Cygwin









Drop me a note
Email Web Sailor
Welcome to Web Sailor's Home
Home > Emacs/Cygwin > Viewing and Editing Chinese/Unicode

Viewing Chinese Characters on Emacs

You need to have the following statements in your .emacs file to view Chinese Characters. This is assuming your PC is equiped with Chinese characters from Microsoft. You may need to activate the command "Mule" -> "Set Language Environment" -> "Chinese" -> "Chinese-GB" from the Emacs pull down menu before viewing Chinese text files.

(if (not (member '("-*-courier new-normal-r-*-*-13-*-*-*-c-*-fontset-chinese"
   . "fontset-chinese") fontset-alias-alist))
    (progn
      (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))
      )
  )


Editing Chinese Characters on Emacs

In order to edit Chinese text files, you need to have the Library of Emacs Input Method (leim) from ftp://ftp.gnu.org/gnu/windows/emacs/. The leim package should be installed at the directory c:/programs/emacs/leim for example.

If you have the package installed, press "ctrl-\" will allow you to toggle between default and Chinese input methods.



echo Formating Chinese Characters on Emacs

echo Formating Chinese characters through Emacs requires the Chinese bitmap fonts to be installed on your PC. The Chinese bitmap fonts can be downloaded from The Organization of Multilingualization.

After the fonts are installed, you will need to have the following lisp codes on your .emacs.

;; BDF fonts for printing
(load-library "ps-bdf")

(setq ps-multibyte-buffer
      'bdf-font-except-latin)

(setq bdf-directory-list
      '(
        "c:/programs/intlfonts-1.2/Chinese"
        "c:/programs/intlfonts-1.2/Chinese.Big"
        "c:/programs/intlfonts-1.2/Chinese.X"
        "c:/programs/intlfonts-1.2/Chinese.X"
        "c:/programs/intlfonts-1.2/Japanese"
        "c:/programs/intlfonts-1.2/Japanese.Big"
        "c:/programs/intlfonts-1.2/Japanese.X"
        "c:/programs/intlfonts-1.2/Korean.X"))


Editing Unicode

Gnu Emacs allows you to edit UTF-8 text files. However, it does not allow you to edit UTF-16 text files. In order to edit UTF-16 files, you need the Mule package. Mule stands for Multilingual Enhancement to Gnu Emacs.

I have placed the Mule package in the directory c:/programs/emacs/site-lisp/. I have done the following to get Mule enabled.

(add-to-list 'load-path
             (downcase
              (concat
               (expand-file-name (getenv "emacs_dir"))
               "/site-lisp/Mule-UCS-0.84/lisp")) t)

;; load the unicode
(load-library "un-define")

Unfortunately, Mule does not support all the characters in the Unicode map. For example, if you try to view this Unicode text file using Emacs with Mule, you will see some question marks for characters like 0x4e06.

I have done some hacks to support those characters because the solution given by Otfried Cheong is not working on Gnu Emacs 21.1 due to limited code points. Since this is a non standard thing, I would not like to share it at the moment. I am hoping Emacs to resolve this problem.

For Emacs 21.2.1, the Mule package is very slow during Emacs startup, you will need a patch from Debian. The patching utility is available in cygwin under the Utils package. The statement below is the syntax of the command to apply the patch. You will need to recompile the Mule package after apply the patch.

% patch -p0 < mule-ucs_0.84-11.diff.gz


Langkawi Sunset