Mercurial > emacs
comparison lisp/language/vietnamese.el @ 17052:d0d7b244b1d0
Initial revision
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Thu, 20 Feb 1997 07:02:49 +0000 |
parents | |
children | 70194012fb3a |
comparison
equal
deleted
inserted
replaced
17051:fd0b17a79b07 | 17052:d0d7b244b1d0 |
---|---|
1 ;;; vietnamese.el --- Support for Vietnamese | |
2 | |
3 ;; Copyright (C) 1995 Free Software Foundation, Inc. | |
4 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN. | |
5 | |
6 ;; Keywords: multilingual, Vietnamese | |
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 | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
22 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
23 | |
24 ;;; Commentary: | |
25 | |
26 ;; For Vietnames, the character sets VISCII and VSCII are supported. | |
27 | |
28 ;;; Code: | |
29 | |
30 (eval-when-compile | |
31 | |
32 (defvar viet-viscii-decode-table | |
33 [;; VISCII is a full 8-bit code. | |
34 0 1 ?,2F(B 3 4 ?,2G(B ?,2g(B 7 8 9 10 11 12 13 14 15 | |
35 16 17 18 19 ?,2V(B 21 22 23 24 ?,2[(B 26 27 28 29 ?,2\(B 31 | |
36 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
37 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
38 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
39 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
40 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
41 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
42 ?,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 | |
43 ?,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 | |
44 ?,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 | |
45 ?,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 | |
46 ?,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 | |
47 ?,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 | |
48 ?,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 | |
49 ?,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 ] | |
50 "Vietnamese VISCII encoding table.") | |
51 | |
52 (defvar viet-viscii-encode-table | |
53 (let ((table-lower (make-vector 128 0)) | |
54 (table-upper (make-vector 128 0)) | |
55 (i 0) | |
56 char-component) | |
57 (while (< i 256) | |
58 (setq char-component (split-char (aref viet-viscii-decode-table i))) | |
59 (cond ((eq (car char-component) 'vietnamese-viscii-lower) | |
60 (aset table-lower (nth 1 char-component) i)) | |
61 ((eq (car char-component) 'vietnamese-viscii-upper) | |
62 (aset table-upper (nth 1 char-component) i))) | |
63 (setq i (1+ i))) | |
64 (cons table-lower table-upper)) | |
65 "Vietnamese VISCII decoding table. | |
66 Cons of tables for decoding lower-case chars and upper-case characterss. | |
67 Both tables are indexed by the position code of Vietnamese characters.") | |
68 | |
69 (defvar viet-vscii-decode-table | |
70 [;; VSCII is a full 8-bit code. | |
71 0 ?,2z(B ?,2x(B 3 ?,2W(B ?,2X(B ?,2f(B 7 8 9 10 11 12 13 14 15 | |
72 16 ?,2Q(B ?,2_(B ?,2O(B ?,2V(B ?,2[(B ?,2}(B ?,2\(B 24 25 26 27 28 29 30 31 | |
73 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | |
74 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | |
75 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
76 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
77 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |
78 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 | |
79 ?,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 | |
80 ?,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 | |
81 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 | |
82 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 | |
83 ?,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 | |
84 ?,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 | |
85 ?,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 | |
86 ?,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] | |
87 "Vietnamese VSCII code table.") | |
88 | |
89 (defvar viet-vscii-encode-table | |
90 (let ((table-lower (make-vector 128 0)) | |
91 (table-upper (make-vector 128 0)) | |
92 (i 0) | |
93 char-component) | |
94 (while (< i 256) | |
95 (setq char-component (split-char (aref viet-vscii-decode-table i))) | |
96 (cond ((eq (car char-component) 'vietnamese-viscii-lower) | |
97 (aset table-lower (nth 1 char-component) i)) | |
98 ((eq (car char-component) 'vietnamese-viscii-upper) | |
99 (aset table-upper (nth 1 char-component) i))) | |
100 (setq i (1+ i))) | |
101 (cons table-lower table-upper)) | |
102 "Vietnamese VSCII decoding table. | |
103 Cons of tables for decoding lower-case chars and upper-case characterss. | |
104 Both tables are indexed by the position code of Vietnamese characters.") | |
105 | |
106 ) | |
107 | |
108 (define-ccl-program ccl-decode-viscii | |
109 `(3 | |
110 ((read r0) | |
111 (loop | |
112 (write-read-repeat r0 ,viet-viscii-decode-table)) | |
113 )) | |
114 "CCL program to decode VISCII 1.1") | |
115 | |
116 ;; Multibyte form of a Vietnamese character is as follows (3-byte): | |
117 ;; LEADING-CODE-PRIVATE-11 LEADING-CODE-EXTENDED-11 POSITION-CODE | |
118 ;; where LEADING-CODE-EXTENDED-11 for Vietnamese is | |
119 ;; `vietnamese-viscii-lower' or `vietnamese-viscii-upper'. | |
120 | |
121 (define-ccl-program ccl-encode-viscii | |
122 `(1 | |
123 ((read r0) | |
124 (loop | |
125 (if (r0 < 128) | |
126 ;; ASCII | |
127 (write-read-repeat r0) | |
128 ;; not ASCII | |
129 (if (r0 != ,leading-code-private-11) | |
130 ;; not Vietnamese | |
131 (write-read-repeat r0) | |
132 ((read-if (r0 == ,(charset-id 'vietnamese-viscii-lower)) | |
133 (;; Vietnamese lower | |
134 (read r0) | |
135 (r0 -= 128) | |
136 (write-read-repeat r0 ,(car viet-viscii-encode-table))) | |
137 (if (r0 == ,(charset-id 'vietnamese-viscii-upper)) | |
138 (;; Vietnamese upper | |
139 (read r0) | |
140 (r0 -= 128) | |
141 (write-read-repeat r0 ,(cdr viet-viscii-encode-table))) | |
142 ;; not Vietnamese | |
143 (write-read-repeat r0))))))))) | |
144 "CCL program to encode VISCII 1.1") | |
145 | |
146 (define-ccl-program ccl-encode-viscii-font | |
147 `(0 | |
148 ;; In: R0:vietnamese-viscii-lower/vietnamese-viscii-upper | |
149 ;; R1:position code | |
150 ;; Out: R1:font code point | |
151 (if (r0 == ,(charset-id 'vietnamese-viscii-lower)) | |
152 (r1 = r1 ,(car viet-viscii-encode-table)) | |
153 (r1 = r1 ,(cdr viet-viscii-encode-table))) | |
154 ) | |
155 "CCL program to encode Vietnamese chars to VISCII 1.1 font") | |
156 | |
157 (define-ccl-program ccl-decode-vscii | |
158 `(3 | |
159 ((read r0) | |
160 (loop | |
161 (write-read-repeat r0 ,viet-vscii-decode-table)) | |
162 )) | |
163 "CCL program to decode VSCII-1.") | |
164 | |
165 (define-ccl-program ccl-encode-vscii | |
166 `(1 | |
167 ((read r0) | |
168 (loop | |
169 (if (r0 < 128) | |
170 ;; ASCII | |
171 (write-read-repeat r0) | |
172 ;; not ASCII | |
173 (if (r0 != ,leading-code-private-11) | |
174 ;; not Vietnamese | |
175 (write-read-repeat r0) | |
176 (read-if (r0 == ,(charset-id 'vietnamese-viscii-lower)) | |
177 (;; Vietnamese lower | |
178 (read r0) | |
179 (r0 -= 128) | |
180 (write-read-repeat r0 ,(car viet-vscii-encode-table))) | |
181 (if (r0 == ,(charset-id 'vietnamese-viscii-upper)) | |
182 (;; Vietnamese upper | |
183 (read r0) | |
184 (r0 -= 128) | |
185 (write-read-repeat r0 ,(cdr viet-viscii-encode-table))) | |
186 ;; not Vietnamese | |
187 (write-read-repeat r0)))))))) | |
188 "CCL program to encode VSCII-1.") | |
189 | |
190 (define-ccl-program ccl-encode-vscii-font | |
191 `(0 | |
192 ;; In: R0:vietnamese-viscii-lower/vietnamese-viscii-upper | |
193 ;; R1:position code | |
194 ;; Out: R1:font code point | |
195 (if (r0 == ,(charset-id 'vietnamese-viscii-lower)) | |
196 (r1 = r1 ,(car viet-vscii-encode-table)) | |
197 (r1 = r1 ,(cdr viet-vscii-encode-table))) | |
198 ) | |
199 "CCL program to encode Vietnamese chars to VSCII-1 font.") | |
200 | |
201 | |
202 (make-coding-system | |
203 'coding-system-viscii 4 ?V | |
204 "Coding-system used for VISCII 1.1." | |
205 (cons ccl-decode-viscii ccl-encode-viscii)) | |
206 | |
207 (make-coding-system | |
208 'coding-system-vscii 4 ?V | |
209 "Coding-system used for VSCII-1." | |
210 (cons ccl-decode-vscii ccl-encode-vscii)) | |
211 | |
212 (make-coding-system | |
213 'coding-system-viqr 0 ?v | |
214 "Codins-system used for VIQR." | |
215 nil) | |
216 (put 'coding-system-viqr 'post-read-conversion 'viet-decode-viqr-region) | |
217 (put 'coding-system-viqr 'pre-write-conversion 'viet-encode-viqr-region) | |
218 | |
219 (setq font-ccl-encoder-alist | |
220 (cons (cons "viscii" ccl-encode-viscii-font) font-ccl-encoder-alist)) | |
221 | |
222 (setq font-ccl-encoder-alist | |
223 (cons (cons "vscii" ccl-encode-vscii-font) font-ccl-encoder-alist)) | |
224 | |
225 (register-input-method | |
226 "Vietnamese" '("quail-viqr" quail-use-package "quail/viqr")) | |
227 | |
228 (defun setup-viet-environment () | |
229 ;; for VISCII users | |
230 (setq coding-category-binary 'coding-system-viscii) | |
231 | |
232 ;; for VSCII users | |
233 ;; (setq coding-category-binary 'coding-system-vscii) | |
234 | |
235 (set-coding-priority | |
236 '(coding-category-iso-7 | |
237 coding-category-binary)) | |
238 | |
239 (setq-default buffer-file-coding-system 'coding-system-viscii) | |
240 | |
241 (setq default-input-method '("Vietnamese" . "quail-viqr")) | |
242 ) | |
243 | |
244 (set-language-info-alist | |
245 "Vietnamese" '((setup-function . setup-viet-environment) | |
246 (charset . (vietnamese-viscii-lower | |
247 vietnamese-viscii-upper)) | |
248 (coding-system . (coding-system-viscii | |
249 coding-system-vscii | |
250 coding-system-viqr)) | |
251 (documentation . t) | |
252 (sample-text . "Vietnamese (Ti,1*(Bng Vi,1.(Bt) Ch,1`(Bo b,1U(Bn"))) | |
253 | |
254 ;;; vietnamese.el ends here |