(Fbyte_code): Convert a unibyte character to multibyte if necessary.
[emacs.git] / lisp / language / chinese.el
blobe6201cef970de479fd2f3dec0d33526233fc1e04
1 ;;; chinese.el --- support for Chinese -*- coding: iso-2022-7bit; -*-
3 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
4 ;; Licensed to the Free Software Foundation.
6 ;; Keywords: multilingual, Chinese
8 ;; This file is part of GNU Emacs.
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.
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.
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 the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
25 ;;; Commentary:
27 ;; For Chinese, three character sets GB2312, BIG5, and CNS11643 are
28 ;; supported.
30 ;;; Code:
32 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
33 ;;; Chinese (general)
34 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
36 (define-coding-system 'iso-2022-cn
37 "ISO 2022 based 7bit encoding for Chinese GB and CNS (MIME:ISO-2022-CN)."
38 :coding-type 'iso-2022
39 :mnemonic ?C
40 :charset-list '(ascii chinese-gb2312 chinese-cns11643-1 chinese-cns11643-2)
41 :designation [ascii
42 (nil chinese-gb2312 chinese-cns11643-1)
43 (nil chinese-cns11643-2)
44 nil]
45 :flags '(ascii-at-eol ascii-at-cntl 7-bit
46 designation locking-shift single-shift init-at-bol)
47 :mime-charset 'iso-2022-cn)
49 (define-coding-system-alias 'chinese-iso-7bit 'iso-2022-cn)
51 (define-coding-system 'iso-2022-cn-ext
52 "ISO 2022 based 7bit encoding for Chinese GB and CNS (MIME:ISO-2022-CN-EXT)."
53 :coding-type 'iso-2022
54 :mnemonic ?C
55 :charset-list '(ascii
56 chinese-gb2312 chinese-cns11643-1
57 chinese-cns11643-2 chinese-cns11643-3 chinese-cns11643-4
58 chinese-cns11643-5 chinese-cns11643-6 chinese-cns11643-7)
59 :designation '[ascii
60 (nil chinese-gb2312 chinese-cns11643-1)
61 (nil chinese-cns11643-2)
62 (nil chinese-cns11643-3 chinese-cns11643-4 chinese-cns11643-5
63 chinese-cns11643-6 chinese-cns11643-7)]
64 :flags '(ascii-at-eol ascii-at-cntl 7-bit
65 designation locking-shift single-shift init-at-bol)
66 :mime-charset 'iso-2022-cn-ext)
69 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
70 ;;; Chinese GB2312 (simplified)
71 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
73 (define-coding-system 'chinese-iso-8bit
74 "ISO 2022 based EUC encoding for Chinese GB2312 (MIME:CN-GB)."
75 :coding-type 'iso-2022
76 :mnemonic ?c
77 :charset-list '(ascii chinese-gb2312)
78 :designation [ascii chinese-gb2312 nil nil]
79 :mime-charset 'cn-gb)
81 (define-coding-system-alias 'cn-gb-2312 'chinese-iso-8bit)
82 (define-coding-system-alias 'euc-china 'chinese-iso-8bit)
83 (define-coding-system-alias 'euc-cn 'chinese-iso-8bit)
84 (define-coding-system-alias 'cn-gb 'chinese-iso-8bit)
85 (define-coding-system-alias 'gb2312 'chinese-iso-8bit)
87 (define-coding-system 'chinese-hz
88 "Hz/ZW 7-bit encoding for Chinese GB2312 (MIME:HZ-GB-2312)."
89 :coding-type 'utf-8
90 :mnemonic ?z
91 :charset-list '(ascii chinese-gb2312)
92 :mime-charset 'hz-gb-2312
93 :post-read-conversion 'post-read-decode-hz
94 :pre-write-conversion 'pre-write-encode-hz)
96 (define-coding-system-alias 'hz-gb-2312 'chinese-hz)
97 (define-coding-system-alias 'hz 'chinese-hz)
99 (set-language-info-alist
100 "Chinese-GB" '((charset chinese-gb2312 chinese-sisheng)
101 (coding-system chinese-iso-8bit iso-2022-cn chinese-hz)
102 (coding-priority chinese-iso-8bit chinese-big5 iso-2022-cn)
103 (input-method . "chinese-py-punct")
104 (features china-util)
105 (sample-text . "Chinese (\e$AVPND\e(B,\e$AFUM(;0\e(B,\e$A::So\e(B) \e$ADc:C\e(B")
106 (documentation . "Support for Chinese GB2312 character set."))
107 '("Chinese"))
109 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
110 ;; Chinese BIG5 (traditional)
111 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
113 (define-coding-system 'chinese-big5
114 "BIG5 8-bit encoding for Chinese (MIME:Big5)"
115 :coding-type 'charset
116 :mnemonic ?B
117 :charset-list '(ascii big5)
118 :mime-charset 'big5)
120 (define-coding-system-alias 'big5 'chinese-big5)
121 (define-coding-system-alias 'cn-big5 'chinese-big5)
123 (set-language-info-alist
124 "Chinese-BIG5" '((charset chinese-big5-1 chinese-big5-2)
125 (coding-system chinese-big5 chinese-iso-7bit)
126 (coding-priority chinese-big5 iso-2022-cn chinese-iso-8bit)
127 (input-method . "chinese-py-punct-b5")
128 (features china-util)
129 (sample-text . "Cantonese (\e$(Gemk#\e(B,\e$(Gl]N)fc\e(B) \e$ATg3?\e(B, \e$ADc:C\e(B")
130 (documentation . "Support for Chinese Big5 character set."))
131 '("Chinese"))
133 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
134 ;; Chinese CNS11643 (traditional)
135 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
137 (define-coding-system 'euc-tw
138 "ISO 2022 based EUC encoding for Chinese CNS11643."
139 :coding-type 'iso-2022
140 :mnemonic ?Z
141 :charset-list '(ascii
142 chinese-cns11643-1
143 chinese-cns11643-2
144 chinese-cns11643-3
145 chinese-cns11643-4
146 chinese-cns11643-5
147 chinese-cns11643-6
148 chinese-cns11643-7)
149 :designation [ascii chinese-cns11643-1 (chinese-cns11643-1
150 chinese-cns11643-2
151 chinese-cns11643-3
152 chinese-cns11643-4
153 chinese-cns11643-5
154 chinese-cns11643-6
155 chinese-cns11643-7) nil]
156 :mime-charset 'euc-tw)
158 (define-coding-system-alias 'euc-taiwan 'euc-tw)
160 (set-language-info-alist
161 "Chinese-CNS" '((charset chinese-cns11643-1 chinese-cns11643-2
162 chinese-cns11643-3 chinese-cns11643-4
163 chinese-cns11643-5 chinese-cns11643-6
164 chinese-cns11643-7)
165 (coding-system iso-2022-cn euc-tw)
166 (coding-priority iso-2022-cn euc-tw chinese-big5
167 chinese-iso-8bit)
168 (features china-util)
169 (input-method . "chinese-cns-quick")
170 ;; Fixme: presumably it won't accept big5 now.
171 (documentation . "\
172 Support for Chinese CNS character sets. Note that EUC-TW coding system
173 accepts Big5 for input also (which is then converted to CNS)."))
174 '("Chinese"))
176 ;;; Chinese GBK
178 (define-coding-system 'chinese-gbk
179 "GBK encoding for Chinese (MIME:GBK)."
180 :coding-type 'charset
181 :mnemonic ?c
182 :charset-list '(chinese-gbk)
183 :mime-charset 'gbk)
184 (define-coding-system-alias 'gbk 'chinese-gbk)
185 (define-coding-system-alias 'cp936 'chinese-gbk)
186 (define-coding-system-alias 'windows-936 'chinese-gbk)
188 (set-language-info-alist
189 "Chinese-GBK" '((charset chinese-gbk)
190 (coding-system chinese-gbk)
191 (coding-priority gbk iso-2022-cn chinese-big5
192 chinese-iso-8bit) ; fixme?
193 (input-method . "chinese-py-punct") ; fixme?
194 (features china-util)
195 (documentation . "Support for Chinese GBK character set."))
196 '("Chinese"))
198 ;; Fixme: add HKSCS, GB18030
200 (provide 'chinese)
202 ;;; chinese.el ends here