412
|
1 ;;; vietnamese.el --- Support for Vietnamese
|
398
|
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.
|
412
|
36 0 1 ?.2NF 3 4 ?NG ?Ng 7 8 9 10 11 12 13 14 15
|
|
37 16 17 18 19 ?.2NV 21 22 23 24 ?N[ 26 27 28 29 ?N\ 31
|
398
|
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
|
412
|
44 ?.2NU ?N! ?N" ?N# ?N$ ?N% ?N& ?N' ?N( ?N) ?N* ?N+ ?N, ?N- ?N. ?N/
|
|
45 ?.2N0 ?N1 ?N2 ?N5 ?N~ ?N> ?N6 ?N7 ?N8 ?Nv ?Nw ?No ?N| ?N{ ?Nx ?NO
|
|
46 ?.2Nu ?.1N! ?N" ?N# ?N$ ?N% ?N& ?N' ?N( ?N) ?N* ?N+ ?N, ?N- ?N. ?N/
|
|
47 ?.1N0 ?N1 ?N2 ?.2N^ ?N= ?.1N5 ?N6 ?N7 ?N8 ?.2Nq ?NQ ?NW ?NX ?.1N= ?N> ?.2N_
|
|
48 ?.2N` ?Na ?Nb ?Nc ?Nd ?Ne ?.1NF ?NG ?.2Nh ?Ni ?Nj ?Nk ?Nl ?Nm ?Nn ?.1NO
|
|
49 ?.2Np ?.1NQ ?.2Nr ?Ns ?Nt ?.1NU ?NV ?NW ?NX ?.2Ny ?Nz ?.1N[ ?N\ ?.2N} ?.1N^ ?N_
|
|
50 ?.1N` ?Na ?Nb ?Nc ?Nd ?Ne ?Nf ?Ng ?Nh ?Ni ?Nj ?Nk ?Nl ?Nm ?Nn ?No
|
|
51 ?.1Np ?Nq ?Nr ?Ns ?Nt ?Nu ?Nv ?Nw ?Nx ?Ny ?Nz ?N{ ?N| ?N} ?N~ ?.2Nf ]
|
398
|
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
|
412
|
61 (split-char-or-char-int (aref viet-viscii-decode-table i)))
|
398
|
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.
|
412
|
74 0 ?.2Nz ?Nx 3 ?NW ?NX ?Nf 7 8 9 10 11 12 13 14 15
|
|
75 16 ?.2NQ ?N_ ?NO ?NV ?N[ ?N} ?N\ 24 25 26 27 28 29 30 31
|
398
|
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
|
412
|
82 ?.2N` ?Nd ?Nc ?Na ?NU ?N# ?N' ?Nh ?Nk ?N( ?Ni ?N) ?N. ?Nl ?No ?Nn
|
|
83 ?.2Nm ?N8 ?Nr ?Nv ?Nu ?Ns ?Nw ?N5 ?N6 ?N7 ?N^ ?N> ?N~ ?Ny ?N| ?N{
|
|
84 160 ?.2Ne ?Nb ?Nj ?Nt ?N= ?N_ ?Np ?.1Ne ?Nb ?Nj ?Nt ?N> ?Ny ?Np ?.2N"
|
|
85 192 193 194 195 196 ?.1N` ?Nd ?Nc ?Na ?NU ?.2NF ?.1N" ?NF ?NG ?N! ?.2NG
|
|
86 ?.2N! ?N% ?N& ?Ng ?N% ?N+ ?.1N# ?N% ?N& ?Ng ?N$ ?N' ?Nh ?.2N, ?.1Nk ?N(
|
|
87 ?.1Ni ?N) ?N+ ?N, ?N- ?N* ?N. ?Nl ?No ?.2N- ?N* ?N0 ?.1Nn ?Nm ?N8 ?Nr
|
|
88 ?.2N1 ?.1Nv ?Nu ?Ns ?Nw ?N0 ?N1 ?N2 ?N/ ?N5 ?N6 ?N7 ?N^ ?N> ?N~ ?Ny
|
|
89 ?.2N2 ?.1N| ?N{ ?Nz ?Nx ?NW ?NX ?Nf ?NQ ?Nq ?NO ?NV ?N[ ?N} ?N\ ?.2N/]
|
398
|
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
|
412
|
99 (split-char-or-char-int (aref viet-vscii-decode-table i)))
|
398
|
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)
|
412
|
191 (write-read-repeat r0 ,(cdr viet-viscii-encode-table)))
|
398
|
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 ;; (make-coding-system
|
|
216 ;; 'vietnamese-viscii 4 ?V
|
|
217 ;; "8-bit encoding for Vietnamese VISCII 1.1 (MIME:VISCII)"
|
412
|
218 ;; (cons ccl-decode-viscii ccl-encode-viscii))
|
398
|
219
|
|
220 ;; (define-coding-system-alias 'viscii 'vietnamese-viscii)
|
|
221
|
|
222 (make-coding-system
|
|
223 'vscii 'ccl
|
|
224 "Coding-system used for VSCII 1.1."
|
|
225 `(mnemonic "VSCII"
|
|
226 decode ,ccl-decode-vscii
|
|
227 encode ,ccl-encode-vscii))
|
|
228
|
|
229 ;; (make-coding-system
|
|
230 ;; 'vietnamese-vscii 4 ?v
|
|
231 ;; "8-bit encoding for Vietnamese VSCII-1"
|
412
|
232 ;; (cons ccl-decode-vscii ccl-encode-vscii))
|
398
|
233
|
|
234 ;; (define-coding-system-alias 'vscii 'vietnamese-vscii)
|
|
235
|
|
236 (make-coding-system
|
|
237 'viqr 'no-conversion
|
|
238 "Coding-system used for VIQR."
|
|
239 '(mnemonic "VIQR"
|
|
240 eol-type lf
|
|
241 post-read-conversion viqr-post-read-conversion
|
|
242 pre-write-conversion viqr-pre-write-conversion))
|
|
243
|
|
244 ;; (make-coding-system
|
|
245 ;; 'vietnamese-viqr 0 ?q
|
|
246 ;; "Vietnamese latin transcription (VIQR)"
|
412
|
247 ;; nil)
|
|
248 ;; (put 'vietnamese-viqr 'post-read-conversion 'viqr-post-read-conversion)
|
|
249 ;; (put 'vietnamese-viqr 'pre-write-conversion 'viqr-pre-write-conversion)
|
398
|
250
|
|
251 ;; (define-coding-system-alias 'viqr 'vietnamese-viqr)
|
|
252
|
|
253 ;; For VISCII users
|
|
254 (set-charset-ccl-program 'vietnamese-viscii-lower
|
|
255 ccl-encode-viscii-font)
|
|
256 (set-charset-ccl-program 'vietnamese-viscii-upper
|
|
257 ccl-encode-viscii-font)
|
|
258 ;; For VSCII users
|
|
259 (set-charset-ccl-program 'vietnamese-viscii-lower ccl-encode-vscii-font)
|
|
260 (set-charset-ccl-program 'vietnamese-viscii-upper ccl-encode-vscii-font)
|
|
261
|
|
262 ;; (setq font-ccl-encoder-alist
|
|
263 ;; (cons (cons "viscii" ccl-encode-viscii-font) font-ccl-encoder-alist))
|
|
264
|
|
265 ;; (setq font-ccl-encoder-alist
|
|
266 ;; (cons (cons "vscii" ccl-encode-vscii-font) font-ccl-encoder-alist))
|
|
267
|
|
268 (set-language-info-alist
|
412
|
269 "Vietnamese" '((setup-function . setup-vietnamese-environment)
|
|
270 (charset . (vietnamese-viscii-lower
|
|
271 vietnamese-viscii-upper))
|
|
272 (coding-system . (viscii vscii viqr))
|
|
273 (sample-text . "Vietnamese (Ti.1N*ng ViN.t) ChN`o bNUn")
|
398
|
274 (documentation . "\
|
412
|
275 For Vietnamese, Emacs uses special charasets internally.
|
|
276 They can be decoded from and encoded to VISCC, VSCII, and VIQR.")
|
398
|
277 ))
|
|
278
|
|
279 ;;; vietnamese.el ends here
|