1 ;;; vietnamese.el --- Support for Vietnamese -*- coding: iso-2022-7bit; -*-
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,2F
\e(B 3 4 ?
\e,2G
\e(B ?
\e,2g
\e(B 7 8 9 10 11 12 13 14 15
37 16 17 18 19 ?
\e,2V
\e(B 21 22 23 24 ?
\e,2[
\e(B 26 27 28 29 ?
\e,2\
\e(B 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,2U
\e(B ?
\e,2!
\e(B ?
\e,2"
\e(B ?
\e,2#
\e(B ?
\e,2$
\e(B ?
\e,2%
\e(B ?
\e,2&
\e(B ?
\e,2'
\e(B ?
\e,2(
\e(B ?
\e,2)
\e(B ?
\e,2*
\e(B ?
\e,2+
\e(B ?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\e(B ?
\e,1[
\e(B ?
\e,1\
\e(B ?
\e,2}
\e(B ?
\e,1^
\e(B ?
\e,1_
\e(B
50 ?
\e,1`
\e(B ?
\e,1a
\e(B ?
\e,1b
\e(B ?
\e,1c
\e(B ?
\e,1d
\e(B ?
\e,1e
\e(B ?
\e,1f
\e(B ?
\e,1g
\e(B ?
\e,1h
\e(B ?
\e,1i
\e(B ?
\e,1j
\e(B ?
\e,1k
\e(B ?
\e,1l
\e(B ?
\e,1m
\e(B ?
\e,1n
\e(B ?
\e,1o
\e(B
51 ?
\e,1p
\e(B ?
\e,1q
\e(B ?
\e,1r
\e(B ?
\e,1s
\e(B ?
\e,1t
\e(B ?
\e,1u
\e(B ?
\e,1v
\e(B ?
\e,1w
\e(B ?
\e,1x
\e(B ?
\e,1y
\e(B ?
\e,1z
\e(B ?
\e,1{
\e(B ?
\e,1|
\e(B ?
\e,1}
\e(B ?
\e,1~
\e(B ?
\e,2f
\e(B ]
52 "Vietnamese VISCII decoding table.")
54 (defvar viet-viscii-encode-table
55 (let ((table-lower (make-vector 128 0))
56 (table-upper (make-vector 128 0))
61 (split-char (aref viet-viscii-decode-table i)))
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)))
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.")
72 (defvar viet-vscii-decode-table
73 [;; VSCII is a full 8-bit code.
74 0 ?
\e,2z
\e(B ?
\e,2x
\e(B 3 ?
\e,2W
\e(B ?
\e,2X
\e(B ?
\e,2f
\e(B 7 8 9 10 11 12 13 14 15
75 16 ?
\e,2Q
\e(B ?
\e,2_
\e(B ?
\e,2O
\e(B ?
\e,2V
\e(B ?
\e,2[
\e(B ?
\e,2}
\e(B ?
\e,2\
\e(B 24 25 26 27 28 29 30 31
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
82 ?
\e,2`
\e(B ?
\e,2d
\e(B ?
\e,2c
\e(B ?
\e,2a
\e(B ?
\e,2U
\e(B ?
\e,2#
\e(B ?
\e,2'
\e(B ?
\e,2h
\e(B ?
\e,2k
\e(B ?
\e,2(
\e(B ?
\e,2i
\e(B ?
\e,2)
\e(B ?
\e,2.
\e(B ?
\e,2l
\e(B ?
\e,2o
\e(B ?
\e,2n
\e(B
83 ?
\e,2m
\e(B ?
\e,28
\e(B ?
\e,2r
\e(B ?
\e,2v
\e(B ?
\e,2u
\e(B ?
\e,2s
\e(B ?
\e,2w
\e(B ?
\e,25
\e(B ?
\e,26
\e(B ?
\e,27
\e(B ?
\e,2^
\e(B ?
\e,2>
\e(B ?
\e,2~
\e(B ?
\e,2y
\e(B ?
\e,2|
\e(B ?
\e,2{
\e(B
84 160 ?
\e,2e
\e(B ?
\e,2b
\e(B ?
\e,2j
\e(B ?
\e,2t
\e(B ?
\e,2=
\e(B ?
\e,2_
\e(B ?
\e,2p
\e(B ?
\e,1e
\e(B ?
\e,1b
\e(B ?
\e,1j
\e(B ?
\e,1t
\e(B ?
\e,1>
\e(B ?
\e,1y
\e(B ?
\e,1p
\e(B ?
\e,2"
\e(B
85 192 193 194 195 196 ?
\e,1`
\e(B ?
\e,1d
\e(B ?
\e,1c
\e(B ?
\e,1a
\e(B ?
\e,1U
\e(B ?
\e,2F
\e(B ?
\e,1"
\e(B ?
\e,1F
\e(B ?
\e,1G
\e(B ?
\e,1!
\e(B ?
\e,2G
\e(B
86 ?
\e,2!
\e(B ?
\e,2%
\e(B ?
\e,2&
\e(B ?
\e,2g
\e(B ?
\e,2%
\e(B ?
\e,2+
\e(B ?
\e,1#
\e(B ?
\e,1%
\e(B ?
\e,1&
\e(B ?
\e,1g
\e(B ?
\e,1$
\e(B ?
\e,1'
\e(B ?
\e,1h
\e(B ?
\e,2,
\e(B ?
\e,1k
\e(B ?
\e,1(
\e(B
87 ?
\e,1i
\e(B ?
\e,1)
\e(B ?
\e,1+
\e(B ?
\e,1,
\e(B ?
\e,1-
\e(B ?
\e,1*
\e(B ?
\e,1.
\e(B ?
\e,1l
\e(B ?
\e,1o
\e(B ?
\e,2-
\e(B ?
\e,2*
\e(B ?
\e,20
\e(B ?
\e,1n
\e(B ?
\e,1m
\e(B ?
\e,18
\e(B ?
\e,1r
\e(B
88 ?
\e,21
\e(B ?
\e,1v
\e(B ?
\e,1u
\e(B ?
\e,1s
\e(B ?
\e,1w
\e(B ?
\e,10
\e(B ?
\e,11
\e(B ?
\e,12
\e(B ?
\e,1/
\e(B ?
\e,15
\e(B ?
\e,16
\e(B ?
\e,17
\e(B ?
\e,1^
\e(B ?
\e,1>
\e(B ?
\e,1~
\e(B ?
\e,1y
\e(B
89 ?
\e,22
\e(B ?
\e,1|
\e(B ?
\e,1{
\e(B ?
\e,1z
\e(B ?
\e,1x
\e(B ?
\e,1W
\e(B ?
\e,1X
\e(B ?
\e,1f
\e(B ?
\e,1Q
\e(B ?
\e,1q
\e(B ?
\e,1O
\e(B ?
\e,1V
\e(B ?
\e,1[
\e(B ?
\e,1}
\e(B ?
\e,1\
\e(B ?
\e,2/
\e(B]
90 "Vietnamese VSCII decoding table.")
92 (defvar viet-vscii-encode-table
93 (let ((table-lower (make-vector 128 0))
94 (table-upper (make-vector 128 0))
99 (split-char (aref viet-vscii-decode-table i)))
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)))
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.")
112 (define-ccl-program ccl-decode-viscii
116 (write-read-repeat r0 ,viet-viscii-decode-table))
118 "CCL program to decode VISCII 1.1")
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'.
125 (defvar leading-code-private-11 #x9E)
127 (define-ccl-program ccl-encode-viscii
133 (write-read-repeat r0)
135 (if (r0 != ,leading-code-private-11)
137 (write-read-repeat r0)
138 ((read-if (r0 == ,(charset-id 'vietnamese-viscii-lower))
142 (write-read-repeat r0 ,(car viet-viscii-encode-table)))
143 (if (r0 == ,(charset-id 'vietnamese-viscii-upper))
147 (write-read-repeat r0 ,(cdr viet-viscii-encode-table)))
149 (write-read-repeat r0)))))))))
150 "CCL program to encode VISCII 1.1")
152 (define-ccl-program ccl-encode-viscii-font
154 ;; In: R0:vietnamese-viscii-lower/vietnamese-viscii-upper
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)))
161 "CCL program to encode Vietnamese chars to VISCII 1.1 font")
163 (define-ccl-program ccl-decode-vscii
167 (write-read-repeat r0 ,viet-vscii-decode-table))
169 "CCL program to decode VSCII-1.")
171 (define-ccl-program ccl-encode-vscii
177 (write-read-repeat r0)
179 (if (r0 != ,leading-code-private-11)
181 (write-read-repeat r0)
182 (read-if (r0 == ,(charset-id 'vietnamese-viscii-lower))
186 (write-read-repeat r0 ,(car viet-vscii-encode-table)))
187 (if (r0 == ,(charset-id 'vietnamese-viscii-upper))
191 (write-read-repeat r0 ,(cdr viet-vscii-encode-table)))
193 (write-read-repeat r0))))))))
194 "CCL program to encode VSCII-1.")
196 (define-ccl-program ccl-encode-vscii-font
198 ;; In: R0:vietnamese-viscii-lower/vietnamese-viscii-upper
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)))
205 "CCL program to encode Vietnamese chars to VSCII-1 font.")
210 "Coding-system used for VISCII 1.1."
212 decode ,ccl-decode-viscii
213 encode ,ccl-encode-viscii))
215 ;; it is not correct, but XEmacs doesn't have `ccl' category...
216 (coding-system-put 'viscii 'category 'iso-8-1)
218 ;; (make-coding-system
219 ;; 'vietnamese-viscii 4 ?V
220 ;; "8-bit encoding for Vietnamese VISCII 1.1 (MIME:VISCII)"
221 ;; '(ccl-decode-viscii . ccl-encode-viscii)
222 ;; '((safe-charsets ascii vietnamese-viscii-lower vietnamese-viscii-upper)
223 ;; (mime-charset . viscii)
224 ;; (valid-codes (0 . 255))))
226 ;; (define-coding-system-alias 'viscii 'vietnamese-viscii)
230 "Coding-system used for VSCII 1.1."
232 decode ,ccl-decode-vscii
233 encode ,ccl-encode-vscii))
235 ;; (make-coding-system
236 ;; 'vietnamese-vscii 4 ?v
237 ;; "8-bit encoding for Vietnamese VSCII-1"
238 ;; '(ccl-decode-vscii . ccl-encode-vscii)
239 ;; '((safe-charsets ascii vietnamese-viscii-lower vietnamese-viscii-upper)
240 ;; (valid-codes (0 . 255))))
242 ;; (define-coding-system-alias 'vscii 'vietnamese-vscii)
246 "Coding-system used for VIQR."
249 post-read-conversion viqr-post-read-conversion
250 pre-write-conversion viqr-pre-write-conversion))
252 ;; (make-coding-system
253 ;; 'vietnamese-viqr 0 ?q
254 ;; "Vietnamese latin transcription (VIQR)"
256 ;; '((safe-charsets ascii vietnamese-viscii-lower vietnamese-viscii-upper)
257 ;; (post-read-conversion . viqr-post-read-conversion)
258 ;; (pre-write-conversion . viqr-pre-write-conversion)
259 ;; (charset-origin-alist
260 ;; (vietnamese-viscii-lower "VISCII" viet-encode-viscii-char)
261 ;; (vietnamese-viscii-upper "VISCII" viet-encode-viscii-char))))
263 ;; (define-coding-system-alias 'viqr 'vietnamese-viqr)
266 (set-charset-ccl-program 'vietnamese-viscii-lower
267 ccl-encode-viscii-font)
268 (set-charset-ccl-program 'vietnamese-viscii-upper
269 ccl-encode-viscii-font)
271 (set-charset-ccl-program 'vietnamese-viscii-lower ccl-encode-vscii-font)
272 (set-charset-ccl-program 'vietnamese-viscii-upper ccl-encode-vscii-font)
274 ;; (setq font-ccl-encoder-alist
275 ;; (cons (cons "viscii" ccl-encode-viscii-font) font-ccl-encoder-alist))
277 ;; (setq font-ccl-encoder-alist
278 ;; (cons (cons "vscii" ccl-encode-vscii-font) font-ccl-encoder-alist))
280 ;; (defvar viet-viscii-nonascii-translation-table
281 ;; (make-translation-table-from-vector viet-viscii-decode-table)
282 ;; "Value of `nonascii-translation-table' in Vietnamese language environment.")
284 (set-language-info-alist
285 "Vietnamese" '((charset vietnamese-viscii-lower vietnamese-viscii-upper)
286 (coding-system viscii vscii viqr)
287 (coding-priority viscii)
288 (input-method . "vietnamese-viqr")
290 (sample-text . "Vietnamese (Ti
\e,1*
\e(Bng Vi
\e,1.
\e(Bt) Ch
\e,1`
\e(Bo b
\e,1U
\e(Bn")
292 For Vietnamese, Emacs uses special charasets internally.
293 They can be decoded from and encoded to VISCC, VSCII, and VIQR.
294 Current setting put higher priority to the coding system VISCII than VSCII.
295 If you prefer VSCII, please do: (prefer-coding-system 'vietnamese-vscii)")
298 ;;; vietnamese.el ends here