1 ;;; vietnamese.el --- Support for Vietnamese
3 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
4 ;; Licensed to the Free Software Foundation.
5 ;; Copyright (C) 1997 MORIOKA Tomohiko
7 ;; Keywords: multilingual, Vietnamese
9 ;; This file is part of XEmacs.
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)
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.
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
28 ;; For Vietnames, the character sets VISCII and VSCII are supported.
34 (defvar viet-viscii-decode-table
35 [;; VISCII is a full 8-bit code.
36 0 1 ?
\e.2
\eNF 3 4 ?
\eNG ?
\eNg 7 8 9 10 11 12 13 14 15
37 16 17 18 19 ?
\e.2
\eNV 21 22 23 24 ?
\eN[ 26 27 28 29 ?
\eN\ 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 ?
\e.2
\eNU ?
\eN! ?
\eN" ?
\eN# ?
\eN$ ?
\eN% ?
\eN& ?
\eN' ?
\eN( ?
\eN) ?
\eN* ?
\eN+ ?
\eN, ?
\eN- ?
\eN. ?
\eN/
45 ?
\e.2
\eN0 ?
\eN1 ?
\eN2 ?
\eN5 ?
\eN~ ?
\eN> ?
\eN6 ?
\eN7 ?
\eN8 ?
\eNv ?
\eNw ?
\eNo ?
\eN| ?
\eN{ ?
\eNx ?
\eNO
46 ?
\e.2
\eNu ?
\e.1
\eN! ?
\eN" ?
\eN# ?
\eN$ ?
\eN% ?
\eN& ?
\eN' ?
\eN( ?
\eN) ?
\eN* ?
\eN+ ?
\eN, ?
\eN- ?
\eN. ?
\eN/
47 ?
\e.1
\eN0 ?
\eN1 ?
\eN2 ?
\e.2
\eN^ ?
\eN= ?
\e.1
\eN5 ?
\eN6 ?
\eN7 ?
\eN8 ?
\e.2
\eNq ?
\eNQ ?
\eNW ?
\eNX ?
\e.1
\eN= ?
\eN> ?
\e.2
\eN_
48 ?
\e.2
\eN` ?
\eNa ?
\eNb ?
\eNc ?
\eNd ?
\eNe ?
\e.1
\eNF ?
\eNG ?
\e.2
\eNh ?
\eNi ?
\eNj ?
\eNk ?
\eNl ?
\eNm ?
\eNn ?
\e.1
\eNO
49 ?
\e.2
\eNp ?
\e.1
\eNQ ?
\e.2
\eNr ?
\eNs ?
\eNt ?
\e.1
\eNU ?
\eNV ?
\eNW ?
\eNX ?
\e.2
\eNy ?
\eNz ?
\e.1
\eN[ ?
\eN\ ?
\e.2
\eN} ?
\e.1
\eN^ ?
\eN_
50 ?
\e.1
\eN` ?
\eNa ?
\eNb ?
\eNc ?
\eNd ?
\eNe ?
\eNf ?
\eNg ?
\eNh ?
\eNi ?
\eNj ?
\eNk ?
\eNl ?
\eNm ?
\eNn ?
\eNo
51 ?
\e.1
\eNp ?
\eNq ?
\eNr ?
\eNs ?
\eNt ?
\eNu ?
\eNv ?
\eNw ?
\eNx ?
\eNy ?
\eNz ?
\eN{ ?
\eN| ?
\eN} ?
\eN~ ?
\e.2
\eNf ]
52 "Vietnamese VISCII decoding table.")
54 (defun split-char-or-char-int (char)
55 "Return list of charset and one or two position-codes of CHAR.
56 CHAR must be character or integer."
59 (let ((c (int-char char)))
65 (defvar viet-viscii-encode-table
66 (let ((table-lower (make-vector 128 0))
67 (table-upper (make-vector 128 0))
72 (split-char-or-char-int (aref viet-viscii-decode-table i)))
73 (cond ((eq (car char-component) 'vietnamese-viscii-lower)
74 (aset table-lower (nth 1 char-component) i))
75 ((eq (car char-component) 'vietnamese-viscii-upper)
76 (aset table-upper (nth 1 char-component) i)))
78 (cons table-lower table-upper))
79 "Vietnamese VISCII encoding table.
80 Cons of tables for encoding lower-case chars and upper-case characters.
81 Both tables are indexed by the position code of Vietnamese characters.")
83 (defvar viet-vscii-decode-table
84 [;; VSCII is a full 8-bit code.
85 0 ?
\e.2
\eNz ?
\eNx 3 ?
\eNW ?
\eNX ?
\eNf 7 8 9 10 11 12 13 14 15
86 16 ?
\e.2
\eNQ ?
\eN_ ?
\eNO ?
\eNV ?
\eN[ ?
\eN} ?
\eN\ 24 25 26 27 28 29 30 31
87 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
88 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
89 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
90 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
91 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
92 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
93 ?
\e.2
\eN` ?
\eNd ?
\eNc ?
\eNa ?
\eNU ?
\eN# ?
\eN' ?
\eNh ?
\eNk ?
\eN( ?
\eNi ?
\eN) ?
\eN. ?
\eNl ?
\eNo ?
\eNn
94 ?
\e.2
\eNm ?
\eN8 ?
\eNr ?
\eNv ?
\eNu ?
\eNs ?
\eNw ?
\eN5 ?
\eN6 ?
\eN7 ?
\eN^ ?
\eN> ?
\eN~ ?
\eNy ?
\eN| ?
\eN{
95 160 ?
\e.2
\eNe ?
\eNb ?
\eNj ?
\eNt ?
\eN= ?
\eN_ ?
\eNp ?
\e.1
\eNe ?
\eNb ?
\eNj ?
\eNt ?
\eN> ?
\eNy ?
\eNp ?
\e.2
\eN"
96 192 193 194 195 196 ?
\e.1
\eN` ?
\eNd ?
\eNc ?
\eNa ?
\eNU ?
\e.2
\eNF ?
\e.1
\eN" ?
\eNF ?
\eNG ?
\eN! ?
\e.2
\eNG
97 ?
\e.2
\eN! ?
\eN% ?
\eN& ?
\eNg ?
\eN% ?
\eN+ ?
\e.1
\eN# ?
\eN% ?
\eN& ?
\eNg ?
\eN$ ?
\eN' ?
\eNh ?
\e.2
\eN, ?
\e.1
\eNk ?
\eN(
98 ?
\e.1
\eNi ?
\eN) ?
\eN+ ?
\eN, ?
\eN- ?
\eN* ?
\eN. ?
\eNl ?
\eNo ?
\e.2
\eN- ?
\eN* ?
\eN0 ?
\e.1
\eNn ?
\eNm ?
\eN8 ?
\eNr
99 ?
\e.2
\eN1 ?
\e.1
\eNv ?
\eNu ?
\eNs ?
\eNw ?
\eN0 ?
\eN1 ?
\eN2 ?
\eN/ ?
\eN5 ?
\eN6 ?
\eN7 ?
\eN^ ?
\eN> ?
\eN~ ?
\eNy
100 ?
\e.2
\eN2 ?
\e.1
\eN| ?
\eN{ ?
\eNz ?
\eNx ?
\eNW ?
\eNX ?
\eNf ?
\eNQ ?
\eNq ?
\eNO ?
\eNV ?
\eN[ ?
\eN} ?
\eN\ ?
\e.2
\eN/]
101 "Vietnamese VSCII decoding table.")
103 (defvar viet-vscii-encode-table
104 (let ((table-lower (make-vector 128 0))
105 (table-upper (make-vector 128 0))
110 (split-char-or-char-int (aref viet-vscii-decode-table i)))
111 (cond ((eq (car char-component) 'vietnamese-viscii-lower)
112 (aset table-lower (nth 1 char-component) i))
113 ((eq (car char-component) 'vietnamese-viscii-upper)
114 (aset table-upper (nth 1 char-component) i)))
116 (cons table-lower table-upper))
117 "Vietnamese VSCII encoding table.
118 Cons of tables for encoding lower-case chars and upper-case characters.
119 Both tables are indexed by the position code of Vietnamese characters.")
123 (define-ccl-program ccl-decode-viscii
127 (write-read-repeat r0 ,viet-viscii-decode-table))
129 "CCL program to decode VISCII 1.1")
131 ;; Multibyte form of a Vietnamese character is as follows (3-byte):
132 ;; LEADING-CODE-PRIVATE-11 LEADING-CODE-EXTENDED-11 POSITION-CODE
133 ;; where LEADING-CODE-EXTENDED-11 for Vietnamese is
134 ;; `vietnamese-viscii-lower' or `vietnamese-viscii-upper'.
136 (defvar leading-code-private-11 #x9E)
138 (define-ccl-program ccl-encode-viscii
144 (write-read-repeat r0)
146 (if (r0 != ,leading-code-private-11)
148 (write-read-repeat r0)
149 ((read-if (r0 == ,(charset-id 'vietnamese-viscii-lower))
153 (write-read-repeat r0 ,(car viet-viscii-encode-table)))
154 (if (r0 == ,(charset-id 'vietnamese-viscii-upper))
158 (write-read-repeat r0 ,(cdr viet-viscii-encode-table)))
160 (write-read-repeat r0)))))))))
161 "CCL program to encode VISCII 1.1")
163 (define-ccl-program ccl-encode-viscii-font
165 ;; In: R0:vietnamese-viscii-lower/vietnamese-viscii-upper
167 ;; Out: R1:font code point
168 (if (r0 == ,(charset-id 'vietnamese-viscii-lower))
169 (r1 = r1 ,(car viet-viscii-encode-table))
170 (r1 = r1 ,(cdr viet-viscii-encode-table)))
172 "CCL program to encode Vietnamese chars to VISCII 1.1 font")
174 (define-ccl-program ccl-decode-vscii
178 (write-read-repeat r0 ,viet-vscii-decode-table))
180 "CCL program to decode VSCII-1.")
182 (define-ccl-program ccl-encode-vscii
188 (write-read-repeat r0)
190 (if (r0 != ,leading-code-private-11)
192 (write-read-repeat r0)
193 (read-if (r0 == ,(charset-id 'vietnamese-viscii-lower))
197 (write-read-repeat r0 ,(car viet-vscii-encode-table)))
198 (if (r0 == ,(charset-id 'vietnamese-viscii-upper))
202 (write-read-repeat r0 ,(cdr viet-viscii-encode-table)))
204 (write-read-repeat r0))))))))
205 "CCL program to encode VSCII-1.")
207 (define-ccl-program ccl-encode-vscii-font
209 ;; In: R0:vietnamese-viscii-lower/vietnamese-viscii-upper
211 ;; Out: R1:font code point
212 (if (r0 == ,(charset-id 'vietnamese-viscii-lower))
213 (r1 = r1 ,(car viet-vscii-encode-table))
214 (r1 = r1 ,(cdr viet-vscii-encode-table)))
216 "CCL program to encode Vietnamese chars to VSCII-1 font.")
221 "Coding-system used for VISCII 1.1."
223 decode ,ccl-decode-viscii
224 encode ,ccl-encode-viscii))
226 ;; (make-coding-system
227 ;; 'vietnamese-viscii 4 ?V
228 ;; "8-bit encoding for Vietnamese VISCII 1.1 (MIME:VISCII)"
229 ;; (cons ccl-decode-viscii ccl-encode-viscii))
231 ;; (define-coding-system-alias 'viscii 'vietnamese-viscii)
235 "Coding-system used for VSCII 1.1."
237 decode ,ccl-decode-vscii
238 encode ,ccl-encode-vscii))
240 ;; (make-coding-system
241 ;; 'vietnamese-vscii 4 ?v
242 ;; "8-bit encoding for Vietnamese VSCII-1"
243 ;; (cons ccl-decode-vscii ccl-encode-vscii))
245 ;; (define-coding-system-alias 'vscii 'vietnamese-vscii)
249 "Coding-system used for VIQR."
252 post-read-conversion viqr-post-read-conversion
253 pre-write-conversion viqr-pre-write-conversion))
255 ;; (make-coding-system
256 ;; 'vietnamese-viqr 0 ?q
257 ;; "Vietnamese latin transcription (VIQR)"
259 ;; (put 'vietnamese-viqr 'post-read-conversion 'viqr-post-read-conversion)
260 ;; (put 'vietnamese-viqr 'pre-write-conversion 'viqr-pre-write-conversion)
262 ;; (define-coding-system-alias 'viqr 'vietnamese-viqr)
265 (set-charset-ccl-program 'vietnamese-viscii-lower
266 ccl-encode-viscii-font)
267 (set-charset-ccl-program 'vietnamese-viscii-upper
268 ccl-encode-viscii-font)
270 (set-charset-ccl-program 'vietnamese-viscii-lower ccl-encode-vscii-font)
271 (set-charset-ccl-program 'vietnamese-viscii-upper ccl-encode-vscii-font)
273 ;; (setq font-ccl-encoder-alist
274 ;; (cons (cons "viscii" ccl-encode-viscii-font) font-ccl-encoder-alist))
276 ;; (setq font-ccl-encoder-alist
277 ;; (cons (cons "vscii" ccl-encode-vscii-font) font-ccl-encoder-alist))
279 (set-language-info-alist
280 "Vietnamese" '((setup-function . setup-vietnamese-environment)
281 (charset . (vietnamese-viscii-lower
282 vietnamese-viscii-upper))
283 (coding-system . (viscii vscii viqr))
284 (sample-text . "Vietnamese (Ti
\e.1
\eN*ng Vi
\eN.t) Ch
\eN`o b
\eNUn")
286 For Vietnamese, Emacs uses special charasets internally.
287 They can be decoded from and encoded to VISCC, VSCII, and VIQR.")
290 ;;; vietnamese.el ends here