1 ;;; vietnamese.el --- Support for Vietnamese
3 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
4 ;; Licensed to the Free Software Foundation.
6 ;; Keywords: multilingual, Vietnamese
8 ;; This file is part of GNU Emacs.
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)
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.
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 the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
27 ;; For Vietnames, the character sets VISCII and VSCII are supported.
33 (defvar viet-viscii-decode-table
34 [;; VISCII is a full 8-bit code.
35 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
36 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
37 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
38 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
39 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
40 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
41 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
42 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
43 ?
\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 ?\e,2,\e(B ?\e,2-\e(B ?\e,2.\e(B ?\e,2/\e(B
44 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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
50 ?
\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 ]
51 "Vietnamese VISCII encoding table.")
53 (defvar viet-viscii-encode-table
54 (let ((table-lower (make-vector 128 0))
55 (table-upper (make-vector 128 0))
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
)))
65 (cons table-lower table-upper
))
66 "Vietnamese VISCII decoding table.
67 Cons of tables for decoding lower-case chars and upper-case characterss.
68 Both tables are indexed by the position code of Vietnamese characters.")
70 (defvar viet-vscii-decode-table
71 [;; VSCII is a full 8-bit code.
72 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
73 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
74 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
75 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
76 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78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?
\e,1k
\e(B ?
\e,1(\e(B
85 ?
\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
86 ?
\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
87 ?
\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]
88 "Vietnamese VSCII code table.")
90 (defvar viet-vscii-encode-table
91 (let ((table-lower (make-vector 128 0))
92 (table-upper (make-vector 128 0))
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
)))
102 (cons table-lower table-upper
))
103 "Vietnamese VSCII decoding table.
104 Cons of tables for decoding lower-case chars and upper-case characterss.
105 Both tables are indexed by the position code of Vietnamese characters.")
109 (define-ccl-program ccl-decode-viscii
113 (write-read-repeat r0
,viet-viscii-decode-table
))
115 "CCL program to decode VISCII 1.1")
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'.
122 (define-ccl-program ccl-encode-viscii
128 (write-read-repeat r0
)
130 (if (r0 != ,leading-code-private-11
)
132 (write-read-repeat r0
)
133 ((read-if (r0 == ,(charset-id 'vietnamese-viscii-lower
))
137 (write-read-repeat r0
,(car viet-viscii-encode-table
)))
138 (if (r0 == ,(charset-id 'vietnamese-viscii-upper
))
142 (write-read-repeat r0
,(cdr viet-viscii-encode-table
)))
144 (write-read-repeat r0
)))))))))
145 "CCL program to encode VISCII 1.1")
147 (define-ccl-program ccl-encode-viscii-font
149 ;; In: R0:vietnamese-viscii-lower/vietnamese-viscii-upper
151 ;; Out: R1:font code point
152 (if (r0 == ,(charset-id 'vietnamese-viscii-lower
))
153 (r1 = r1
,(car viet-viscii-encode-table
))
154 (r1 = r1
,(cdr viet-viscii-encode-table
)))
156 "CCL program to encode Vietnamese chars to VISCII 1.1 font")
158 (define-ccl-program ccl-decode-vscii
162 (write-read-repeat r0
,viet-vscii-decode-table
))
164 "CCL program to decode VSCII-1.")
166 (define-ccl-program ccl-encode-vscii
172 (write-read-repeat r0
)
174 (if (r0 != ,leading-code-private-11
)
176 (write-read-repeat r0
)
177 (read-if (r0 == ,(charset-id 'vietnamese-viscii-lower
))
181 (write-read-repeat r0
,(car viet-vscii-encode-table
)))
182 (if (r0 == ,(charset-id 'vietnamese-viscii-upper
))
186 (write-read-repeat r0
,(cdr viet-viscii-encode-table
)))
188 (write-read-repeat r0
))))))))
189 "CCL program to encode VSCII-1.")
191 (define-ccl-program ccl-encode-vscii-font
193 ;; In: R0:vietnamese-viscii-lower/vietnamese-viscii-upper
195 ;; Out: R1:font code point
196 (if (r0 == ,(charset-id 'vietnamese-viscii-lower
))
197 (r1 = r1
,(car viet-vscii-encode-table
))
198 (r1 = r1
,(cdr viet-vscii-encode-table
)))
200 "CCL program to encode Vietnamese chars to VSCII-1 font.")
204 'vietnamese-viscii
4 ?V
205 "8-bit encoding for Vietnamese VISCII 1.1 (MIME:VISCII)"
206 (cons ccl-decode-viscii ccl-encode-viscii
))
208 (define-coding-system-alias 'viscii
'vietnamese-viscii
)
211 'vietnamese-vscii
4 ?v
212 "8-bit encoding for Vietnamese VSCII-1"
213 (cons ccl-decode-vscii ccl-encode-vscii
))
215 (define-coding-system-alias 'vscii
'vietnamese-vscii
)
218 'vietnamese-viqr
0 ?q
219 "Vietnamese latin transcription (VIQR)"
221 (put 'vietnamese-viqr
'post-read-conversion
'viqr-post-read-conversion
)
222 (put 'vietnamese-viqr
'pre-write-conversion
'viqr-pre-write-conversion
)
224 (define-coding-system-alias 'viqr
'vietnamese-viqr
)
226 (setq font-ccl-encoder-alist
227 (cons (cons "viscii" ccl-encode-viscii-font
) font-ccl-encoder-alist
))
229 (setq font-ccl-encoder-alist
230 (cons (cons "vscii" ccl-encode-vscii-font
) font-ccl-encoder-alist
))
232 (set-language-info-alist
233 "Vietnamese" '((setup-function . setup-vietnamese-environment
)
234 (charset .
(vietnamese-viscii-lower
235 vietnamese-viscii-upper
))
236 (coding-system .
(vietnamese-viscii vietnamese-vscii
238 (sample-text .
"Vietnamese (Ti\e,1*\e(Bng Vi\e,1.\e(Bt) Ch\e,1`\e(Bo b\e,1U\e(Bn")
240 For Vietnamese, Emacs uses special charasets internally.
241 They can be decoded from and encoded to VISCC, VSCII, and VIQR.")
244 ;;; vietnamese.el ends here