Mercurial > emacs
comparison lisp/language/vietnamese.el @ 29452:86a268b661c2
Remove eval-when-compile.
(viet-viscii-nonascii-translation-table): Define it as a
translation table made from viet-viscii-decode-table.
(viet-viscii-encode-table): Define it as a translation table made
from the reverse map of above.
(viet-vscii-nonascii-translation-table): Define it as a
translation table made from viet-vscii-decode-table.
(viet-vscii-encode-table): Define it as a translation table made
from the reverse map of above.
(ccl-decode-viscii): Use translate-character.
(ccl-encode-viscii, ccl-encode-viscii-font)
(ccl-decode-vscii, ccl-encode-vscii, ccl-encode-vscii-font):
Likewize.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Tue, 06 Jun 2000 02:09:30 +0000 |
parents | fd56586afd85 |
children | 6d966e8b4bbe |
comparison
equal
deleted
inserted
replaced
29451:44ecae4ce8e7 | 29452:86a268b661c2 |
---|---|
26 | 26 |
27 ;; For Vietnames, the character sets VISCII and VSCII are supported. | 27 ;; For Vietnames, the character sets VISCII and VSCII are supported. |
28 | 28 |
29 ;;; Code: | 29 ;;; Code: |
30 | 30 |
31 (eval-and-compile | |
32 | |
33 (defvar viet-viscii-decode-table | 31 (defvar viet-viscii-decode-table |
34 [;; VISCII is a full 8-bit code. | 32 [;; VISCII is a full 8-bit code. |
35 0 1 ?,2F(B 3 4 ?,2G(B ?,2g(B 7 8 9 10 11 12 13 14 15 | 33 0 1 ?,2F(B 3 4 ?,2G(B ?,2g(B 7 8 9 10 11 12 13 14 15 |
36 16 17 18 19 ?,2V(B 21 22 23 24 ?,2[(B 26 27 28 29 ?,2\(B 31 | 34 16 17 18 19 ?,2V(B 21 22 23 24 ?,2[(B 26 27 28 29 ?,2\(B 31 |
37 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | 35 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
48 ?,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 | 46 ?,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 |
49 ?,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 | 47 ?,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 |
50 ?,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 ] | 48 ?,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 ] |
51 "Vietnamese VISCII decoding table.") | 49 "Vietnamese VISCII decoding table.") |
52 | 50 |
53 (defvar viet-viscii-encode-table | 51 (let ((table (make-translation-table-from-vector viet-viscii-decode-table))) |
54 (let ((table-lower (make-vector 128 0)) | 52 (define-translation-table 'viet-viscii-nonascii-translation-table table) |
55 (table-upper (make-vector 128 0)) | 53 (define-translation-table 'viet-viscii-encode-table |
56 (i 0) | 54 (char-table-extra-slot table 0))) |
57 char-component) | |
58 (while (< i 256) | |
59 (setq char-component (split-char (aref viet-viscii-decode-table i))) | |
60 (cond ((eq (car char-component) 'vietnamese-viscii-lower) | |
61 (aset table-lower (nth 1 char-component) i)) | |
62 ((eq (car char-component) 'vietnamese-viscii-upper) | |
63 (aset table-upper (nth 1 char-component) i))) | |
64 (setq i (1+ i))) | |
65 (cons table-lower table-upper)) | |
66 "Vietnamese VISCII encoding table. | |
67 Cons of tables for encoding lower-case chars and upper-case characters. | |
68 Both tables are indexed by the position code of Vietnamese characters.") | |
69 | 55 |
70 (defvar viet-vscii-decode-table | 56 (defvar viet-vscii-decode-table |
71 [;; VSCII is a full 8-bit code. | 57 [;; VSCII is a full 8-bit code. |
72 0 ?,2z(B ?,2x(B 3 ?,2W(B ?,2X(B ?,2f(B 7 8 9 10 11 12 13 14 15 | 58 0 ?,2z(B ?,2x(B 3 ?,2W(B ?,2X(B ?,2f(B 7 8 9 10 11 12 13 14 15 |
73 16 ?,2Q(B ?,2_(B ?,2O(B ?,2V(B ?,2[(B ?,2}(B ?,2\(B 24 25 26 27 28 29 30 31 | 59 16 ?,2Q(B ?,2_(B ?,2O(B ?,2V(B ?,2[(B ?,2}(B ?,2\(B 24 25 26 27 28 29 30 31 |
85 ?,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 | 71 ?,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 |
86 ?,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 | 72 ?,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 |
87 ?,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] | 73 ?,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] |
88 "Vietnamese VSCII decoding table.") | 74 "Vietnamese VSCII decoding table.") |
89 | 75 |
90 (defvar viet-vscii-encode-table | 76 (let ((table (make-translation-table-from-vector viet-vscii-decode-table))) |
91 (let ((table-lower (make-vector 128 0)) | 77 (define-translation-table 'viet-vscii-nonascii-translation-table table) |
92 (table-upper (make-vector 128 0)) | 78 (define-translation-table 'viet-vscii-encode-table |
93 (i 0) | 79 (char-table-extra-slot table 0))) |
94 char-component) | |
95 (while (< i 256) | |
96 (setq char-component (split-char (aref viet-vscii-decode-table i))) | |
97 (cond ((eq (car char-component) 'vietnamese-viscii-lower) | |
98 (aset table-lower (nth 1 char-component) i)) | |
99 ((eq (car char-component) 'vietnamese-viscii-upper) | |
100 (aset table-upper (nth 1 char-component) i))) | |
101 (setq i (1+ i))) | |
102 (cons table-lower table-upper)) | |
103 "Vietnamese VSCII encoding table. | |
104 Cons of tables for encoding lower-case chars and upper-case characters. | |
105 Both tables are indexed by the position code of Vietnamese characters.") | |
106 | |
107 ) | |
108 | 80 |
109 (define-ccl-program ccl-decode-viscii | 81 (define-ccl-program ccl-decode-viscii |
110 `(3 | 82 `(3 |
111 ((read r0) | 83 ((loop |
112 (loop | 84 (r0 = 0) |
113 (write-read-repeat r0 ,viet-viscii-decode-table)) | 85 (read r1) |
114 )) | 86 (translate-character viet-viscii-nonascii-translation-table r0 r1) |
87 (write-multibyte-character r0 r1) | |
88 (repeat)))) | |
115 "CCL program to decode VISCII 1.1") | 89 "CCL program to decode VISCII 1.1") |
116 | |
117 ;; Multibyte form of a Vietnamese character is as follows (3-byte): | |
118 ;; LEADING-CODE-PRIVATE-11 LEADING-CODE-EXTENDED-11 POSITION-CODE | |
119 ;; where LEADING-CODE-EXTENDED-11 for Vietnamese is | |
120 ;; `vietnamese-viscii-lower' or `vietnamese-viscii-upper'. | |
121 | 90 |
122 (define-ccl-program ccl-encode-viscii | 91 (define-ccl-program ccl-encode-viscii |
123 `(1 | 92 `(1 |
124 ((read r0) | 93 ((loop |
125 (loop | 94 (read-multibyte-character r0 r1) |
126 (if (r0 < 128) | 95 (translate-character viet-viscii-encode-table r0 r1) |
127 ;; ASCII | 96 (write-repeat r1)))) |
128 (write-read-repeat r0) | |
129 ;; not ASCII | |
130 (if (r0 != ,leading-code-private-11) | |
131 ;; not Vietnamese | |
132 (write-read-repeat r0) | |
133 ((read-if (r0 == ,(charset-id 'vietnamese-viscii-lower)) | |
134 (;; Vietnamese lower | |
135 (read r0) | |
136 (r0 -= 128) | |
137 (write-read-repeat r0 ,(car viet-viscii-encode-table))) | |
138 (if (r0 == ,(charset-id 'vietnamese-viscii-upper)) | |
139 (;; Vietnamese upper | |
140 (read r0) | |
141 (r0 -= 128) | |
142 (write-read-repeat r0 ,(cdr viet-viscii-encode-table))) | |
143 ;; not Vietnamese | |
144 (write-read-repeat r0))))))))) | |
145 "CCL program to encode VISCII 1.1") | 97 "CCL program to encode VISCII 1.1") |
146 | 98 |
147 (define-ccl-program ccl-encode-viscii-font | 99 (define-ccl-program ccl-encode-viscii-font |
148 `(0 | 100 `(0 |
149 ;; In: R0:vietnamese-viscii-lower/vietnamese-viscii-upper | 101 ;; In: R0:vietnamese-viscii-lower/vietnamese-viscii-upper |
150 ;; R1:position code | 102 ;; R1:position code |
151 ;; Out: R1:font code point | 103 ;; Out: R1:font code point |
152 (if (r0 == ,(charset-id 'vietnamese-viscii-lower)) | 104 (translate-character viet-viscii-encode-table r0 r1)) |
153 (r1 = r1 ,(car viet-viscii-encode-table)) | |
154 (r1 = r1 ,(cdr viet-viscii-encode-table))) | |
155 ) | |
156 "CCL program to encode Vietnamese chars to VISCII 1.1 font") | 105 "CCL program to encode Vietnamese chars to VISCII 1.1 font") |
157 | 106 |
158 (define-ccl-program ccl-decode-vscii | 107 (define-ccl-program ccl-decode-vscii |
159 `(3 | 108 `(3 |
160 ((read r0) | 109 ((loop |
161 (loop | 110 (r0 = 0) |
162 (write-read-repeat r0 ,viet-vscii-decode-table)) | 111 (read r1) |
163 )) | 112 (translate-character viet-vscii-nonascii-translation-table r0 r1) |
113 (write-multibyte-character r0 r1) | |
114 (repeat)))) | |
164 "CCL program to decode VSCII-1.") | 115 "CCL program to decode VSCII-1.") |
165 | 116 |
166 (define-ccl-program ccl-encode-vscii | 117 (define-ccl-program ccl-encode-vscii |
167 `(1 | 118 `(1 |
168 ((read r0) | 119 ((loop |
169 (loop | 120 (read-multibyte-character r0 r1) |
170 (if (r0 < 128) | 121 (translate-character viet-vscii-encode-table r0 r1) |
171 ;; ASCII | 122 (write-repeat r1)))) |
172 (write-read-repeat r0) | |
173 ;; not ASCII | |
174 (if (r0 != ,leading-code-private-11) | |
175 ;; not Vietnamese | |
176 (write-read-repeat r0) | |
177 (read-if (r0 == ,(charset-id 'vietnamese-viscii-lower)) | |
178 (;; Vietnamese lower | |
179 (read r0) | |
180 (r0 -= 128) | |
181 (write-read-repeat r0 ,(car viet-vscii-encode-table))) | |
182 (if (r0 == ,(charset-id 'vietnamese-viscii-upper)) | |
183 (;; Vietnamese upper | |
184 (read r0) | |
185 (r0 -= 128) | |
186 (write-read-repeat r0 ,(cdr viet-vscii-encode-table))) | |
187 ;; not Vietnamese | |
188 (write-read-repeat r0)))))))) | |
189 "CCL program to encode VSCII-1.") | 123 "CCL program to encode VSCII-1.") |
190 | 124 |
191 (define-ccl-program ccl-encode-vscii-font | 125 (define-ccl-program ccl-encode-vscii-font |
192 `(0 | 126 `(0 |
193 ;; In: R0:vietnamese-viscii-lower/vietnamese-viscii-upper | 127 ;; In: R0:vietnamese-viscii-lower/vietnamese-viscii-upper |
194 ;; R1:position code | 128 ;; R1:position code |
195 ;; Out: R1:font code point | 129 ;; Out: R1:font code point |
196 (if (r0 == ,(charset-id 'vietnamese-viscii-lower)) | 130 (translate-character viet-vscii-encode-table r0 r1)) |
197 (r1 = r1 ,(car viet-vscii-encode-table)) | |
198 (r1 = r1 ,(cdr viet-vscii-encode-table))) | |
199 ) | |
200 "CCL program to encode Vietnamese chars to VSCII-1 font.") | 131 "CCL program to encode Vietnamese chars to VSCII-1 font.") |
201 | 132 |
202 | 133 |
203 (make-coding-system | 134 (make-coding-system |
204 'vietnamese-viscii 4 ?V | 135 'vietnamese-viscii 4 ?V |
232 | 163 |
233 | 164 |
234 (define-coding-system-alias 'viqr 'vietnamese-viqr) | 165 (define-coding-system-alias 'viqr 'vietnamese-viqr) |
235 | 166 |
236 (setq font-ccl-encoder-alist | 167 (setq font-ccl-encoder-alist |
237 (cons (cons "viscii" ccl-encode-viscii-font) font-ccl-encoder-alist)) | 168 (cons '("viscii" . ccl-encode-viscii-font) font-ccl-encoder-alist)) |
238 | 169 |
239 (setq font-ccl-encoder-alist | 170 (setq font-ccl-encoder-alist |
240 (cons (cons "vscii" ccl-encode-vscii-font) font-ccl-encoder-alist)) | 171 (cons '("vscii" . ccl-encode-vscii-font) font-ccl-encoder-alist)) |
241 | |
242 (defvar viet-viscii-nonascii-translation-table | |
243 (make-translation-table-from-vector viet-viscii-decode-table) | |
244 "Value of `nonascii-translation-table' in Vietnamese language environment.") | |
245 | 172 |
246 (set-language-info-alist | 173 (set-language-info-alist |
247 "Vietnamese" `((charset vietnamese-viscii-lower vietnamese-viscii-upper) | 174 "Vietnamese" `((charset vietnamese-viscii-lower vietnamese-viscii-upper) |
248 (nonascii-translation | 175 (nonascii-translation |
249 . ,viet-viscii-nonascii-translation-table) | 176 . ,(get 'viet-viscii-nonascii-translation-table |
177 'translation-table)) | |
250 (coding-system vietnamese-viscii vietnamese-vscii | 178 (coding-system vietnamese-viscii vietnamese-vscii |
251 vietnamese-viqr) | 179 vietnamese-viqr) |
252 (coding-priority vietnamese-viscii) | 180 (coding-priority vietnamese-viscii) |
253 (input-method . "vietnamese-viqr") | 181 (input-method . "vietnamese-viqr") |
254 (unibyte-display . vietnamese-viscii) | 182 (unibyte-display . vietnamese-viscii) |