1 ;;; thai-xtis.el --- Support for Thai (XTIS) -*- coding: iso-2022-7bit; -*-
3 ;; Copyright (C) 1999 Electrotechnical Laboratory, JAPAN.
4 ;; Licensed to the Free Software Foundation.
6 ;; Author: TAKAHASHI Naoto <ntakahas@etl.go.jp>
7 ;; MORIOKA Tomohiko <tomo@etl.go.jp>
8 ;; Created: 1998-03-27 for Emacs-20.3 by TAKAHASHI Naoto
9 ;; 1999-03-29 imported and modified for XEmacs by MORIOKA Tomohiko
11 ;; Keywords: mule, multilingual, Thai, XTIS
13 ;; This file is part of XEmacs.
15 ;; XEmacs is free software; you can redistribute it and/or modify it
16 ;; under the terms of the GNU General Public License as published by
17 ;; the Free Software Foundation; either version 2, or (at your option)
20 ;; XEmacs is distributed in the hope that it will be useful, but
21 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 ;; General Public License for more details.
25 ;; You should have received a copy of the GNU General Public License
26 ;; along with XEmacs; see the file COPYING. If not, write to the Free
27 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
32 ;; For Thai, the pre-composed character set proposed by
33 ;; Virach Sornlertlamvanich <virach@links.nectec.or.th> is supported.
37 (when (featurep 'xemacs)
38 (let ((deflist '(;; chars syntax
39 ("
\e$(?!0
\e(B-
\e$(?NxP0R0S0`0
\e(B-
\e$(?e0
\e(B" "w")
40 ("
\e$(?p0
\e(B-
\e$(?y0
\e(B" "w")
41 ("
\e$(?O0f0_0o0z0{0
\e(B" "_")
43 elm chars len syntax to ch i)
45 (setq elm (car deflist))
51 (if (= (aref chars i) ?-)
53 to (nth 1 (split-char (aref chars i))))
54 (setq ch (nth 1 (split-char (aref chars i)))
57 (modify-syntax-entry (vector 'thai-xtis ch) syntax)
60 (setq deflist (cdr deflist))))
62 (put-charset-property 'thai-xtis 'preferred-coding-system 'tis-620)
65 ;; This is the ccl-decode-thai-xtis automaton.
67 ;; "WRITE x y" == (insert (make-char 'thai-xtis x y))
68 ;; "write x" == (insert x)
69 ;; rx' == (tis620-to-thai-xtis-second-byte-bitpattern rx)
70 ;; r3 == "no vower nor tone"
71 ;; r4 == (charset-id 'thai-xtis)
74 ;; state |--------------------------------------------
75 ;; | consonant | vowel | tone
76 ;; ---------+-------------+-------------+----------------
77 ;; r1 == 0 | r1 = r0 | WRITE r0,r3 | WRITE r0,r3
79 ;; ---------+-------------+-------------+----------------
80 ;; r1 == C | WRITE r1,r3 | r2 = r0' | WRITE r1,r3|r0'
81 ;; r2 == 0 | r1 = r0 | | r1 = 0
82 ;; ---------+-------------+-------------+----------------
83 ;; r1 == C | WRITE r1,r2 | WRITE r1,r2 | WRITE r1,r2|r0'
84 ;; r2 == V | r1 = r0 | WRITE r0,r3 | r1 = r2 = 0
85 ;; | r2 = 0 | r1 = r2 = 0 |
89 ;; state |-----------------------------------------
90 ;; | symbol | ASCII | EOF
91 ;; ---------+-------------+-------------+-------------
92 ;; r1 == 0 | WRITE r0,r3 | write r0 |
94 ;; ---------+-------------+-------------+-------------
95 ;; r1 == C | WRITE r1,r3 | WRITE r1,r3 | WRITE r1,r3
96 ;; r2 == 0 | WRITE r0,r3 | write r0 |
97 ;; | r1 = 0 | r1 = 0 |
98 ;; ---------+-------------+-------------+-------------
99 ;; r1 == C | WRITE r1,r2 | WRITE r1,r2 | WRITE r1,r2
100 ;; r2 == V | WRITE r0,r3 | write r0 |
101 ;; | r1 = r2 = 0 | r1 = r2 = 0 |
106 ;; input : r5 = 1st byte, r6 = 2nd byte
107 ;; Their values will be destroyed.
108 (define-ccl-program ccl-thai-xtis-write
110 ((r5 = ((r5 & #x7F) << 7))
111 (r6 = ((r6 & #x7F) | r5))
112 (write-multibyte-character r4 r6))))
114 (define-ccl-program ccl-thai-xtis-consonant
119 ((r5 = r1) (r6 = r3) (call ccl-thai-xtis-write)
121 ((r5 = r1) (r6 = r2) (call ccl-thai-xtis-write)
125 (define-ccl-program ccl-thai-xtis-vowel
128 ((r5 = r0) (r6 = r3) (call ccl-thai-xtis-write))
130 (r2 = ((r0 - 204) << 3))
131 ((r5 = r1) (r6 = r2) (call ccl-thai-xtis-write)
132 (r5 = r0) (r6 = r3) (call ccl-thai-xtis-write)
136 (define-ccl-program ccl-thai-xtis-vowel-d1
139 ((r5 = r0) (r6 = r3) (call ccl-thai-xtis-write))
142 ((r5 = r1) (r6 = r2) (call ccl-thai-xtis-write)
143 (r5 = r0) (r6 = r3) (call ccl-thai-xtis-write)
147 (define-ccl-program ccl-thai-xtis-vowel-ee
150 ((r5 = r0) (r6 = r3) (call ccl-thai-xtis-write))
153 ((r5 = r1) (r6 = r2) (call ccl-thai-xtis-write)
154 (r5 = r0) (r6 = r3) (call ccl-thai-xtis-write)
158 (define-ccl-program ccl-thai-xtis-tone
161 ((r5 = r0) (r6 = r3) (call ccl-thai-xtis-write))
163 ((r5 = r1) (r6 = ((r0 - #xE6) | r3)) (call ccl-thai-xtis-write)
165 ((r5 = r1) (r6 = ((r0 - #xE6) | r2)) (call ccl-thai-xtis-write)
169 (define-ccl-program ccl-thai-xtis-symbol
172 ((r5 = r0) (r6 = r3) (call ccl-thai-xtis-write))
174 ((r5 = r1) (r6 = r3) (call ccl-thai-xtis-write)
175 (r5 = r0) (r6 = r3) (call ccl-thai-xtis-write)
177 ((r5 = r1) (r6 = r2) (call ccl-thai-xtis-write)
178 (r5 = r0) (r6 = r3) (call ccl-thai-xtis-write)
182 (define-ccl-program ccl-thai-xtis-ascii
187 ((r5 = r1) (r6 = r3) (call ccl-thai-xtis-write)
190 ((r5 = r1) (r6 = r2) (call ccl-thai-xtis-write)
195 (define-ccl-program ccl-thai-xtis-eof
199 ((r5 = r1) (r6 = r3) (call ccl-thai-xtis-write))
200 ((r5 = r1) (r6 = r2) (call ccl-thai-xtis-write))))))
202 (define-ccl-program ccl-decode-thai-xtis
208 (r4 = ,(charset-id 'thai-xtis))
211 (call ccl-thai-xtis-ascii)
213 (call ccl-thai-xtis-consonant)
214 (call ccl-thai-xtis-consonant)
215 (call ccl-thai-xtis-consonant)
216 (call ccl-thai-xtis-consonant)
217 (call ccl-thai-xtis-consonant)
218 (call ccl-thai-xtis-consonant)
219 (call ccl-thai-xtis-consonant)
220 (call ccl-thai-xtis-consonant)
221 (call ccl-thai-xtis-consonant)
222 (call ccl-thai-xtis-consonant)
223 (call ccl-thai-xtis-consonant)
224 (call ccl-thai-xtis-consonant)
225 (call ccl-thai-xtis-consonant)
226 (call ccl-thai-xtis-consonant)
227 (call ccl-thai-xtis-consonant)
228 (call ccl-thai-xtis-consonant)
229 (call ccl-thai-xtis-consonant)
230 (call ccl-thai-xtis-consonant)
231 (call ccl-thai-xtis-consonant)
232 (call ccl-thai-xtis-consonant)
233 (call ccl-thai-xtis-consonant)
234 (call ccl-thai-xtis-consonant)
235 (call ccl-thai-xtis-consonant)
236 (call ccl-thai-xtis-consonant)
237 (call ccl-thai-xtis-consonant)
238 (call ccl-thai-xtis-consonant)
239 (call ccl-thai-xtis-consonant)
240 (call ccl-thai-xtis-consonant)
241 (call ccl-thai-xtis-consonant)
242 (call ccl-thai-xtis-consonant)
243 (call ccl-thai-xtis-consonant)
244 (call ccl-thai-xtis-consonant)
245 (call ccl-thai-xtis-consonant)
246 (call ccl-thai-xtis-consonant)
247 (call ccl-thai-xtis-consonant)
248 (call ccl-thai-xtis-symbol)
249 (call ccl-thai-xtis-consonant)
250 (call ccl-thai-xtis-symbol)
251 (call ccl-thai-xtis-consonant)
252 (call ccl-thai-xtis-consonant)
253 (call ccl-thai-xtis-consonant)
254 (call ccl-thai-xtis-consonant)
255 (call ccl-thai-xtis-consonant)
256 (call ccl-thai-xtis-consonant)
257 (call ccl-thai-xtis-consonant)
258 (call ccl-thai-xtis-consonant)
259 (call ccl-thai-xtis-symbol)
260 (call ccl-thai-xtis-symbol)
261 (call ccl-thai-xtis-vowel-d1)
262 (call ccl-thai-xtis-symbol)
263 (call ccl-thai-xtis-symbol)
264 (call ccl-thai-xtis-vowel)
265 (call ccl-thai-xtis-vowel)
266 (call ccl-thai-xtis-vowel)
267 (call ccl-thai-xtis-vowel)
268 (call ccl-thai-xtis-vowel)
269 (call ccl-thai-xtis-vowel)
270 (call ccl-thai-xtis-vowel)
275 (call ccl-thai-xtis-symbol)
276 (call ccl-thai-xtis-symbol)
277 (call ccl-thai-xtis-symbol)
278 (call ccl-thai-xtis-symbol)
279 (call ccl-thai-xtis-symbol)
280 (call ccl-thai-xtis-symbol)
281 (call ccl-thai-xtis-symbol)
282 (call ccl-thai-xtis-symbol)
283 (call ccl-thai-xtis-tone)
284 (call ccl-thai-xtis-tone)
285 (call ccl-thai-xtis-tone)
286 (call ccl-thai-xtis-tone)
287 (call ccl-thai-xtis-tone)
288 (call ccl-thai-xtis-tone)
289 (call ccl-thai-xtis-tone)
290 (call ccl-thai-xtis-vowel-ee)
291 (call ccl-thai-xtis-symbol)
292 (call ccl-thai-xtis-symbol)
293 (call ccl-thai-xtis-symbol)
294 (call ccl-thai-xtis-symbol)
295 (call ccl-thai-xtis-symbol)
296 (call ccl-thai-xtis-symbol)
297 (call ccl-thai-xtis-symbol)
298 (call ccl-thai-xtis-symbol)
299 (call ccl-thai-xtis-symbol)
300 (call ccl-thai-xtis-symbol)
301 (call ccl-thai-xtis-symbol)
302 (call ccl-thai-xtis-symbol)
303 (call ccl-thai-xtis-symbol)
310 (call ccl-thai-xtis-eof)))
314 (defconst leading-code-private-21 #x9F)
316 (define-ccl-program ccl-encode-thai-xtis
320 (if (r0 == ,leading-code-private-21)
322 (if (r1 == ,(charset-id 'thai-xtis))
327 (r0 = ((r0 - #xB0) >> 3))
329 (write r0 [0 209 212 213 214 215 216 217 218 238]))
331 (write r1 [0 231 232 233 234 235 236 237]))
337 (write-read-repeat r0))))))
339 (if (featurep 'xemacs)
343 "external=tis620, internal=thai-xtis"
345 decode ccl-decode-thai-xtis
346 encode ccl-encode-thai-xtis))
347 (coding-system-put 'tis-620 'category 'iso-8-1))
349 'tis-620 4 ?T "external=tis620, internal=thai-xtis"
350 '(ccl-decode-thai-xtis . ccl-encode-thai-xtis)
351 '((safe-charsets . t)))
355 (set-language-info-alist
357 '((charset thai-xtis)
358 (coding-system tis-620 iso-2022-7bit)
359 (tutorial . "TUTORIAL.th")
360 (tutorial-coding-system . tis-620)
361 (coding-priority tis-620 iso-2022-7bit)
362 (sample-text . "
\e$(?!:
\e(B")
363 (documentation . t)))
365 ;; thai-xtis.el ends here.