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