333
|
1 ;;; chinese.el --- Support for Chinese
|
|
2
|
|
3 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
|
|
4 ;; Licensed to the Free Software Foundation.
|
|
5 ;; Copyright (C) 1997 MORIOKA Tomohiko
|
|
6
|
|
7 ;; Keywords: multilingual, Chinese
|
|
8
|
|
9 ;; This file is part of XEmacs.
|
|
10
|
|
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)
|
|
14 ;; any later version.
|
|
15
|
|
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.
|
|
20
|
|
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
|
|
24 ;; 02111-1307, USA.
|
|
25
|
|
26 ;;; Commentary:
|
|
27
|
|
28 ;; For Chinese, three character sets GB2312, BIG5, and CNS11643 are
|
|
29 ;; supported.
|
|
30
|
|
31 ;;; Code:
|
|
32
|
|
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"))
|
|
41
|
|
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")
|
|
46
|
|
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
|
|
51 ;; is unknown.
|
|
52
|
|
53 (flet
|
|
54 ((make-chinese-cns11643-charset
|
|
55 (name plane final)
|
|
56 (make-charset
|
|
57 name (concat "CNS 11643 Plane " plane " (Chinese traditional)")
|
|
58 `(registry
|
|
59 ,(concat "CNS11643[.-]\\(.*[.-]\\)?" plane "$")
|
|
60 dimension 2
|
|
61 chars 94
|
|
62 final ,final
|
|
63 graphic 0))
|
|
64 (modify-syntax-entry name "w")
|
|
65 (modify-category-entry name ?t)
|
|
66 ))
|
|
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)
|
|
72 )
|
|
73
|
|
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.
|
|
77 (make-charset
|
|
78 'chinese-isoir165
|
|
79 "ISO-IR-165 (CCITT Extended GB; Chinese simplified)"
|
|
80 `(registry "isoir165"
|
|
81 dimension 2
|
|
82 chars 94
|
|
83 final ?E
|
|
84 graphic 0))
|
|
85
|
|
86 ;; PinYin-ZhuYin
|
|
87 (make-charset 'sisheng "PinYin-ZhuYin"
|
|
88 '(registry "sisheng_cwnn\\|OMRON_UDC_ZH"
|
|
89 dimension 1
|
|
90 chars 94
|
|
91 final ?0
|
|
92 graphic 0
|
|
93 ))
|
|
94
|
|
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)
|
|
98 ;; (load "pinyin")
|
|
99 ;; (setq its:*standard-modes*
|
|
100 ;; (cons (its:get-mode-map "PinYin") its:*standard-modes*)))
|
|
101
|
|
102 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
103 ;;; Chinese (general)
|
|
104 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
105
|
|
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)"
|
|
109 ;; '(ascii
|
|
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
|
|
115 ;; init-bol))
|
|
116
|
|
117 ;; (define-coding-system-alias 'iso-2022-cn 'chinese-iso-7bit)
|
|
118 ;; (define-coding-system-alias 'iso-2022-cn-ext 'chinese-iso-7bit)
|
|
119
|
|
120 ;; (define-prefix-command 'describe-chinese-environment-map)
|
|
121 ;; (define-key-after describe-language-environment-map [Chinese]
|
|
122 ;; '("Chinese" . describe-chinese-environment-map)
|
|
123 ;; t)
|
|
124
|
|
125 ;; (define-prefix-command 'setup-chinese-environment-map)
|
|
126 ;; (define-key-after setup-language-environment-map [Chinese]
|
|
127 ;; '("Chinese" . setup-chinese-environment-map)
|
|
128 ;; t)
|
|
129
|
|
130 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
131 ;;; Chinese GB2312 (simplified)
|
|
132 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
133
|
|
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))
|
|
139
|
|
140 (make-coding-system
|
|
141 'cn-gb-2312 'iso2022
|
|
142 "Coding-system of Chinese EUC (Extended Unix Code)."
|
|
143 '(charset-g0 ascii
|
|
144 charset-g1 chinese-gb2312
|
|
145 charset-g2 sisheng
|
|
146 charset-g3 t
|
|
147 mnemonic "Zh-GB/EUC"
|
|
148 ))
|
|
149
|
|
150 ;; (define-coding-system-alias 'cn-gb-2312 'chinese-iso-8bit)
|
|
151 ;; (define-coding-system-alias 'euc-china 'chinese-iso-8bit)
|
|
152
|
|
153 (copy-coding-system 'cn-gb-2312 'gb2312)
|
|
154 (copy-coding-system 'cn-gb-2312 'chinese-euc)
|
|
155
|
|
156 ;; (make-coding-system
|
|
157 ;; 'chinese-hz 0 ?z
|
|
158 ;; "Hz/ZW 7-bit encoding for Chinese GB2312 (MIME:HZ-GB-2312)"
|
|
159 ;; nil)
|
|
160 ;; (put 'chinese-hz 'post-read-conversion 'post-read-decode-hz)
|
|
161 ;; (put 'chinese-hz 'pre-write-conversion 'pre-write-encode-hz)
|
|
162
|
|
163 (make-coding-system
|
|
164 'hz-gb-2312 'no-conversion
|
|
165 "Coding-system of Hz/ZW used for Chinese."
|
|
166 '(mnemonic "Zh-GB/Hz"
|
|
167 eol-type lf
|
|
168 post-read-conversion post-read-decode-hz
|
|
169 pre-write-conversion pre-write-encode-hz))
|
|
170
|
|
171 ;; (define-coding-system-alias 'hz-gb-2312 'chinese-hz)
|
|
172 ;; (define-coding-system-alias 'hz 'chinese-hz)
|
|
173
|
|
174 (copy-coding-system 'hz-gb-2312 'hz)
|
|
175 (copy-coding-system 'hz-gb-2312 'chinese-hz)
|
|
176
|
|
177 (defun post-read-decode-hz (len)
|
|
178 (let ((pos (point)))
|
|
179 (decode-hz-region pos (+ pos len))))
|
|
180
|
|
181 (defun pre-write-encode-hz (from to)
|
|
182 (let ((buf (current-buffer))
|
|
183 (work (get-buffer-create " *pre-write-encoding-work*")))
|
|
184 (set-buffer work)
|
|
185 (erase-buffer)
|
|
186 (if (stringp from)
|
|
187 (insert from)
|
|
188 (insert-buffer-substring buf from to))
|
|
189 (encode-hz-region 1 (point-max))
|
|
190 nil))
|
|
191
|
|
192 (set-language-info-alist
|
|
193 "Chinese-GB" '((setup-function . (setup-chinese-gb-environment
|
|
194 . setup-chinese-environment-map))
|
|
195 (charset . (chinese-gb2312 sisheng))
|
|
196 (coding-system
|
|
197 . (cn-gb-2312 iso-2022-7bit hz-gb-2312))
|
|
198 (sample-text . "Chinese ($AVPND(B,$AFUM(;0(B,$A::So(B) $ADc:C(B")
|
|
199 (documentation . ("Support for Chinese GB2312 character set."
|
|
200 . describe-chinese-environment-map))
|
|
201 ))
|
|
202
|
357
|
203 (defun setup-chinese-gb-environment ()
|
|
204 "Setup multilingual environment (MULE) for Chinese GB2312 users."
|
|
205 (interactive)
|
|
206 (setup-english-environment)
|
|
207 (set-coding-category-system 'iso-8-2 'cn-gb-2312)
|
|
208 (set-coding-category-system 'big5 'big5)
|
|
209 (set-coding-category-system 'iso-7 'iso-2022-7bit)
|
|
210 (set-coding-priority-list
|
|
211 '(iso-8-2
|
|
212 big5
|
|
213 iso-7))
|
|
214 (set-default-coding-systems 'cn-gb-2312))
|
|
215
|
333
|
216 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
217 ;; Chinese BIG5 (traditional)
|
|
218 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
219
|
|
220 ;; (make-coding-system
|
|
221 ;; 'chinese-big5 3 ?B "BIG5 8-bit encoding for Chinese (MIME:CN-BIG5)")
|
|
222
|
|
223 (make-coding-system
|
|
224 'big5 'big5
|
|
225 "Coding-system of BIG5."
|
|
226 '(mnemonic "Zh/Big5"))
|
|
227
|
|
228 ;; (define-coding-system-alias 'big5 'chinese-big5)
|
|
229 ;; (define-coding-system-alias 'cn-big5 'chinese-big5)
|
|
230
|
|
231 (copy-coding-system 'big5 'cn-big5)
|
|
232 (copy-coding-system 'big5 'chinese-big5)
|
|
233
|
|
234 ;; Big5 font requires special encoding.
|
|
235 (define-ccl-program ccl-encode-big5-font
|
|
236 `(0
|
|
237 ;; In: R0:chinese-big5-1 or chinese-big5-2
|
|
238 ;; R1:position code 1
|
|
239 ;; R2:position code 2
|
|
240 ;; Out: R1:font code point 1
|
|
241 ;; R2:font code point 2
|
|
242 ((r2 = ((((r1 - ?\x21) * 94) + r2) - ?\x21))
|
|
243 (if (r0 == ,(charset-id 'chinese-big5-2)) (r2 += 6280))
|
|
244 (r1 = ((r2 / 157) + ?\xA1))
|
|
245 (r2 %= 157)
|
|
246 (if (r2 < ?\x3F) (r2 += ?\x40) (r2 += ?\x62))))
|
|
247 "CCL program to encode a Big5 code to code point of Big5 font.")
|
|
248
|
|
249 ;; (setq font-ccl-encoder-alist
|
|
250 ;; (cons (cons "big5" ccl-encode-big5-font) font-ccl-encoder-alist))
|
|
251
|
|
252 (set-charset-ccl-program 'chinese-big5-1 ccl-encode-big5-font)
|
|
253 (set-charset-ccl-program 'chinese-big5-2 ccl-encode-big5-font)
|
|
254
|
|
255 (set-language-info-alist
|
|
256 "Chinese-BIG5" '((setup-function . (setup-chinese-big5-environment
|
|
257 . setup-chinese-environment-map))
|
|
258 (charset . (chinese-big5-1 chinese-big5-2))
|
|
259 (coding-system . (big5 iso-2022-7bit))
|
|
260 (sample-text . "Cantonese ($(0GnM$(B,$(0N]0*Hd(B) $(0*/=((B, $(0+$)p(B")
|
|
261 (documentation . ("Support for Chinese Big5 character set."
|
|
262 . describe-chinese-environment-map))
|
|
263 ))
|
|
264
|
357
|
265 (defun setup-chinese-big5-environment ()
|
|
266 "Setup multilingual environment (MULE) for Chinese Big5 users."
|
|
267 (interactive)
|
|
268 (setup-english-environment)
|
|
269 (set-coding-category-system 'big5 'big5)
|
|
270 (set-coding-category-system 'iso-8-2 'cn-gb-2312)
|
|
271 (set-coding-category-system 'iso-7 'iso-2022-7bit)
|
|
272 (set-coding-priority-list
|
|
273 '(big5
|
|
274 iso-8-2
|
|
275 iso-7))
|
|
276 (set-default-coding-systems 'big5))
|
|
277
|
333
|
278 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
279 ;; Chinese CNS11643 (traditional)
|
|
280 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
281
|
|
282 ;; (set-language-info-alist
|
|
283 ;; "Chinese-CNS" '((setup-function . (setup-chinese-cns-environment
|
|
284 ;; . setup-chinese-environment-map))
|
|
285 ;; (charset . (chinese-cns11643-1 chinese-cns11643-2
|
|
286 ;; chinese-cns11643-3 chinese-cns11643-4
|
|
287 ;; chinese-cns11643-5 chinese-cns11643-6
|
|
288 ;; chinese-cns11643-7))
|
|
289 ;; (coding-system . (chinese-iso-7bit))
|
|
290 ;; (documentation . ("Support for Chinese CNS character sets."
|
|
291 ;; . describe-chinese-environment-map))
|
|
292 ;; ))
|
|
293
|
|
294 ;;; chinese.el ends here
|