Sync to HEAD
[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
91 (define-coding-system 'chinese-hz
92 "Hz/ZW 7-bit encoding for Chinese GB2312 (MIME:HZ-GB-2312)."
93 :coding-type 'utf-8
94 :mnemonic ?z
95 :charset-list '(ascii chinese-gb2312)
96 :mime-charset 'hz-gb-2312
97 :post-read-conversion 'post-read-decode-hz
98 :pre-write-conversion 'pre-write-encode-hz)
99
100 (define-coding-system-alias 'hz-gb-2312 'chinese-hz)
101 (define-coding-system-alias 'hz 'chinese-hz)
102
103 (set-language-info-alist
104 "Chinese-GB" '((charset chinese-gb2312 chinese-sisheng)
105 (coding-system chinese-iso-8bit iso-2022-cn chinese-hz)
106 (coding-priority chinese-iso-8bit chinese-big5 iso-2022-cn)
107 (input-method . "chinese-py-punct")
108 (features china-util)
109 (sample-text . "Chinese (\e$AVPND\e(B,\e$AFUM(;0\e(B,\e$A::So\e(B) \e$ADc:C\e(B")
110 (documentation . "Support for Chinese GB2312 character set.")
111 (tutorial . "TUTORIAL.cn"))
112 '("Chinese"))
113
114 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
115 ;; Chinese BIG5 (traditional)
116 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
117
118 (define-coding-system 'chinese-big5
119 "BIG5 8-bit encoding for Chinese (MIME:Big5)"
120 :coding-type 'charset
121 :mnemonic ?B
122 :charset-list '(ascii big5)
123 :mime-charset 'big5)
124
125 (define-coding-system-alias 'big5 'chinese-big5)
126 (define-coding-system-alias 'cn-big5 'chinese-big5)
127
128 (set-language-info-alist
129 "Chinese-BIG5" '((charset chinese-big5-1 chinese-big5-2)
130 (coding-system chinese-big5 chinese-iso-7bit)
131 (coding-priority chinese-big5 iso-2022-cn chinese-iso-8bit)
132 (input-method . "chinese-py-punct-b5")
133 (features china-util)
134 (sample-text . "Cantonese (\e$(0GnM$\e(B,\e$(0N]0*Hd\e(B) \e$(0*/=(\e(B, \e$(0+$)p\e(B")
135 (documentation . "Support for Chinese Big5 character set.")
136 (tutorial . "TUTORIAL.zh"))
137 '("Chinese"))
138
139 (define-coding-system 'chinese-big5-hkscs
140 "BIG5-HKSCS 8-bit encoding for Chinese, Hong Kong supplement (MIME:Big5-HKSCS)"
141 :coding-type 'charset
142 :mnemonic ?B
143 :charset-list '(ascii big5-hkscs)
144 :mime-charset 'big5-hkscs)
145 (define-coding-system-alias 'big5-hkscs 'chinese-big5-hkscs)
146 (define-coding-system-alias 'cn-big5-hkscs 'chinese-big5-hkscs)
147
148 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
149 ;; Chinese CNS11643 (traditional)
150 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
151
152 (define-coding-system 'euc-tw
153 "ISO 2022 based EUC encoding for Chinese CNS11643."
154 :coding-type 'iso-2022
155 :mnemonic ?Z
156 :charset-list '(ascii
157 chinese-cns11643-1
158 chinese-cns11643-2
159 chinese-cns11643-3
160 chinese-cns11643-4
161 chinese-cns11643-5
162 chinese-cns11643-6
163 chinese-cns11643-7)
164 :designation [ascii chinese-cns11643-1 (chinese-cns11643-1
165 chinese-cns11643-2
166 chinese-cns11643-3
167 chinese-cns11643-4
168 chinese-cns11643-5
169 chinese-cns11643-6
170 chinese-cns11643-7) nil]
171 :mime-charset 'euc-tw)
172
173 (define-coding-system-alias 'euc-taiwan 'euc-tw)
174
175 (set-language-info-alist
176 "Chinese-CNS" '((charset chinese-cns11643-1 chinese-cns11643-2
177 chinese-cns11643-3 chinese-cns11643-4
178 chinese-cns11643-5 chinese-cns11643-6
179 chinese-cns11643-7)
180 (coding-system iso-2022-cn euc-tw)
181 (coding-priority iso-2022-cn euc-tw chinese-big5
182 chinese-iso-8bit)
183 (features china-util)
184 (input-method . "chinese-cns-quick")
185 ;; Fixme: presumably it won't accept big5 now.
186 (documentation . "\
187 Support for Chinese CNS character sets. Note that the EUC-TW coding system
188 accepts Big5 for input also (which is then converted to CNS)."))
189 '("Chinese"))
190
191 (set-language-info-alist
192 "Chinese-EUC-TW" '((charset chinese-cns11643-1 chinese-cns11643-2
193 chinese-cns11643-3 chinese-cns11643-4
194 chinese-cns11643-5 chinese-cns11643-6
195 chinese-cns11643-7 chinese-big5-1 chinese-big5-2)
196 (coding-system euc-tw iso-2022-cn)
197 (coding-priority euc-tw chinese-big5 iso-2022-cn
198 chinese-iso-8bit)
199 (features china-util)
200 (input-method . "chinese-cns-quick")
201 (documentation . "\
202 Support for Chinese, prefering the EUC-TW character set. Note that
203 the EUC-TW coding system accepts Big5 for input also (which is then
204 converted to CNS)."))
205 '("Chinese"))
206
207
208 ;;; Chinese GBK
209
210 (define-coding-system 'chinese-gbk
211 "GBK encoding for Chinese (MIME:GBK)."
212 :coding-type 'charset
213 :mnemonic ?c
214 :charset-list '(chinese-gbk)
215 :mime-charset 'gbk)
216 (define-coding-system-alias 'gbk 'chinese-gbk)
217 (define-coding-system-alias 'cp936 'chinese-gbk)
218 (define-coding-system-alias 'windows-936 'chinese-gbk)
219
220 (set-language-info-alist
221 "Chinese-GBK" '((charset chinese-gbk)
222 (coding-system chinese-gbk)
223 (coding-priority gbk iso-2022-cn chinese-big5
224 chinese-iso-8bit) ; fixme?
225 (input-method . "chinese-py-punct") ; fixme?
226 (features china-util)
227 (documentation . "Support for Chinese GBK character set."))
228 '("Chinese"))
229
230 ;;; Chinese GB18030
231
232 (define-coding-system 'chinese-gb18030
233 "GB18030 encoding for Chinese (MIME:GB18030)."
234 :coding-type 'charset
235 :mnemonic ?c
236 :charset-list '(ascii gb18030-2-byte
237 gb18030-4-byte-bmp gb18030-4-byte-smp
238 gb18030-4-byte-ext-1 gb18030-4-byte-ext-2)
239 :mime-charset 'gb18030)
240
241 (define-coding-system-alias 'gb18030 'chinese-gb18030)
242
243 (set-language-info-alist
244 "Chinese-GB18030" '((charset gb18030)
245 (coding-system chinese-gb18030)
246 (coding-priority gb18030 gbk iso-2022-cn chinese-big5
247 chinese-iso-8bit) ; fixme?
248 (input-method . "chinese-py-punct") ; fixme?
249 (features china-util)
250 (documentation
251 . "Support for Chinese GB18030 character set."))
252 '("Chinese"))
253
254 ;; Fixme: add HKSCS
255
256 (provide 'chinese)
257
258 ;;; arch-tag: b82fcf7a-84f6-4e0b-b38c-1742dac0e09f
259 ;;; chinese.el ends here