428
|
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
|
778
|
32 ;; Vietnamese VISCII. VISCII is 1-byte character set which contains
|
|
33 ;; more than 96 characters. Since Emacs can't handle it as one
|
|
34 ;; character set, it is divided into two: lower case letters and upper
|
|
35 ;; case letters.
|
|
36 (make-charset 'vietnamese-viscii-lower "VISCII1.1 lower-case"
|
|
37 '(dimension
|
|
38 1
|
|
39 registry "VISCII1.1"
|
|
40 chars 96
|
|
41 columns 1
|
|
42 direction l2r
|
|
43 final ?1
|
|
44 graphic 1
|
|
45 short-name "VISCII lower"
|
|
46 long-name "VISCII lower-case"
|
|
47 ))
|
|
48
|
|
49 (make-charset 'vietnamese-viscii-upper "VISCII1.1 upper-case"
|
|
50 '(dimension
|
|
51 1
|
|
52 registry "VISCII1.1"
|
|
53 chars 96
|
|
54 columns 1
|
|
55 direction l2r
|
|
56 final ?2
|
|
57 graphic 1
|
|
58 short-name "VISCII upper"
|
|
59 long-name "VISCII upper-case"
|
|
60 ))
|
|
61
|
|
62 (modify-syntax-entry 'vietnamese-viscii-lower "w")
|
|
63 (modify-syntax-entry 'vietnamese-viscii-upper "w")
|
|
64
|
|
65 (define-category ?v "Vietnamese character.")
|
|
66 (modify-category-entry 'vietnamese-viscii-lower ?v)
|
|
67 (modify-category-entry 'vietnamese-viscii-upper ?v)
|
|
68
|
428
|
69 (eval-and-compile
|
|
70
|
|
71 (defvar viet-viscii-decode-table
|
|
72 [;; VISCII is a full 8-bit code.
|
|
73 0 1 ?,2F(B 3 4 ?,2G(B ?,2g(B 7 8 9 10 11 12 13 14 15
|
|
74 16 17 18 19 ?,2V(B 21 22 23 24 ?,2[(B 26 27 28 29 ?,2\(B 31
|
|
75 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
|
76 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
|
77 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
|
78 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
|
79 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
|
80 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
|
81 ?,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
|
|
82 ?,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
|
|
83 ?,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
|
|
84 ?,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
|
|
85 ?,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
|
|
86 ?,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
|
|
87 ?,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
|
|
88 ?,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 ]
|
|
89 "Vietnamese VISCII decoding table.")
|
|
90
|
|
91 (defvar viet-viscii-encode-table
|
|
92 (let ((table-lower (make-vector 128 0))
|
|
93 (table-upper (make-vector 128 0))
|
|
94 (i 0)
|
|
95 char-component)
|
|
96 (while (< i 256)
|
|
97 (setq char-component
|
|
98 (split-char (aref viet-viscii-decode-table i)))
|
|
99 (cond ((eq (car char-component) 'vietnamese-viscii-lower)
|
|
100 (aset table-lower (nth 1 char-component) i))
|
|
101 ((eq (car char-component) 'vietnamese-viscii-upper)
|
|
102 (aset table-upper (nth 1 char-component) i)))
|
|
103 (setq i (1+ i)))
|
|
104 (cons table-lower table-upper))
|
|
105 "Vietnamese VISCII encoding table.
|
|
106 Cons of tables for encoding lower-case chars and upper-case characters.
|
|
107 Both tables are indexed by the position code of Vietnamese characters.")
|
|
108
|
|
109 (defvar viet-vscii-decode-table
|
|
110 [;; VSCII is a full 8-bit code.
|
|
111 0 ?,2z(B ?,2x(B 3 ?,2W(B ?,2X(B ?,2f(B 7 8 9 10 11 12 13 14 15
|
|
112 16 ?,2Q(B ?,2_(B ?,2O(B ?,2V(B ?,2[(B ?,2}(B ?,2\(B 24 25 26 27 28 29 30 31
|
|
113 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
|
114 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
|
115 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
|
116 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
|
117 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
|
118 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
|
119 ?,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
|
|
120 ?,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
|
|
121 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
|
|
122 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
|
|
123 ?,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
|
|
124 ?,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
|
|
125 ?,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
|
|
126 ?,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]
|
|
127 "Vietnamese VSCII decoding table.")
|
|
128
|
|
129 (defvar viet-vscii-encode-table
|
|
130 (let ((table-lower (make-vector 128 0))
|
|
131 (table-upper (make-vector 128 0))
|
|
132 (i 0)
|
|
133 char-component)
|
|
134 (while (< i 256)
|
|
135 (setq char-component
|
|
136 (split-char (aref viet-vscii-decode-table i)))
|
|
137 (cond ((eq (car char-component) 'vietnamese-viscii-lower)
|
|
138 (aset table-lower (nth 1 char-component) i))
|
|
139 ((eq (car char-component) 'vietnamese-viscii-upper)
|
|
140 (aset table-upper (nth 1 char-component) i)))
|
|
141 (setq i (1+ i)))
|
|
142 (cons table-lower table-upper))
|
|
143 "Vietnamese VSCII encoding table.
|
|
144 Cons of tables for encoding lower-case chars and upper-case characters.
|
|
145 Both tables are indexed by the position code of Vietnamese characters.")
|
|
146
|
|
147 )
|
|
148
|
|
149 (define-ccl-program ccl-decode-viscii
|
|
150 `(3
|
|
151 ((read r0)
|
|
152 (loop
|
|
153 (write-read-repeat r0 ,viet-viscii-decode-table))
|
|
154 ))
|
|
155 "CCL program to decode VISCII 1.1")
|
|
156
|
|
157 ;; Multibyte form of a Vietnamese character is as follows (3-byte):
|
|
158 ;; LEADING-CODE-PRIVATE-11 LEADING-CODE-EXTENDED-11 POSITION-CODE
|
|
159 ;; where LEADING-CODE-EXTENDED-11 for Vietnamese is
|
|
160 ;; `vietnamese-viscii-lower' or `vietnamese-viscii-upper'.
|
|
161
|
|
162 (defvar leading-code-private-11 #x9E)
|
|
163
|
|
164 (define-ccl-program ccl-encode-viscii
|
|
165 `(1
|
|
166 ((read r0)
|
|
167 (loop
|
|
168 (if (r0 < 128)
|
|
169 ;; ASCII
|
|
170 (write-read-repeat r0)
|
|
171 ;; not ASCII
|
|
172 (if (r0 != ,leading-code-private-11)
|
|
173 ;; not Vietnamese
|
|
174 (write-read-repeat r0)
|
|
175 ((read-if (r0 == ,(charset-id 'vietnamese-viscii-lower))
|
|
176 (;; Vietnamese lower
|
|
177 (read r0)
|
|
178 (r0 -= 128)
|
|
179 (write-read-repeat r0 ,(car viet-viscii-encode-table)))
|
|
180 (if (r0 == ,(charset-id 'vietnamese-viscii-upper))
|
|
181 (;; Vietnamese upper
|
|
182 (read r0)
|
|
183 (r0 -= 128)
|
|
184 (write-read-repeat r0 ,(cdr viet-viscii-encode-table)))
|
|
185 ;; not Vietnamese
|
|
186 (write-read-repeat r0)))))))))
|
|
187 "CCL program to encode VISCII 1.1")
|
|
188
|
|
189 (define-ccl-program ccl-encode-viscii-font
|
|
190 `(0
|
|
191 ;; In: R0:vietnamese-viscii-lower/vietnamese-viscii-upper
|
|
192 ;; R1:position code
|
|
193 ;; Out: R1:font code point
|
|
194 (if (r0 == ,(charset-id 'vietnamese-viscii-lower))
|
|
195 (r1 = r1 ,(car viet-viscii-encode-table))
|
|
196 (r1 = r1 ,(cdr viet-viscii-encode-table)))
|
|
197 )
|
|
198 "CCL program to encode Vietnamese chars to VISCII 1.1 font")
|
|
199
|
|
200 (define-ccl-program ccl-decode-vscii
|
|
201 `(3
|
|
202 ((read r0)
|
|
203 (loop
|
|
204 (write-read-repeat r0 ,viet-vscii-decode-table))
|
|
205 ))
|
|
206 "CCL program to decode VSCII-1.")
|
|
207
|
|
208 (define-ccl-program ccl-encode-vscii
|
|
209 `(1
|
|
210 ((read r0)
|
|
211 (loop
|
|
212 (if (r0 < 128)
|
|
213 ;; ASCII
|
|
214 (write-read-repeat r0)
|
|
215 ;; not ASCII
|
|
216 (if (r0 != ,leading-code-private-11)
|
|
217 ;; not Vietnamese
|
|
218 (write-read-repeat r0)
|
|
219 (read-if (r0 == ,(charset-id 'vietnamese-viscii-lower))
|
|
220 (;; Vietnamese lower
|
|
221 (read r0)
|
|
222 (r0 -= 128)
|
|
223 (write-read-repeat r0 ,(car viet-vscii-encode-table)))
|
|
224 (if (r0 == ,(charset-id 'vietnamese-viscii-upper))
|
|
225 (;; Vietnamese upper
|
|
226 (read r0)
|
|
227 (r0 -= 128)
|
|
228 (write-read-repeat r0 ,(cdr viet-vscii-encode-table)))
|
|
229 ;; not Vietnamese
|
|
230 (write-read-repeat r0))))))))
|
|
231 "CCL program to encode VSCII-1.")
|
|
232
|
|
233 (define-ccl-program ccl-encode-vscii-font
|
|
234 `(0
|
|
235 ;; In: R0:vietnamese-viscii-lower/vietnamese-viscii-upper
|
|
236 ;; R1:position code
|
|
237 ;; Out: R1:font code point
|
|
238 (if (r0 == ,(charset-id 'vietnamese-viscii-lower))
|
|
239 (r1 = r1 ,(car viet-vscii-encode-table))
|
|
240 (r1 = r1 ,(cdr viet-vscii-encode-table)))
|
|
241 )
|
|
242 "CCL program to encode Vietnamese chars to VSCII-1 font.")
|
|
243
|
|
244
|
|
245 (make-coding-system
|
|
246 'viscii 'ccl
|
771
|
247 "VISCII 1.1 (Vietnamese)"
|
428
|
248 `(mnemonic "VISCII"
|
444
|
249 decode ccl-decode-viscii
|
|
250 encode ccl-encode-viscii))
|
428
|
251
|
|
252 ;; it is not correct, but XEmacs doesn't have `ccl' category...
|
|
253 (coding-system-put 'viscii 'category 'iso-8-1)
|
|
254
|
|
255 ;; (make-coding-system
|
|
256 ;; 'vietnamese-viscii 4 ?V
|
|
257 ;; "8-bit encoding for Vietnamese VISCII 1.1 (MIME:VISCII)"
|
|
258 ;; '(ccl-decode-viscii . ccl-encode-viscii)
|
|
259 ;; '((safe-charsets ascii vietnamese-viscii-lower vietnamese-viscii-upper)
|
|
260 ;; (mime-charset . viscii)
|
|
261 ;; (valid-codes (0 . 255))))
|
|
262
|
|
263 ;; (define-coding-system-alias 'viscii 'vietnamese-viscii)
|
|
264
|
|
265 (make-coding-system
|
|
266 'vscii 'ccl
|
771
|
267 "VSCII 1.1 (Vietnamese)"
|
428
|
268 `(mnemonic "VSCII"
|
444
|
269 decode ccl-decode-vscii
|
|
270 encode ccl-encode-vscii))
|
428
|
271
|
|
272 ;; (make-coding-system
|
|
273 ;; 'vietnamese-vscii 4 ?v
|
|
274 ;; "8-bit encoding for Vietnamese VSCII-1"
|
|
275 ;; '(ccl-decode-vscii . ccl-encode-vscii)
|
|
276 ;; '((safe-charsets ascii vietnamese-viscii-lower vietnamese-viscii-upper)
|
|
277 ;; (valid-codes (0 . 255))))
|
|
278
|
|
279 ;; (define-coding-system-alias 'vscii 'vietnamese-vscii)
|
|
280
|
|
281 (make-coding-system
|
|
282 'viqr 'no-conversion
|
771
|
283 "VIQR (Vietnamese)"
|
428
|
284 '(mnemonic "VIQR"
|
|
285 eol-type lf
|
|
286 post-read-conversion viqr-post-read-conversion
|
|
287 pre-write-conversion viqr-pre-write-conversion))
|
|
288
|
|
289 ;; (make-coding-system
|
|
290 ;; 'vietnamese-viqr 0 ?q
|
|
291 ;; "Vietnamese latin transcription (VIQR)"
|
|
292 ;; nil
|
|
293 ;; '((safe-charsets ascii vietnamese-viscii-lower vietnamese-viscii-upper)
|
|
294 ;; (post-read-conversion . viqr-post-read-conversion)
|
|
295 ;; (pre-write-conversion . viqr-pre-write-conversion)
|
|
296 ;; (charset-origin-alist
|
|
297 ;; (vietnamese-viscii-lower "VISCII" viet-encode-viscii-char)
|
|
298 ;; (vietnamese-viscii-upper "VISCII" viet-encode-viscii-char))))
|
|
299
|
|
300 ;; (define-coding-system-alias 'viqr 'vietnamese-viqr)
|
|
301
|
|
302 ;; For VISCII users
|
|
303 (set-charset-ccl-program 'vietnamese-viscii-lower
|
444
|
304 'ccl-encode-viscii-font)
|
428
|
305 (set-charset-ccl-program 'vietnamese-viscii-upper
|
444
|
306 'ccl-encode-viscii-font)
|
428
|
307 ;; For VSCII users
|
444
|
308 (set-charset-ccl-program 'vietnamese-viscii-lower 'ccl-encode-vscii-font)
|
|
309 (set-charset-ccl-program 'vietnamese-viscii-upper 'ccl-encode-vscii-font)
|
428
|
310
|
|
311 ;; (setq font-ccl-encoder-alist
|
|
312 ;; (cons (cons "viscii" ccl-encode-viscii-font) font-ccl-encoder-alist))
|
|
313
|
|
314 ;; (setq font-ccl-encoder-alist
|
|
315 ;; (cons (cons "vscii" ccl-encode-vscii-font) font-ccl-encoder-alist))
|
|
316
|
|
317 ;; (defvar viet-viscii-nonascii-translation-table
|
|
318 ;; (make-translation-table-from-vector viet-viscii-decode-table)
|
|
319 ;; "Value of `nonascii-translation-table' in Vietnamese language environment.")
|
|
320
|
|
321 (set-language-info-alist
|
|
322 "Vietnamese" '((charset vietnamese-viscii-lower vietnamese-viscii-upper)
|
|
323 (coding-system viscii vscii viqr)
|
|
324 (coding-priority viscii)
|
771
|
325 (locale "vietnamese" "vi")
|
428
|
326 (input-method . "vietnamese-viqr")
|
|
327 (features viet-util)
|
|
328 (sample-text . "Vietnamese (Ti,1*(Bng Vi,1.(Bt) Ch,1`(Bo b,1U(Bn")
|
|
329 (documentation . "\
|
440
|
330 For Vietnamese, Emacs uses special charsets internally.
|
428
|
331 They can be decoded from and encoded to VISCC, VSCII, and VIQR.
|
|
332 Current setting put higher priority to the coding system VISCII than VSCII.
|
|
333 If you prefer VSCII, please do: (prefer-coding-system 'vietnamese-vscii)")
|
|
334 ))
|
|
335
|
|
336 ;;; vietnamese.el ends here
|