Revision: miles@gnu.org--gnu-2004/emacs--unicode--0--patch-15
[bpt/emacs.git] / lisp / language / chinese.el
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) 2003
6 ;; National Institute of Advanced Industrial Science and Technology (AIST)
7 ;; Registration Number H13PRO009
8
9 ;; Keywords: multilingual, Chinese
10
11 ;; This file is part of GNU Emacs.
12
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; any later version.
17
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
22
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26 ;; Boston, MA 02111-1307, USA.
27
28 ;;; Commentary:
29
30 ;; For Chinese, three character sets GB2312, BIG5, and CNS11643 are
31 ;; supported.
32
33 ;;; Code:
34
35 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
36 ;;; Chinese (general)
37 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
38
39
40 (define-coding-system 'iso-2022-cn
41 "ISO 2022 based 7bit encoding for Chinese GB and CNS (MIME:ISO-2022-CN)."
42 :coding-type 'iso-2022
43 :mnemonic ?C
44 :charset-list '(ascii chinese-gb2312 chinese-cns11643-1 chinese-cns11643-2)
45 :designation [ascii
46 (nil chinese-gb2312 chinese-cns11643-1)
47 (nil chinese-cns11643-2)
48 nil]
49 :flags '(ascii-at-eol ascii-at-cntl 7-bit
50 designation locking-shift single-shift init-at-bol)
51 :mime-charset 'iso-2022-cn)
52
53 (define-coding-system-alias 'chinese-iso-7bit 'iso-2022-cn)
54
55 (define-coding-system 'iso-2022-cn-ext
56 "ISO 2022 based 7bit encoding for Chinese GB and CNS (MIME:ISO-2022-CN-EXT)."
57 :coding-type 'iso-2022
58 :mnemonic ?C
59 :charset-list '(ascii
60 chinese-gb2312 chinese-cns11643-1
61 chinese-cns11643-2 chinese-cns11643-3 chinese-cns11643-4
62 chinese-cns11643-5 chinese-cns11643-6 chinese-cns11643-7)
63 :designation '[ascii
64 (nil chinese-gb2312 chinese-cns11643-1)
65 (nil chinese-cns11643-2)
66 (nil chinese-cns11643-3 chinese-cns11643-4 chinese-cns11643-5
67 chinese-cns11643-6 chinese-cns11643-7)]
68 :flags '(ascii-at-eol ascii-at-cntl 7-bit
69 designation locking-shift single-shift init-at-bol)
70 :mime-charset 'iso-2022-cn-ext)
71
72 \f
73 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
74 ;;; Chinese GB2312 (simplified)
75 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
76
77 (define-coding-system 'chinese-iso-8bit
78 "ISO 2022 based EUC encoding for Chinese GB2312 (MIME:CN-GB)."
79 :coding-type 'iso-2022
80 :mnemonic ?c
81 :charset-list '(ascii chinese-gb2312)
82 :designation [ascii chinese-gb2312 nil nil]
83 :mime-charset 'cn-gb)
84
85 (define-coding-system-alias 'cn-gb-2312 'chinese-iso-8bit)
86 (define-coding-system-alias 'euc-china 'chinese-iso-8bit)
87 (define-coding-system-alias 'euc-cn 'chinese-iso-8bit)
88 (define-coding-system-alias 'cn-gb 'chinese-iso-8bit)
89 (define-coding-system-alias 'gb2312 'chinese-iso-8bit)
90 (define-coding-system-alias 'cp936 'chinese-iso-8bit)
91
92 (define-coding-system 'chinese-hz
93 "Hz/ZW 7-bit encoding for Chinese GB2312 (MIME:HZ-GB-2312)."
94 :coding-type 'utf-8
95 :mnemonic ?z
96 :charset-list '(ascii chinese-gb2312)
97 :mime-charset 'hz-gb-2312
98 :post-read-conversion 'post-read-decode-hz
99 :pre-write-conversion 'pre-write-encode-hz)
100
101 (define-coding-system-alias 'hz-gb-2312 'chinese-hz)
102 (define-coding-system-alias 'hz 'chinese-hz)
103
104 (set-language-info-alist
105 "Chinese-GB" '((charset chinese-gb2312 chinese-sisheng)
106 (coding-system chinese-iso-8bit iso-2022-cn chinese-hz)
107 (coding-priority chinese-iso-8bit chinese-big5 iso-2022-cn)
108 (input-method . "chinese-py-punct")
109 (features china-util)
110 (sample-text . "Chinese (\e$AVPND\e(B,\e$AFUM(;0\e(B,\e$A::So\e(B) \e$ADc:C\e(B")
111 (documentation . "Support for Chinese GB2312 character set.")
112 (tutorial . "TUTORIAL.cn"))
113 '("Chinese"))
114
115 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
116 ;; Chinese BIG5 (traditional)
117 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
118
119 (define-coding-system 'chinese-big5
120 "BIG5 8-bit encoding for Chinese (MIME:Big5)"
121 :coding-type 'charset
122 :mnemonic ?B
123 :charset-list '(ascii big5)
124 :mime-charset 'big5)
125
126 (define-coding-system-alias 'big5 'chinese-big5)
127 (define-coding-system-alias 'cn-big5 'chinese-big5)
128 (define-coding-system-alias 'cp950 'chinese-big5)
129
130 (set-language-info-alist
131 "Chinese-BIG5" '((charset chinese-big5-1 chinese-big5-2)
132 (coding-system chinese-big5 chinese-iso-7bit)
133 (coding-priority chinese-big5 iso-2022-cn chinese-iso-8bit)
134 (input-method . "chinese-py-punct-b5")
135 (features china-util)
136 (sample-text . "Cantonese (\e$(0GnM$\e(B,\e$(0N]0*Hd\e(B) \e$(0*/=(\e(B, \e$(0+$)p\e(B")
137 (documentation . "Support for Chinese Big5 character set.")
138 (tutorial . "TUTORIAL.zh"))
139 '("Chinese"))
140
141 (define-coding-system 'chinese-big5-hkscs
142 "BIG5-HKSCS 8-bit encoding for Chinese, Hong Kong supplement (MIME:Big5-HKSCS)"
143 :coding-type 'charset
144 :mnemonic ?B
145 :charset-list '(ascii big5-hkscs)
146 :mime-charset 'big5-hkscs)
147 (define-coding-system-alias 'big5-hkscs 'chinese-big5-hkscs)
148 (define-coding-system-alias 'cn-big5-hkscs 'chinese-big5-hkscs)
149
150 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
151 ;; Chinese CNS11643 (traditional)
152 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
153
154 (define-coding-system 'euc-tw
155 "ISO 2022 based EUC encoding for Chinese CNS11643."
156 :coding-type 'iso-2022
157 :mnemonic ?Z
158 :charset-list '(ascii
159 chinese-cns11643-1
160 chinese-cns11643-2
161 chinese-cns11643-3
162 chinese-cns11643-4
163 chinese-cns11643-5
164 chinese-cns11643-6
165 chinese-cns11643-7)
166 :designation [ascii chinese-cns11643-1 (chinese-cns11643-1
167 chinese-cns11643-2
168 chinese-cns11643-3
169 chinese-cns11643-4
170 chinese-cns11643-5
171 chinese-cns11643-6
172 chinese-cns11643-7) nil]
173 :mime-charset 'euc-tw)
174
175 (define-coding-system-alias 'euc-taiwan 'euc-tw)
176
177 (set-language-info-alist
178 "Chinese-CNS" '((charset chinese-cns11643-1 chinese-cns11643-2
179 chinese-cns11643-3 chinese-cns11643-4
180 chinese-cns11643-5 chinese-cns11643-6
181 chinese-cns11643-7)
182 (coding-system iso-2022-cn euc-tw)
183 (coding-priority iso-2022-cn euc-tw chinese-big5
184 chinese-iso-8bit)
185 (features china-util)
186 (input-method . "chinese-cns-quick")
187 ;; Fixme: presumably it won't accept big5 now.
188 (documentation . "\
189 Support for Chinese CNS character sets. Note that the EUC-TW coding system
190 accepts Big5 for input also (which is then converted to CNS)."))
191 '("Chinese"))
192
193 (set-language-info-alist
194 "Chinese-EUC-TW" '((charset chinese-cns11643-1 chinese-cns11643-2
195 chinese-cns11643-3 chinese-cns11643-4
196 chinese-cns11643-5 chinese-cns11643-6
197 chinese-cns11643-7 chinese-big5-1 chinese-big5-2)
198 (coding-system euc-tw iso-2022-cn)
199 (coding-priority euc-tw chinese-big5 iso-2022-cn
200 chinese-iso-8bit)
201 (features china-util)
202 (input-method . "chinese-cns-quick")
203 (documentation . "\
204 Support for Chinese, prefering the EUC-TW character set. Note that
205 the EUC-TW coding system accepts Big5 for input also (which is then
206 converted to CNS)."))
207 '("Chinese"))
208
209
210 ;;; Chinese GBK
211
212 (define-coding-system 'chinese-gbk
213 "GBK encoding for Chinese (MIME:GBK)."
214 :coding-type 'charset
215 :mnemonic ?c
216 :charset-list '(chinese-gbk)
217 :mime-charset 'gbk)
218 (define-coding-system-alias 'gbk 'chinese-gbk)
219 (define-coding-system-alias 'cp936 'chinese-gbk)
220 (define-coding-system-alias 'windows-936 'chinese-gbk)
221
222 (set-language-info-alist
223 "Chinese-GBK" '((charset chinese-gbk)
224 (coding-system chinese-gbk)
225 (coding-priority gbk iso-2022-cn chinese-big5
226 chinese-iso-8bit) ; fixme?
227 (input-method . "chinese-py-punct") ; fixme?
228 (features china-util)
229 (documentation . "Support for Chinese GBK character set."))
230 '("Chinese"))
231
232 ;;; Chinese GB18030
233
234 (define-coding-system 'chinese-gb18030
235 "GB18030 encoding for Chinese (MIME:GB18030)."
236 :coding-type 'charset
237 :mnemonic ?c
238 :charset-list '(ascii gb18030-2-byte
239 gb18030-4-byte-bmp gb18030-4-byte-smp
240 gb18030-4-byte-ext-1 gb18030-4-byte-ext-2)
241 :mime-charset 'gb18030)
242
243 (define-coding-system-alias 'gb18030 'chinese-gb18030)
244
245 (set-language-info-alist
246 "Chinese-GB18030" '((charset gb18030)
247 (coding-system chinese-gb18030)
248 (coding-priority gb18030 gbk iso-2022-cn chinese-big5
249 chinese-iso-8bit) ; fixme?
250 (input-method . "chinese-py-punct") ; fixme?
251 (features china-util)
252 (documentation
253 . "Support for Chinese GB18030 character set."))
254 '("Chinese"))
255
256 ;; Fixme: add HKSCS
257
258 (provide 'chinese)
259
260 ;;; arch-tag: b82fcf7a-84f6-4e0b-b38c-1742dac0e09f
261 ;;; chinese.el ends here