Commit | Line | Data |
---|---|---|
60370d40 | 1 | ;;; chinese.el --- support for Chinese -*- coding: iso-2022-7bit; -*- |
4ed46869 | 2 | |
4ed46869 | 3 | ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN. |
fa526c4a | 4 | ;; Licensed to the Free Software Foundation. |
4ed46869 KH |
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 | |
369314dc KH |
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. | |
4ed46869 KH |
24 | |
25 | ;;; Commentary: | |
26 | ||
27 | ;; For Chinese, three character sets GB2312, BIG5, and CNS11643 are | |
28 | ;; supported. | |
29 | ||
30 | ;;; Code: | |
31 | ||
32 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
33 | ;;; Chinese (general) | |
34 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
35 | ||
e1915ab3 | 36 | (define-coding-system 'iso-2022-cn |
285aac85 | 37 | "ISO 2022 based 7bit encoding for Chinese GB and CNS (MIME:ISO-2022-CN)." |
e1915ab3 KH |
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) | |
d21363d3 | 47 | :mime-charset 'iso-2022-cn) |
4138c943 KH |
48 | |
49 | (define-coding-system-alias 'chinese-iso-7bit 'iso-2022-cn) | |
50 | ||
e1915ab3 KH |
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) | |
d21363d3 | 66 | :mime-charset 'iso-2022-cn-ext) |
4138c943 | 67 | |
335a7ad7 | 68 | \f |
4ed46869 KH |
69 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
70 | ;;; Chinese GB2312 (simplified) | |
71 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
72 | ||
e1915ab3 KH |
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] | |
d21363d3 | 79 | :mime-charset 'cn-gb) |
4ed46869 | 80 | |
71eabd24 RS |
81 | (define-coding-system-alias 'cn-gb-2312 'chinese-iso-8bit) |
82 | (define-coding-system-alias 'euc-china 'chinese-iso-8bit) | |
a18aa841 | 83 | (define-coding-system-alias 'euc-cn 'chinese-iso-8bit) |
4f35555a KH |
84 | (define-coding-system-alias 'cn-gb 'chinese-iso-8bit) |
85 | (define-coding-system-alias 'gb2312 'chinese-iso-8bit) | |
f3f18123 | 86 | |
e1915ab3 | 87 | (define-coding-system 'chinese-hz |
285aac85 | 88 | "Hz/ZW 7-bit encoding for Chinese GB2312 (MIME:HZ-GB-2312)." |
e1915ab3 KH |
89 | :coding-type 'utf-8 |
90 | :mnemonic ?z | |
91 | :charset-list '(ascii chinese-gb2312) | |
d21363d3 | 92 | :mime-charset 'hz-gb-2312 |
e1915ab3 KH |
93 | :post-read-conversion 'post-read-decode-hz |
94 | :pre-write-conversion 'pre-write-encode-hz) | |
f3f18123 | 95 | |
71eabd24 RS |
96 | (define-coding-system-alias 'hz-gb-2312 'chinese-hz) |
97 | (define-coding-system-alias 'hz 'chinese-hz) | |
4ed46869 KH |
98 | |
99 | (defun post-read-decode-hz (len) | |
69f24acf KH |
100 | (let ((pos (point)) |
101 | (buffer-modified-p (buffer-modified-p)) | |
102 | last-coding-system-used) | |
103 | (prog1 | |
104 | (decode-hz-region pos (+ pos len)) | |
105 | (set-buffer-modified-p buffer-modified-p)))) | |
4ed46869 KH |
106 | |
107 | (defun pre-write-encode-hz (from to) | |
1944b2e7 | 108 | (let ((buf (current-buffer))) |
d64a0ef7 KH |
109 | (set-buffer (generate-new-buffer " *temp*")) |
110 | (if (stringp from) | |
111 | (insert from) | |
112 | (insert-buffer-substring buf from to)) | |
113 | (let (last-coding-system-used) | |
114 | (encode-hz-region 1 (point-max))) | |
4ed46869 KH |
115 | nil)) |
116 | ||
4ed46869 | 117 | (set-language-info-alist |
a564ccf9 | 118 | "Chinese-GB" '((charset chinese-gb2312 chinese-sisheng) |
4138c943 KH |
119 | (coding-system chinese-iso-8bit iso-2022-cn chinese-hz) |
120 | (coding-priority chinese-iso-8bit chinese-big5 iso-2022-cn) | |
a564ccf9 KH |
121 | (input-method . "chinese-py-punct") |
122 | (features china-util) | |
fab8252e | 123 | (sample-text . "Chinese (\e$AVPND\e(B,\e$AFUM(;0\e(B,\e$A::So\e(B) \e$ADc:C\e(B") |
4138c943 KH |
124 | (documentation . "Support for Chinese GB2312 character set.")) |
125 | '("Chinese")) | |
4ed46869 KH |
126 | |
127 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
128 | ;; Chinese BIG5 (traditional) | |
129 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
130 | ||
e1915ab3 KH |
131 | (define-coding-system 'chinese-big5 |
132 | "BIG5 8-bit encoding for Chinese (MIME:Big5)" | |
51574791 | 133 | :coding-type 'charset |
e1915ab3 KH |
134 | :mnemonic ?B |
135 | :charset-list '(ascii big5) | |
d21363d3 | 136 | :mime-charset 'big5) |
4ed46869 | 137 | |
71eabd24 RS |
138 | (define-coding-system-alias 'big5 'chinese-big5) |
139 | (define-coding-system-alias 'cn-big5 'chinese-big5) | |
f3f18123 | 140 | |
4ed46869 | 141 | (set-language-info-alist |
a564ccf9 | 142 | "Chinese-BIG5" '((charset chinese-big5-1 chinese-big5-2) |
4138c943 KH |
143 | (coding-system chinese-big5 chinese-iso-7bit) |
144 | (coding-priority chinese-big5 iso-2022-cn chinese-iso-8bit) | |
a564ccf9 KH |
145 | (input-method . "chinese-py-punct-b5") |
146 | (features china-util) | |
fab8252e | 147 | (sample-text . "Cantonese (\e$(0GnM$\e(B,\e$(0N]0*Hd\e(B) \e$(0*/=(\e(B, \e$(0+$)p\e(B") |
4138c943 KH |
148 | (documentation . "Support for Chinese Big5 character set.")) |
149 | '("Chinese")) | |
4ed46869 KH |
150 | |
151 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
152 | ;; Chinese CNS11643 (traditional) | |
153 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
154 | ||
e1915ab3 KH |
155 | (define-coding-system 'euc-tw |
156 | "ISO 2022 based EUC encoding for Chinese CNS11643." | |
157 | :coding-type 'iso-2022 | |
158 | :mnemonic ?Z | |
159 | :charset-list '(ascii | |
160 | chinese-cns11643-1 | |
161 | chinese-cns11643-2 | |
162 | chinese-cns11643-3 | |
163 | chinese-cns11643-4 | |
164 | chinese-cns11643-5 | |
165 | chinese-cns11643-6 | |
166 | chinese-cns11643-7) | |
167 | :designation [ascii chinese-cns11643-1 (chinese-cns11643-1 | |
168 | chinese-cns11643-2 | |
169 | chinese-cns11643-3 | |
170 | chinese-cns11643-4 | |
171 | chinese-cns11643-5 | |
172 | chinese-cns11643-6 | |
173 | chinese-cns11643-7) nil] | |
d21363d3 | 174 | :mime-charset 'euc-tw) |
285aac85 WL |
175 | |
176 | (define-coding-system-alias 'euc-taiwan 'euc-tw) | |
177 | ||
4ed46869 | 178 | (set-language-info-alist |
a564ccf9 | 179 | "Chinese-CNS" '((charset chinese-cns11643-1 chinese-cns11643-2 |
4138c943 KH |
180 | chinese-cns11643-3 chinese-cns11643-4 |
181 | chinese-cns11643-5 chinese-cns11643-6 | |
182 | chinese-cns11643-7) | |
285aac85 WL |
183 | (coding-system iso-2022-cn euc-tw) |
184 | (coding-priority iso-2022-cn euc-tw chinese-big5 | |
185 | chinese-iso-8bit) | |
a564ccf9 KH |
186 | (features china-util) |
187 | (input-method . "chinese-cns-quick") | |
285aac85 WL |
188 | (documentation . "\ |
189 | Support for Chinese CNS character sets. Note that EUC-TW coding system | |
190 | accepts Big5 for input also (which is then converted to CNS).")) | |
4138c943 | 191 | '("Chinese")) |
4ed46869 | 192 | |
41da80b1 DL |
193 | (provide 'chinese) |
194 | ||
4ed46869 | 195 | ;;; chinese.el ends here |