1 ;;; chinese.el --- Support for Chinese
3 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
4 ;; Licensed to the Free Software Foundation.
5 ;; Copyright (C) 1997 MORIOKA Tomohiko
7 ;; Keywords: multilingual, Chinese
9 ;; This file is part of XEmacs.
11 ;; XEmacs is free software; you can redistribute it and/or modify it
12 ;; under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; XEmacs is distributed in the hope that it will be useful, but
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ;; General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with XEmacs; see the file COPYING. If not, write to the Free
23 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
28 ;; For Chinese, three character sets GB2312, BIG5, and CNS11643 are
33 ;; Syntax of Chinese characters.
34 (modify-syntax-entry 'chinese-gb2312 "w")
35 (loop for row in '(33 34 41)
36 do (modify-syntax-entry `[chinese-gb2312 ,row] "."))
37 ;;(loop for row from 35 to 40
38 ;; do (modify-syntax-entry `[chinese-gb2312 ,row] "w"))
39 ;;(loop for row from 42 to 126
40 ;; do (modify-syntax-entry `[chinese-gb2312 ,row] "w"))
42 (modify-syntax-entry 'chinese-cns11643-1 "w")
43 (modify-syntax-entry 'chinese-cns11643-2 "w")
44 (modify-syntax-entry 'chinese-big5-1 "w")
45 (modify-syntax-entry 'chinese-big5-2 "w")
47 ;; CNS11643 Plane3 thru Plane7
48 ;; These represent more and more obscure Chinese characters.
49 ;; By the time you get to Plane 7, we're talking about characters
50 ;; that appear once in some ancient manuscript and whose meaning
54 ((make-chinese-cns11643-charset
57 name (concat "CNS 11643 Plane " plane " (Chinese traditional)")
59 ,(concat "CNS11643[.-]\\(.*[.-]\\)?" plane "$")
64 (modify-syntax-entry name "w")
65 (modify-category-entry name ?t)
67 (make-chinese-cns11643-charset 'chinese-cns11643-3 "3" ?I)
68 (make-chinese-cns11643-charset 'chinese-cns11643-4 "4" ?J)
69 (make-chinese-cns11643-charset 'chinese-cns11643-5 "5" ?K)
70 (make-chinese-cns11643-charset 'chinese-cns11643-6 "6" ?L)
71 (make-chinese-cns11643-charset 'chinese-cns11643-7 "7" ?M)
74 ;; ISO-IR-165 (CCITT Extended GB)
75 ;; It is based on CCITT Recommendation T.101, includes GB 2312-80 +
76 ;; GB 8565-88 table A4 + 293 characters.
79 "ISO-IR-165 (CCITT Extended GB; Chinese simplified)"
87 (make-charset 'sisheng "PinYin-ZhuYin"
88 '(registry "sisheng_cwnn\\|OMRON_UDC_ZH"
95 ;; If you prefer QUAIL to EGG, please modify below as you wish.
96 ;;(when (and (featurep 'egg) (featurep 'wnn))
97 ;; (setq wnn-server-type 'cserver)
99 ;; (setq its:*standard-modes*
100 ;; (cons (its:get-mode-map "PinYin") its:*standard-modes*)))
102 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
103 ;;; Chinese (general)
104 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
106 ;; (make-coding-system
107 ;; 'chinese-iso-7bit 2 ?C
108 ;; "ISO 2022 based 7bit encoding for Chinese GB and CNS (MIME:ISO-2022-CN)"
110 ;; (nil chinese-gb2312 chinese-cns11643-1)
111 ;; (nil chinese-cns11643-2)
112 ;; (nil chinese-cns11643-3 chinese-cns11643-4 chinese-cns11643-5
113 ;; chinese-cns11643-6 chinese-cns11643-7)
114 ;; nil ascii-eol ascii-cntl seven locking-shift single-shift nil nil nil
117 ;; (define-coding-system-alias 'iso-2022-cn 'chinese-iso-7bit)
118 ;; (define-coding-system-alias 'iso-2022-cn-ext 'chinese-iso-7bit)
120 ;; (define-prefix-command 'describe-chinese-environment-map)
121 ;; (define-key-after describe-language-environment-map [Chinese]
122 ;; '("Chinese" . describe-chinese-environment-map)
125 ;; (define-prefix-command 'setup-chinese-environment-map)
126 ;; (define-key-after setup-language-environment-map [Chinese]
127 ;; '("Chinese" . setup-chinese-environment-map)
130 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
131 ;;; Chinese GB2312 (simplified)
132 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
134 ;; (make-coding-system
135 ;; 'chinese-iso-8bit 2 ?c
136 ;; "ISO 2022 based EUC encoding for Chinese GB2312 (MIME:CN-GB-2312)"
137 ;; '((ascii t) chinese-gb2312 chinese-sisheng nil
138 ;; nil ascii-eol ascii-cntl nil nil single-shift nil))
142 "Coding-system of Chinese EUC (Extended Unix Code)."
144 charset-g1 chinese-gb2312
150 ;; (define-coding-system-alias 'cn-gb-2312 'chinese-iso-8bit)
151 ;; (define-coding-system-alias 'euc-china 'chinese-iso-8bit)
153 (copy-coding-system 'cn-gb-2312 'gb2312)
154 (copy-coding-system 'cn-gb-2312 'chinese-euc)
156 ;; (make-coding-system
158 ;; "Hz/ZW 7-bit encoding for Chinese GB2312 (MIME:HZ-GB-2312)"
160 ;; (put 'chinese-hz 'post-read-conversion 'post-read-decode-hz)
161 ;; (put 'chinese-hz 'pre-write-conversion 'pre-write-encode-hz)
164 'hz-gb-2312 'no-conversion
165 "Coding-system of Hz/ZW used for Chinese."
166 '(mnemonic "Zh-GB/Hz"
168 post-read-conversion post-read-decode-hz
169 pre-write-conversion pre-write-encode-hz))
171 ;; (define-coding-system-alias 'hz-gb-2312 'chinese-hz)
172 ;; (define-coding-system-alias 'hz 'chinese-hz)
174 (copy-coding-system 'hz-gb-2312 'hz)
175 (copy-coding-system 'hz-gb-2312 'chinese-hz)
177 (defun post-read-decode-hz (len)
179 (decode-hz-region pos (+ pos len))))
181 (defun pre-write-encode-hz (from to)
182 (let ((buf (current-buffer))
183 (work (get-buffer-create " *pre-write-encoding-work*")))
188 (insert-buffer-substring buf from to))
189 (encode-hz-region 1 (point-max))
192 (set-language-info-alist
193 "Chinese-GB" '((setup-function . (setup-chinese-gb-environment
194 . setup-chinese-environment-map))
195 (charset . (chinese-gb2312 sisheng))
197 . (cn-gb-2312 iso-2022-7bit hz-gb-2312))
198 (sample-text . "Chinese (
\e$AVPND
\e(B,
\e$AFUM(;0
\e(B,
\e$A::So
\e(B)
\e$ADc:C
\e(B")
199 (documentation . ("Support for Chinese GB2312 character set."
200 . describe-chinese-environment-map))
203 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
204 ;; Chinese BIG5 (traditional)
205 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
207 ;; (make-coding-system
208 ;; 'chinese-big5 3 ?B "BIG5 8-bit encoding for Chinese (MIME:CN-BIG5)")
212 "Coding-system of BIG5."
213 '(mnemonic "Zh/Big5"))
215 ;; (define-coding-system-alias 'big5 'chinese-big5)
216 ;; (define-coding-system-alias 'cn-big5 'chinese-big5)
218 (copy-coding-system 'big5 'cn-big5)
219 (copy-coding-system 'big5 'chinese-big5)
221 ;; Big5 font requires special encoding.
222 (define-ccl-program ccl-encode-big5-font
224 ;; In: R0:chinese-big5-1 or chinese-big5-2
225 ;; R1:position code 1
226 ;; R2:position code 2
227 ;; Out: R1:font code point 1
228 ;; R2:font code point 2
229 ((r2 = ((((r1 - ?\x21) * 94) + r2) - ?\x21))
230 (if (r0 == ,(charset-id 'chinese-big5-2)) (r2 += 6280))
231 (r1 = ((r2 / 157) + ?\xA1))
233 (if (r2 < ?\x3F) (r2 += ?\x40) (r2 += ?\x62))))
234 "CCL program to encode a Big5 code to code point of Big5 font.")
236 ;; (setq font-ccl-encoder-alist
237 ;; (cons (cons "big5" ccl-encode-big5-font) font-ccl-encoder-alist))
239 (set-charset-ccl-program 'chinese-big5-1 ccl-encode-big5-font)
240 (set-charset-ccl-program 'chinese-big5-2 ccl-encode-big5-font)
242 (set-language-info-alist
243 "Chinese-BIG5" '((setup-function . (setup-chinese-big5-environment
244 . setup-chinese-environment-map))
245 (charset . (chinese-big5-1 chinese-big5-2))
246 (coding-system . (big5 iso-2022-7bit))
247 (sample-text . "Cantonese (
\e$(0GnM$
\e(B,
\e$(0N]0*Hd
\e(B)
\e$(0*/=(
\e(B,
\e$(0+$)p
\e(B")
248 (documentation . ("Support for Chinese Big5 character set."
249 . describe-chinese-environment-map))
252 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
253 ;; Chinese CNS11643 (traditional)
254 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
256 ;; (set-language-info-alist
257 ;; "Chinese-CNS" '((setup-function . (setup-chinese-cns-environment
258 ;; . setup-chinese-environment-map))
259 ;; (charset . (chinese-cns11643-1 chinese-cns11643-2
260 ;; chinese-cns11643-3 chinese-cns11643-4
261 ;; chinese-cns11643-5 chinese-cns11643-6
262 ;; chinese-cns11643-7))
263 ;; (coding-system . (chinese-iso-7bit))
264 ;; (documentation . ("Support for Chinese CNS character sets."
265 ;; . describe-chinese-environment-map))
268 ;;; chinese.el ends here