17052
|
1 ;;; chinese.el --- Support for Chinese
|
|
2
|
|
3 ;; Copyright (C) 1995 Free Software Foundation, Inc.
|
|
4 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
|
|
5
|
|
6 ;; Keywords: multilingual, Chinese
|
|
7
|
|
8 ;; This file is part of GNU Emacs.
|
|
9
|
|
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
|
|
11 ;; it under the terms of the GNU General Public License as published by
|
|
12 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
13 ;; any later version.
|
|
14
|
|
15 ;; GNU Emacs is distributed in the hope that it will be useful,
|
|
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
18 ;; GNU General Public License for more details.
|
|
19
|
|
20 ;; You should have received a copy of the GNU General Public License
|
|
21 ;; along with GNU Emacs; see the file COPYING. If not, write to
|
|
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
23
|
|
24 ;;; Commentary:
|
|
25
|
|
26 ;; For Chinese, three character sets GB2312, BIG5, and CNS11643 are
|
|
27 ;; supported.
|
|
28
|
|
29 ;;; Code:
|
|
30
|
|
31 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
32 ;;; Chinese (general)
|
|
33 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
34
|
|
35 (make-coding-system
|
|
36 'coding-system-iso-2022-cn 2 ?C
|
|
37 "Coding system ISO-2022-CN for Chinese (GB and CNS character sets)."
|
|
38 '(ascii
|
|
39 (nil chinese-gb2312 chinese-cns11643-1)
|
|
40 (nil chinese-cns11643-2)
|
|
41 (nil chinese-cns11643-3 chinese-cns11643-4 chinese-cns11643-5
|
|
42 chinese-cns11643-6 chinese-cns11643-7)
|
|
43 nil ascii-eol ascii-cntl seven locking-shift single-shift))
|
|
44
|
|
45 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
46 ;;; Chinese GB2312 (simplified)
|
|
47 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
48
|
|
49 (make-coding-system
|
|
50 'coding-system-euc-china 2 ?C
|
|
51 "Coding-system of Chinese EUC (so called GB Encoding)."
|
|
52 '((ascii t) chinese-gb2312 chinese-sisheng nil
|
|
53 nil ascii-eol ascii-cntl nil nil single-shift nil))
|
|
54
|
|
55 (make-coding-system
|
|
56 'coding-system-hz 0 ?z
|
|
57 "Codins-system of Hz/ZW used for Chinese (GB)."
|
|
58 nil)
|
|
59 (put 'coding-system-hz 'post-read-conversion 'post-read-decode-hz)
|
|
60 (put 'coding-system-hz 'pre-write-conversion 'pre-write-encode-hz)
|
|
61
|
|
62 (defun post-read-decode-hz (len)
|
|
63 (let ((pos (point)))
|
|
64 (decode-hz-region pos (+ pos len))))
|
|
65
|
|
66 (defun pre-write-encode-hz (from to)
|
|
67 (let ((buf (current-buffer))
|
|
68 (work (get-buffer-create " *pre-write-encoding-work*")))
|
|
69 (set-buffer work)
|
|
70 (widen)
|
|
71 (erase-buffer)
|
|
72 (insert-buffer-substring buf from to)
|
|
73 (encode-hz-region 1 (point-max))
|
|
74 nil))
|
|
75
|
|
76 (register-input-method
|
|
77 "Chinese-GB" '("quail-ccdospy" quail-use-package "quail/ccdospy"))
|
|
78 (register-input-method
|
|
79 "Chinese-GB" '("quail-ctlau" quail-use-package "quail/ctlau"))
|
|
80 (register-input-method
|
|
81 "Chinese-GB" '("quail-punct" quail-use-package "quail/punct"))
|
|
82 (register-input-method
|
|
83 "Chinese-GB" '("quail-qj" quail-use-package "quail/qj"))
|
|
84 (register-input-method
|
|
85 "Chinese-GB" '("quail-sw" quail-use-package "quail/sw"))
|
|
86 (register-input-method
|
|
87 "Chinese-GB" '("quail-ziranma" quail-use-package "quail/ziranma"))
|
|
88 (register-input-method
|
|
89 "Chinese-GB" '("quail-tonepy" quail-use-package "quail/tonepy"))
|
|
90 (register-input-method
|
|
91 "Chinese-GB" '("quail-py" quail-use-package "quail/py"))
|
|
92
|
|
93 (defun setup-chinese-gb-environment ()
|
|
94 (setq primary-language "Chinese-GB")
|
|
95
|
|
96 (setq coding-category-iso-8-2 'coding-system-euc-china)
|
|
97 (setq coding-category-iso-else 'coding-system-iso-2022-cn)
|
|
98
|
|
99 (set-coding-priority
|
|
100 '(coding-category-iso-7
|
|
101 coding-category-iso-else
|
|
102 coding-category-iso-8-2
|
|
103 coding-category-big5
|
|
104 coding-category-iso-8-1
|
|
105 coding-category-internal
|
|
106 ))
|
|
107
|
|
108 (setq-default buffer-file-coding-system 'coding-system-euc-china)
|
|
109 (set-terminal-coding-system 'coding-system-euc-china)
|
|
110 (set-keyboard-coding-system 'coding-system-euc-china)
|
|
111
|
|
112 (setq default-input-method '("Chinese-GB" . "quail-py"))
|
|
113 )
|
|
114
|
|
115 (set-language-info-alist
|
|
116 "Chinese" '((documentation .
|
|
117 "Emacs provides three kinds of Chinese support: Chinese-GB,
|
|
118 Chinese-BIG5, and Chinese-CNS. Please specify one of them to get more
|
|
119 information.")
|
|
120 (setup-function . setup-chinese-gb-environment)
|
|
121 (charset . (chinese-gb2312 chinese-sisheng))
|
|
122 (coding-system . (coding-system-euc-china
|
|
123 coding-system-hz
|
|
124 coding-system-iso-2022-cn))
|
|
125 (documentation . t)
|
|
126 (sample-text . "Chinese ($AVPND(B,$AFUM(;0(B,$A::So(B) $ADc:C(B")))
|
|
127
|
|
128 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
129 ;; Chinese BIG5 (traditional)
|
|
130 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
131
|
|
132 (make-coding-system
|
|
133 'coding-system-big5 3 ?B
|
|
134 "Coding-system of BIG5.")
|
|
135
|
|
136 ;; Big5 font requires special encoding.
|
|
137 (define-ccl-program ccl-encode-big5-font
|
|
138 `(0
|
|
139 ;; In: R0:chinese-big5-1 or chinese-big5-2
|
|
140 ;; R1:position code 1
|
|
141 ;; R2:position code 2
|
|
142 ;; Out: R1:font code point 1
|
|
143 ;; R2:font code point 2
|
|
144 ((r2 = ((((r1 - ?\x21) * 94) + r2) - ?\x21))
|
|
145 (if (r0 == ,(charset-id 'chinese-big5-2)) (r2 += 6280))
|
|
146 (r1 = ((r2 / 157) + ?\xA1))
|
|
147 (r2 %= 157)
|
|
148 (if (r2 < ?\x3F) (r2 += ?\x40) (r2 += ?\x62))))
|
|
149 "CCL program to encode a Big5 code to code point of Big5 font.")
|
|
150
|
|
151 (setq font-ccl-encoder-alist
|
|
152 (cons (cons "big5" ccl-encode-big5-font) font-ccl-encoder-alist))
|
|
153
|
|
154 (register-input-method
|
|
155 "Chinese-BIG5" '("quail-qj-b5" quail-use-package "quail/qj-b5"))
|
|
156 (register-input-method
|
|
157 "Chinese-BIG5" '("quail-zozy" quail-use-package "quail/zozy"))
|
|
158 (register-input-method
|
|
159 "Chinese-BIG5" '("quail-tsangchi-b5" quail-use-package "quail/tsangchi-b5"))
|
|
160 (register-input-method
|
|
161 "Chinese-BIG5" '("quail-py-b5" quail-use-package "quail/py-b5"))
|
|
162 (register-input-method
|
|
163 "Chinese-BIG5" '("quail-quick-b5" quail-use-package "quail/quick-bt"))
|
|
164 (register-input-method
|
|
165 "Chinese-BIG5" '("quail-etzy" quail-use-package "quail/etzy"))
|
|
166 (register-input-method
|
|
167 "Chinese-BIG5" '("quail-ecdict" quail-use-package "quail/ecdict"))
|
|
168 (register-input-method
|
|
169 "Chinese-BIG5" '("quail-ctlaub" quail-use-package "quail/ctlaub"))
|
|
170 (register-input-method
|
|
171 "Chinese-BIG5" '("quail-array30" quail-use-package "quail/array30"))
|
|
172 (register-input-method
|
|
173 "Chinese-BIG5" '("quail-4corner" quail-use-package "quail/4corner"))
|
|
174
|
|
175 (defun setup-chinese-big5-environment ()
|
|
176 (setq primary-language "Chinese-BIG5")
|
|
177
|
|
178 (setq coding-category-big5 'coding-system-big5)
|
|
179 (setq coding-category-iso-else 'coding-system-iso-2022-cn)
|
|
180
|
|
181 (set-coding-priority
|
|
182 '(coding-category-iso-7
|
|
183 coding-category-iso-else
|
|
184 coding-category-big5))
|
|
185
|
|
186 (setq-default buffer-file-coding-system 'coding-system-big5)
|
|
187 (set-terminal-coding-system 'coding-system-big5)
|
|
188 (set-keyboard-coding-system 'coding-system-big5)
|
|
189
|
|
190 (setq default-input-method '("Chinese-BIG5" . "quail-py-b5"))
|
|
191 )
|
|
192
|
|
193 (set-language-info-alist
|
|
194 "Chinese-BIG5" '((setup-function . setup-chinese-big5-environment)
|
|
195 (charset . (chinese-big5-1 chinese-big5-2))
|
|
196 (coding-system . (coding-system-big5
|
|
197 coding-system-iso-2022-cn))
|
|
198 (documentation . t)
|
|
199 (sample-text . "Cantonese ($(0GnM$(B,$(0N]0*Hd(B) $(0*/=((B, $(0+$)p(B")))
|
|
200
|
|
201 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
202 ;; Chinese CNS11643 (traditional)
|
|
203 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
204
|
|
205 (register-input-method
|
|
206 "Chinese-CNS" '("quail-quick-cns" quail-use-package "quail/quick-cns"))
|
|
207 (register-input-method
|
|
208 "Chinese-CNS" '("quail-tsangchi-cns" quail-use-package "quail/tsangchi-cns"))
|
|
209
|
|
210 (defun setup-chinese-cns-environment ()
|
|
211 (setq primary-language "Chinese-CNS")
|
|
212
|
|
213 (setq coding-category-iso-else 'coding-system-iso-2022-cn)
|
|
214
|
|
215 (set-coding-priority
|
|
216 '(coding-category-iso-7
|
|
217 coding-category-iso-else
|
|
218 coding-category-big5))
|
|
219
|
|
220 (setq-default buffer-file-coding-system 'coding-system-iso-2022-7)
|
|
221 (set-terminal-coding-system 'coding-system-iso-2022-7)
|
|
222 (set-keyboard-coding-system 'coding-system-iso-2022-7)
|
|
223
|
|
224 (setq default-input-method '("Chinese-CNS" . "quail-py-cns"))
|
|
225 )
|
|
226
|
|
227 (set-language-info-alist
|
|
228 "Chinese-CNS" '((setup-function . setup-chinese-cns-environment)
|
|
229 (charset . (chinese-cns11643-1 chinese-cns11643-2
|
|
230 chinese-cns11643-3 chinese-cns11643-4
|
|
231 chinese-cns11643-5 chinese-cns11643-6
|
|
232 chinese-cns11643-7))
|
|
233 (coding-system . (coding-system-iso-2022-cn))
|
|
234 (documentation . t)))
|
|
235
|
|
236 ;;; chinese.el ends here
|