Mercurial > hg > xemacs-beta
comparison lisp/mule/chinese.el @ 428:3ecd8885ac67 r21-2-22
Import from CVS: tag r21-2-22
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:28:15 +0200 |
parents | |
children | 576fb035e263 |
comparison
equal
deleted
inserted
replaced
427:0a0253eac470 | 428:3ecd8885ac67 |
---|---|
1 ;;; chinese.el --- Support for Chinese -*- coding: iso-2022-7bit; -*- | |
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 ;; 'iso-2022-cn 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 | |
113 ;; nil ascii-eol ascii-cntl seven locking-shift single-shift nil nil nil | |
114 ;; init-bol) | |
115 ;; '((safe-charsets ascii chinese-gb2312 chinese-cns11643-1 chinese-cns11643-2) | |
116 ;; (mime-charset . iso-2022-cn))) | |
117 | |
118 ;; (define-coding-system-alias 'chinese-iso-7bit 'iso-2022-cn) | |
119 | |
120 ;; (make-coding-system | |
121 ;; 'iso-2022-cn-ext 2 ?C | |
122 ;; "ISO 2022 based 7bit encoding for Chinese GB and CNS (MIME:ISO-2022-CN-EXT)" | |
123 ;; '(ascii | |
124 ;; (nil chinese-gb2312 chinese-cns11643-1) | |
125 ;; (nil chinese-cns11643-2) | |
126 ;; (nil chinese-cns11643-3 chinese-cns11643-4 chinese-cns11643-5 | |
127 ;; chinese-cns11643-6 chinese-cns11643-7) | |
128 ;; nil ascii-eol ascii-cntl seven locking-shift single-shift nil nil nil | |
129 ;; init-bol) | |
130 ;; '((safe-charsets ascii chinese-gb2312 chinese-cns11643-1 chinese-cns11643-2 | |
131 ;; chinese-cns11643-3 chinese-cns11643-4 chinese-cns11643-5 | |
132 ;; chinese-cns11643-6 chinese-cns11643-7) | |
133 ;; (mime-charset . iso-2022-cn-ext))) | |
134 | |
135 | |
136 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
137 ;;; Chinese GB2312 (simplified) | |
138 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
139 | |
140 ;; (make-coding-system | |
141 ;; 'chinese-iso-8bit 2 ?c | |
142 ;; "ISO 2022 based EUC encoding for Chinese GB2312 (MIME:CN-GB-2312)" | |
143 ;; '(ascii chinese-gb2312 nil nil | |
144 ;; nil ascii-eol ascii-cntl nil nil nil nil) | |
145 ;; '((safe-charsets ascii chinese-gb2312) | |
146 ;; (mime-charset . cn-gb-2312))) | |
147 | |
148 (make-coding-system | |
149 'cn-gb-2312 'iso2022 | |
150 "Coding-system of Chinese EUC (Extended Unix Code)." | |
151 '(charset-g0 ascii | |
152 charset-g1 chinese-gb2312 | |
153 charset-g2 sisheng | |
154 charset-g3 t | |
155 mnemonic "Zh-GB/EUC" | |
156 )) | |
157 | |
158 ;; (define-coding-system-alias 'cn-gb-2312 'chinese-iso-8bit) | |
159 ;; (define-coding-system-alias 'euc-china 'chinese-iso-8bit) | |
160 ;; (define-coding-system-alias 'euc-cn 'chinese-iso-8bit) | |
161 | |
162 (define-coding-system-alias 'gb2312 'cn-gb-2312) | |
163 (define-coding-system-alias 'chinese-euc 'cn-gb-2312) | |
164 | |
165 ;; (make-coding-system | |
166 ;; 'chinese-hz 0 ?z | |
167 ;; "Hz/ZW 7-bit encoding for Chinese GB2312 (MIME:HZ-GB-2312)" | |
168 ;; nil | |
169 ;; '((safe-charsets ascii chinese-gb2312) | |
170 ;; (mime-charset . hz-gb-2312) | |
171 ;; (post-read-conversion . post-read-decode-hz) | |
172 ;; (pre-write-conversion . pre-write-encode-hz))) | |
173 ;; (put 'chinese-hz 'post-read-conversion 'post-read-decode-hz) | |
174 ;; (put 'chinese-hz 'pre-write-conversion 'pre-write-encode-hz) | |
175 | |
176 (make-coding-system | |
177 'hz-gb-2312 'no-conversion | |
178 "Coding-system of Hz/ZW used for Chinese." | |
179 '(mnemonic "Zh-GB/Hz" | |
180 eol-type lf | |
181 post-read-conversion post-read-decode-hz | |
182 pre-write-conversion pre-write-encode-hz)) | |
183 | |
184 ;; (define-coding-system-alias 'hz-gb-2312 'chinese-hz) | |
185 ;; (define-coding-system-alias 'hz 'chinese-hz) | |
186 | |
187 (define-coding-system-alias 'hz 'hz-gb-2312) | |
188 | |
189 (defun post-read-decode-hz (len) | |
190 (let ((pos (point)) | |
191 (buffer-modified-p (buffer-modified-p)) | |
192 last-coding-system-used) | |
193 (prog1 | |
194 (decode-hz-region pos (+ pos len)) | |
195 (set-buffer-modified-p buffer-modified-p)))) | |
196 | |
197 (defun pre-write-encode-hz (from to) | |
198 (let ((buf (current-buffer))) | |
199 (set-buffer (generate-new-buffer " *temp*")) | |
200 (if (stringp from) | |
201 (insert from) | |
202 (insert-buffer-substring buf from to)) | |
203 (let (last-coding-system-used) | |
204 (encode-hz-region 1 (point-max))) | |
205 nil)) | |
206 | |
207 (set-language-info-alist | |
208 "Chinese-GB" '((setup-function . setup-chinese-gb-environment-internal) | |
209 (charset chinese-gb2312 sisheng) | |
210 (coding-system cn-gb-2312 iso-2022-7bit hz-gb-2312) | |
211 (coding-priority cn-gb-2312 big5 iso-2022-7bit) | |
212 (input-method . "chinese-py-punct") | |
213 (features china-util) | |
214 (sample-text . "Chinese ($AVPND(B,$AFUM(;0(B,$A::So(B) $ADc:C(B") | |
215 (documentation . "Support for Chinese GB2312 character set.")) | |
216 '("Chinese")) | |
217 | |
218 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
219 ;; Chinese BIG5 (traditional) | |
220 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
221 | |
222 ;; (make-coding-system | |
223 ;; 'chinese-big5 3 ?B "BIG5 8-bit encoding for Chinese (MIME:CN-BIG5)" | |
224 ;; nil | |
225 ;; '((safe-charsets ascii chinese-big5-1 chinese-big5-2) | |
226 ;; (mime-charset . cn-big5) | |
227 ;; (charset-origin-alist (chinese-big5-1 "BIG5" encode-big5-char) | |
228 ;; (chinese-big5-2 "BIG5" encode-big5-char)))) | |
229 | |
230 (make-coding-system | |
231 'big5 'big5 | |
232 "Coding-system of BIG5." | |
233 '(mnemonic "Zh/Big5")) | |
234 | |
235 ;; (define-coding-system-alias 'big5 'chinese-big5) | |
236 ;; (define-coding-system-alias 'cn-big5 'chinese-big5) | |
237 | |
238 (define-coding-system-alias 'cn-big5 'big5) | |
239 | |
240 ;; Big5 font requires special encoding. | |
241 (define-ccl-program ccl-encode-big5-font | |
242 `(0 | |
243 ;; In: R0:chinese-big5-1 or chinese-big5-2 | |
244 ;; R1:position code 1 | |
245 ;; R2:position code 2 | |
246 ;; Out: R1:font code point 1 | |
247 ;; R2:font code point 2 | |
248 ((r2 = ((((r1 - ?\x21) * 94) + r2) - ?\x21)) | |
249 (if (r0 == ,(charset-id 'chinese-big5-2)) (r2 += 6280)) | |
250 (r1 = ((r2 / 157) + ?\xA1)) | |
251 (r2 %= 157) | |
252 (if (r2 < ?\x3F) (r2 += ?\x40) (r2 += ?\x62)))) | |
253 "CCL program to encode a Big5 code to code point of Big5 font.") | |
254 | |
255 ;; (setq font-ccl-encoder-alist | |
256 ;; (cons (cons "big5" ccl-encode-big5-font) font-ccl-encoder-alist)) | |
257 | |
258 (set-charset-ccl-program 'chinese-big5-1 ccl-encode-big5-font) | |
259 (set-charset-ccl-program 'chinese-big5-2 ccl-encode-big5-font) | |
260 | |
261 (set-language-info-alist | |
262 "Chinese-BIG5" '((charset chinese-big5-1 chinese-big5-2) | |
263 (coding-system big5 iso-2022-7bit) | |
264 (coding-priority big5 cn-gb-2312 iso-2022-7bit) | |
265 (input-method . "chinese-py-punct-b5") | |
266 (features china-util) | |
267 (sample-text . "Cantonese ($(0GnM$(B,$(0N]0*Hd(B) $(0*/=((B, $(0+$)p(B") | |
268 (documentation . "Support for Chinese Big5 character set.")) | |
269 '("Chinese")) | |
270 | |
271 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
272 ;; Chinese CNS11643 (traditional) | |
273 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
274 | |
275 ;; (set-language-info-alist | |
276 ;; "Chinese-CNS" '((charset chinese-cns11643-1 chinese-cns11643-2 | |
277 ;; chinese-cns11643-3 chinese-cns11643-4 | |
278 ;; chinese-cns11643-5 chinese-cns11643-6 | |
279 ;; chinese-cns11643-7) | |
280 ;; (coding-system iso-2022-cn) | |
281 ;; (coding-priority iso-2022-cn chinese-big5 chinese-iso-8bit) | |
282 ;; (features china-util) | |
283 ;; (input-method . "chinese-cns-quick") | |
284 ;; (documentation . "Support for Chinese CNS character sets.")) | |
285 ;; '("Chinese")) | |
286 | |
287 ;;; chinese.el ends here |