Mercurial > hg > xemacs-beta
comparison lisp/mule/vietnamese.el @ 428:3ecd8885ac67 r21-2-22
Import from CVS: tag r21-2-22
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:28:15 +0200 |
parents | |
children | 8de8e3f6228a |
comparison
equal
deleted
inserted
replaced
427:0a0253eac470 | 428:3ecd8885ac67 |
---|---|
1 ;;; vietnamese.el --- Support for Vietnamese -*- coding: iso-2022-7bit; -*- | |
2 | |
3 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN. | |
4 ;; Licensed to the Free Software Foundation. | |
5 ;; Copyright (C) 1997 MORIOKA Tomohiko | |
6 | |
7 ;; Keywords: multilingual, Vietnamese | |
8 | |
9 ;; This file is part of XEmacs. | |
10 | |
11 ;; XEmacs is free software; you can redistribute it and/or modify it | |
12 ;; under the terms of the GNU General Public License as published by | |
13 ;; the Free Software Foundation; either version 2, or (at your option) | |
14 ;; any later version. | |
15 | |
16 ;; XEmacs is distributed in the hope that it will be useful, but | |
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
19 ;; General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
22 ;; along with XEmacs; see the file COPYING. If not, write to the Free | |
23 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
24 ;; 02111-1307, USA. | |
25 | |
26 ;;; Commentary: | |
27 | |
28 ;; For Vietnames, the character sets VISCII and VSCII are supported. | |
29 | |
30 ;;; Code: | |
31 | |
32 (eval-and-compile | |
33 | |
34 (defvar viet-viscii-decode-table | |
35 [;; VISCII is a full 8-bit code. | |
36 0 1 ?,2F(B 3 4 ?,2G(B ?,2g(B 7 8 9 10 11 12 13 14 15 | |
37 16 17 18 19 ?,2V(B 21 22 23 24 ?,2[(B 26 27 28 29 ?,2\(B 31 | |
38 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
39 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
40 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
41 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
42 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
43 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
44 ?,2U(B ?,2!(B ?,2"(B ?,2#(B ?,2$(B ?,2%(B ?,2&(B ?,2'(B ?,2((B ?,2)(B ?,2*(B ?,2+(B ?,2,(B ?,2-(B ?,2.(B ?,2/(B | |
45 ?,20(B ?,21(B ?,22(B ?,25(B ?,2~(B ?,2>(B ?,26(B ?,27(B ?,28(B ?,2v(B ?,2w(B ?,2o(B ?,2|(B ?,2{(B ?,2x(B ?,2O(B | |
46 ?,2u(B ?,1!(B ?,1"(B ?,1#(B ?,1$(B ?,1%(B ?,1&(B ?,1'(B ?,1((B ?,1)(B ?,1*(B ?,1+(B ?,1,(B ?,1-(B ?,1.(B ?,1/(B | |
47 ?,10(B ?,11(B ?,12(B ?,2^(B ?,2=(B ?,15(B ?,16(B ?,17(B ?,18(B ?,2q(B ?,2Q(B ?,2W(B ?,2X(B ?,1=(B ?,1>(B ?,2_(B | |
48 ?,2`(B ?,2a(B ?,2b(B ?,2c(B ?,2d(B ?,2e(B ?,1F(B ?,1G(B ?,2h(B ?,2i(B ?,2j(B ?,2k(B ?,2l(B ?,2m(B ?,2n(B ?,1O(B | |
49 ?,2p(B ?,1Q(B ?,2r(B ?,2s(B ?,2t(B ?,1U(B ?,1V(B ?,1W(B ?,1X(B ?,2y(B ?,2z(B ?,1[(B ?,1\(B ?,2}(B ?,1^(B ?,1_(B | |
50 ?,1`(B ?,1a(B ?,1b(B ?,1c(B ?,1d(B ?,1e(B ?,1f(B ?,1g(B ?,1h(B ?,1i(B ?,1j(B ?,1k(B ?,1l(B ?,1m(B ?,1n(B ?,1o(B | |
51 ?,1p(B ?,1q(B ?,1r(B ?,1s(B ?,1t(B ?,1u(B ?,1v(B ?,1w(B ?,1x(B ?,1y(B ?,1z(B ?,1{(B ?,1|(B ?,1}(B ?,1~(B ?,2f(B ] | |
52 "Vietnamese VISCII decoding table.") | |
53 | |
54 (defvar viet-viscii-encode-table | |
55 (let ((table-lower (make-vector 128 0)) | |
56 (table-upper (make-vector 128 0)) | |
57 (i 0) | |
58 char-component) | |
59 (while (< i 256) | |
60 (setq char-component | |
61 (split-char (aref viet-viscii-decode-table i))) | |
62 (cond ((eq (car char-component) 'vietnamese-viscii-lower) | |
63 (aset table-lower (nth 1 char-component) i)) | |
64 ((eq (car char-component) 'vietnamese-viscii-upper) | |
65 (aset table-upper (nth 1 char-component) i))) | |
66 (setq i (1+ i))) | |
67 (cons table-lower table-upper)) | |
68 "Vietnamese VISCII encoding table. | |
69 Cons of tables for encoding lower-case chars and upper-case characters. | |
70 Both tables are indexed by the position code of Vietnamese characters.") | |
71 | |
72 (defvar viet-vscii-decode-table | |
73 [;; VSCII is a full 8-bit code. | |
74 0 ?,2z(B ?,2x(B 3 ?,2W(B ?,2X(B ?,2f(B 7 8 9 10 11 12 13 14 15 | |
75 16 ?,2Q(B ?,2_(B ?,2O(B ?,2V(B ?,2[(B ?,2}(B ?,2\(B 24 25 26 27 28 29 30 31 | |
76 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
77 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
78 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
80 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
81 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
82 ?,2`(B ?,2d(B ?,2c(B ?,2a(B ?,2U(B ?,2#(B ?,2'(B ?,2h(B ?,2k(B ?,2((B ?,2i(B ?,2)(B ?,2.(B ?,2l(B ?,2o(B ?,2n(B | |
83 ?,2m(B ?,28(B ?,2r(B ?,2v(B ?,2u(B ?,2s(B ?,2w(B ?,25(B ?,26(B ?,27(B ?,2^(B ?,2>(B ?,2~(B ?,2y(B ?,2|(B ?,2{(B | |
84 160 ?,2e(B ?,2b(B ?,2j(B ?,2t(B ?,2=(B ?,2_(B ?,2p(B ?,1e(B ?,1b(B ?,1j(B ?,1t(B ?,1>(B ?,1y(B ?,1p(B ?,2"(B | |
85 192 193 194 195 196 ?,1`(B ?,1d(B ?,1c(B ?,1a(B ?,1U(B ?,2F(B ?,1"(B ?,1F(B ?,1G(B ?,1!(B ?,2G(B | |
86 ?,2!(B ?,2%(B ?,2&(B ?,2g(B ?,2%(B ?,2+(B ?,1#(B ?,1%(B ?,1&(B ?,1g(B ?,1$(B ?,1'(B ?,1h(B ?,2,(B ?,1k(B ?,1((B | |
87 ?,1i(B ?,1)(B ?,1+(B ?,1,(B ?,1-(B ?,1*(B ?,1.(B ?,1l(B ?,1o(B ?,2-(B ?,2*(B ?,20(B ?,1n(B ?,1m(B ?,18(B ?,1r(B | |
88 ?,21(B ?,1v(B ?,1u(B ?,1s(B ?,1w(B ?,10(B ?,11(B ?,12(B ?,1/(B ?,15(B ?,16(B ?,17(B ?,1^(B ?,1>(B ?,1~(B ?,1y(B | |
89 ?,22(B ?,1|(B ?,1{(B ?,1z(B ?,1x(B ?,1W(B ?,1X(B ?,1f(B ?,1Q(B ?,1q(B ?,1O(B ?,1V(B ?,1[(B ?,1}(B ?,1\(B ?,2/(B] | |
90 "Vietnamese VSCII decoding table.") | |
91 | |
92 (defvar viet-vscii-encode-table | |
93 (let ((table-lower (make-vector 128 0)) | |
94 (table-upper (make-vector 128 0)) | |
95 (i 0) | |
96 char-component) | |
97 (while (< i 256) | |
98 (setq char-component | |
99 (split-char (aref viet-vscii-decode-table i))) | |
100 (cond ((eq (car char-component) 'vietnamese-viscii-lower) | |
101 (aset table-lower (nth 1 char-component) i)) | |
102 ((eq (car char-component) 'vietnamese-viscii-upper) | |
103 (aset table-upper (nth 1 char-component) i))) | |
104 (setq i (1+ i))) | |
105 (cons table-lower table-upper)) | |
106 "Vietnamese VSCII encoding table. | |
107 Cons of tables for encoding lower-case chars and upper-case characters. | |
108 Both tables are indexed by the position code of Vietnamese characters.") | |
109 | |
110 ) | |
111 | |
112 (define-ccl-program ccl-decode-viscii | |
113 `(3 | |
114 ((read r0) | |
115 (loop | |
116 (write-read-repeat r0 ,viet-viscii-decode-table)) | |
117 )) | |
118 "CCL program to decode VISCII 1.1") | |
119 | |
120 ;; Multibyte form of a Vietnamese character is as follows (3-byte): | |
121 ;; LEADING-CODE-PRIVATE-11 LEADING-CODE-EXTENDED-11 POSITION-CODE | |
122 ;; where LEADING-CODE-EXTENDED-11 for Vietnamese is | |
123 ;; `vietnamese-viscii-lower' or `vietnamese-viscii-upper'. | |
124 | |
125 (defvar leading-code-private-11 #x9E) | |
126 | |
127 (define-ccl-program ccl-encode-viscii | |
128 `(1 | |
129 ((read r0) | |
130 (loop | |
131 (if (r0 < 128) | |
132 ;; ASCII | |
133 (write-read-repeat r0) | |
134 ;; not ASCII | |
135 (if (r0 != ,leading-code-private-11) | |
136 ;; not Vietnamese | |
137 (write-read-repeat r0) | |
138 ((read-if (r0 == ,(charset-id 'vietnamese-viscii-lower)) | |
139 (;; Vietnamese lower | |
140 (read r0) | |
141 (r0 -= 128) | |
142 (write-read-repeat r0 ,(car viet-viscii-encode-table))) | |
143 (if (r0 == ,(charset-id 'vietnamese-viscii-upper)) | |
144 (;; Vietnamese upper | |
145 (read r0) | |
146 (r0 -= 128) | |
147 (write-read-repeat r0 ,(cdr viet-viscii-encode-table))) | |
148 ;; not Vietnamese | |
149 (write-read-repeat r0))))))))) | |
150 "CCL program to encode VISCII 1.1") | |
151 | |
152 (define-ccl-program ccl-encode-viscii-font | |
153 `(0 | |
154 ;; In: R0:vietnamese-viscii-lower/vietnamese-viscii-upper | |
155 ;; R1:position code | |
156 ;; Out: R1:font code point | |
157 (if (r0 == ,(charset-id 'vietnamese-viscii-lower)) | |
158 (r1 = r1 ,(car viet-viscii-encode-table)) | |
159 (r1 = r1 ,(cdr viet-viscii-encode-table))) | |
160 ) | |
161 "CCL program to encode Vietnamese chars to VISCII 1.1 font") | |
162 | |
163 (define-ccl-program ccl-decode-vscii | |
164 `(3 | |
165 ((read r0) | |
166 (loop | |
167 (write-read-repeat r0 ,viet-vscii-decode-table)) | |
168 )) | |
169 "CCL program to decode VSCII-1.") | |
170 | |
171 (define-ccl-program ccl-encode-vscii | |
172 `(1 | |
173 ((read r0) | |
174 (loop | |
175 (if (r0 < 128) | |
176 ;; ASCII | |
177 (write-read-repeat r0) | |
178 ;; not ASCII | |
179 (if (r0 != ,leading-code-private-11) | |
180 ;; not Vietnamese | |
181 (write-read-repeat r0) | |
182 (read-if (r0 == ,(charset-id 'vietnamese-viscii-lower)) | |
183 (;; Vietnamese lower | |
184 (read r0) | |
185 (r0 -= 128) | |
186 (write-read-repeat r0 ,(car viet-vscii-encode-table))) | |
187 (if (r0 == ,(charset-id 'vietnamese-viscii-upper)) | |
188 (;; Vietnamese upper | |
189 (read r0) | |
190 (r0 -= 128) | |
191 (write-read-repeat r0 ,(cdr viet-vscii-encode-table))) | |
192 ;; not Vietnamese | |
193 (write-read-repeat r0)))))))) | |
194 "CCL program to encode VSCII-1.") | |
195 | |
196 (define-ccl-program ccl-encode-vscii-font | |
197 `(0 | |
198 ;; In: R0:vietnamese-viscii-lower/vietnamese-viscii-upper | |
199 ;; R1:position code | |
200 ;; Out: R1:font code point | |
201 (if (r0 == ,(charset-id 'vietnamese-viscii-lower)) | |
202 (r1 = r1 ,(car viet-vscii-encode-table)) | |
203 (r1 = r1 ,(cdr viet-vscii-encode-table))) | |
204 ) | |
205 "CCL program to encode Vietnamese chars to VSCII-1 font.") | |
206 | |
207 | |
208 (make-coding-system | |
209 'viscii 'ccl | |
210 "Coding-system used for VISCII 1.1." | |
211 `(mnemonic "VISCII" | |
212 decode ,ccl-decode-viscii | |
213 encode ,ccl-encode-viscii)) | |
214 | |
215 ;; it is not correct, but XEmacs doesn't have `ccl' category... | |
216 (coding-system-put 'viscii 'category 'iso-8-1) | |
217 | |
218 ;; (make-coding-system | |
219 ;; 'vietnamese-viscii 4 ?V | |
220 ;; "8-bit encoding for Vietnamese VISCII 1.1 (MIME:VISCII)" | |
221 ;; '(ccl-decode-viscii . ccl-encode-viscii) | |
222 ;; '((safe-charsets ascii vietnamese-viscii-lower vietnamese-viscii-upper) | |
223 ;; (mime-charset . viscii) | |
224 ;; (valid-codes (0 . 255)))) | |
225 | |
226 ;; (define-coding-system-alias 'viscii 'vietnamese-viscii) | |
227 | |
228 (make-coding-system | |
229 'vscii 'ccl | |
230 "Coding-system used for VSCII 1.1." | |
231 `(mnemonic "VSCII" | |
232 decode ,ccl-decode-vscii | |
233 encode ,ccl-encode-vscii)) | |
234 | |
235 ;; (make-coding-system | |
236 ;; 'vietnamese-vscii 4 ?v | |
237 ;; "8-bit encoding for Vietnamese VSCII-1" | |
238 ;; '(ccl-decode-vscii . ccl-encode-vscii) | |
239 ;; '((safe-charsets ascii vietnamese-viscii-lower vietnamese-viscii-upper) | |
240 ;; (valid-codes (0 . 255)))) | |
241 | |
242 ;; (define-coding-system-alias 'vscii 'vietnamese-vscii) | |
243 | |
244 (make-coding-system | |
245 'viqr 'no-conversion | |
246 "Coding-system used for VIQR." | |
247 '(mnemonic "VIQR" | |
248 eol-type lf | |
249 post-read-conversion viqr-post-read-conversion | |
250 pre-write-conversion viqr-pre-write-conversion)) | |
251 | |
252 ;; (make-coding-system | |
253 ;; 'vietnamese-viqr 0 ?q | |
254 ;; "Vietnamese latin transcription (VIQR)" | |
255 ;; nil | |
256 ;; '((safe-charsets ascii vietnamese-viscii-lower vietnamese-viscii-upper) | |
257 ;; (post-read-conversion . viqr-post-read-conversion) | |
258 ;; (pre-write-conversion . viqr-pre-write-conversion) | |
259 ;; (charset-origin-alist | |
260 ;; (vietnamese-viscii-lower "VISCII" viet-encode-viscii-char) | |
261 ;; (vietnamese-viscii-upper "VISCII" viet-encode-viscii-char)))) | |
262 | |
263 ;; (define-coding-system-alias 'viqr 'vietnamese-viqr) | |
264 | |
265 ;; For VISCII users | |
266 (set-charset-ccl-program 'vietnamese-viscii-lower | |
267 ccl-encode-viscii-font) | |
268 (set-charset-ccl-program 'vietnamese-viscii-upper | |
269 ccl-encode-viscii-font) | |
270 ;; For VSCII users | |
271 (set-charset-ccl-program 'vietnamese-viscii-lower ccl-encode-vscii-font) | |
272 (set-charset-ccl-program 'vietnamese-viscii-upper ccl-encode-vscii-font) | |
273 | |
274 ;; (setq font-ccl-encoder-alist | |
275 ;; (cons (cons "viscii" ccl-encode-viscii-font) font-ccl-encoder-alist)) | |
276 | |
277 ;; (setq font-ccl-encoder-alist | |
278 ;; (cons (cons "vscii" ccl-encode-vscii-font) font-ccl-encoder-alist)) | |
279 | |
280 ;; (defvar viet-viscii-nonascii-translation-table | |
281 ;; (make-translation-table-from-vector viet-viscii-decode-table) | |
282 ;; "Value of `nonascii-translation-table' in Vietnamese language environment.") | |
283 | |
284 (set-language-info-alist | |
285 "Vietnamese" '((charset vietnamese-viscii-lower vietnamese-viscii-upper) | |
286 (coding-system viscii vscii viqr) | |
287 (coding-priority viscii) | |
288 (input-method . "vietnamese-viqr") | |
289 (features viet-util) | |
290 (sample-text . "Vietnamese (Ti,1*(Bng Vi,1.(Bt) Ch,1`(Bo b,1U(Bn") | |
291 (documentation . "\ | |
292 For Vietnamese, Emacs uses special charasets internally. | |
293 They can be decoded from and encoded to VISCC, VSCII, and VIQR. | |
294 Current setting put higher priority to the coding system VISCII than VSCII. | |
295 If you prefer VSCII, please do: (prefer-coding-system 'vietnamese-vscii)") | |
296 )) | |
297 | |
298 ;;; vietnamese.el ends here |