Update copyright years.
[emacs.git] / lisp / language / lao-util.el
blobed3fdefe501d24625d8a0a4a18fc129806d7f327
1 ;;; lao-util.el --- utilities for Lao -*- coding: iso-2022-7bit; -*-
3 ;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006
4 ;; Free Software Foundation, Inc.
5 ;; Copyright (C) 1997, 1998, 1999, 2000
6 ;; National Institute of Advanced Industrial Science and Technology (AIST)
7 ;; Registration Number H14PRO021
9 ;; Keywords: multilingual, Lao
11 ;; This file is part of GNU Emacs.
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; any later version.
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
26 ;; Boston, MA 02110-1301, USA.
28 ;;; Commentary:
30 ;;; Code:
32 ;; Setting information of Thai characters.
34 (defconst lao-category-table (make-category-table))
35 (define-category ?c "Lao consonant" lao-category-table)
36 (define-category ?s "Lao semi-vowel" lao-category-table)
37 (define-category ?v "Lao upper/lower vowel" lao-category-table)
38 (define-category ?t "Lao tone" lao-category-table)
40 (let ((l '((?\e(1!\e(B consonant "LETTER KOR KAI'" "CHICKEN")
41 (?\e(1"\e(B consonant "LETTER KHOR KHAI'" "EGG")
42 (?\e(1#\e(B invalid nil)
43 (?\e(1$\e(B consonant "LETTER QHOR QHWARGN" "BUFFALO")
44 (?\e(1%\e(B invalid nil)
45 (? invalid nil)
46 (?\e(1'\e(B consonant "LETTER NGOR NGUU" "SNAKE")
47 (?\e(1(\e(B consonant "LETTER JOR JUA" "BUDDHIST NOVICE")
48 (?\e(1)\e(B invalid nil)
49 (?\e(1*\e(B consonant "LETTER XOR X\"ARNG" "ELEPHANT")
50 (?\e(1+\e(B invalid nil)
51 (?\e(1,\e(B invalid nil)
52 (?\e(1-\e(B consonant "LETTER YOR YUNG" "MOSQUITO")
53 (?\e(1.\e(B invalid nil)
54 (?\e(1.\e(B invalid nil)
55 (?\e(1.\e(B invalid nil)
56 (?\e(1.\e(B invalid nil)
57 (?\e(1.\e(B invalid nil)
58 (?\e(1.\e(B invalid nil)
59 (?\e(14\e(B consonant "LETTER DOR DANG" "NOSE")
60 (?\e(15\e(B consonant "LETTER TOR TAR" "EYE")
61 (?\e(16\e(B consonant "LETTER THOR THUNG" "TO ASK,QUESTION")
62 (?\e(17\e(B consonant "LETTER DHOR DHARM" "FLAG")
63 (?\e(18\e(B invalid nil)
64 (?\e(19\e(B consonant "LETTER NOR NOK" "BIRD")
65 (?\e(1:\e(B consonant "LETTER BOR BED" "FISHHOOK")
66 (?\e(1;\e(B consonant "LETTER POR PAR" "FISH")
67 (?\e(1<\e(B consonant "LETTER HPOR HPER\"" "BEE")
68 (?\e(1=\e(B consonant "LETTER FHOR FHAR" "WALL")
69 (?\e(1>\e(B consonant "LETTER PHOR PHUU" "MOUNTAIN")
70 (?\e(1?\e(B consonant "LETTER FOR FAI" "FIRE")
71 (?\e(1@\e(B invalid nil)
72 (?\e(1A\e(B consonant "LETTER MOR MAR\"" "HORSE")
73 (?\e(1B\e(B consonant "LETTER GNOR GNAR" "MEDICINE")
74 (?\e(1C\e(B consonant "LETTER ROR ROD" "CAR")
75 (?\e(1D\e(B invalid nil)
76 (?\e(1E\e(B consonant "LETTER LOR LIING" "MONKEY")
77 (?\e(1F\e(B invalid nil)
78 (?\e(1G\e(B consonant "LETTER WOR WII" "HAND FAN")
79 (?\e(1H\e(B invalid nil)
80 (?\e(1I\e(B invalid nil)
81 (?\e(1J\e(B consonant "LETTER SOR SEA" "TIGER")
82 (?\e(1K\e(B consonant "LETTER HHOR HHAI" "JAR")
83 (?\e(1L\e(B invalid nil)
84 (?\e(1M\e(B consonant "LETTER OR OOW" "TAKE")
85 (?\e(1N\e(B consonant "LETTER HOR HEA" "BOAT")
86 (?\e(1O\e(B special "ELLIPSIS")
87 (?\e(1P\e(B vowel-base "VOWEL SIGN SARA A")
88 (?\e(1Q\e(B vowel-upper "VOWEL SIGN MAI KAN")
89 (?\e(1R\e(B vowel-base "VOWEL SIGN SARA AR")
90 (?\e(1S\e(B vowel-base "VOWEL SIGN SARA AM")
91 (?\e(1T\e(B vowel-upper "VOWEL SIGN SARA I")
92 (?\e(1U\e(B vowel-upper "VOWEL SIGN SARA II")
93 (?\e(1V\e(B vowel-upper "VOWEL SIGN SARA EU")
94 (?\e(1W\e(B vowel-upper "VOWEL SIGN SARA UR")
95 (?\e(1X\e(B vowel-lower "VOWEL SIGN SARA U")
96 (?\e(1Y\e(B vowel-lower "VOWEL SIGN SARA UU")
97 (?\e(1Z\e(B invalid nil)
98 (?\e(1[\e(B vowel-upper "VOWEL SIGN MAI KONG")
99 (?\e(1\\e(B semivowel-lower "SEMIVOWEL SIGN LO")
100 (?\e(1]\e(B vowel-base "SEMIVOWEL SIGN SARA IA")
101 (?\e(1^\e(B invalid nil)
102 (?\e(1_\e(B invalid nil)
103 (?\e(1`\e(B vowel-base "VOWEL SIGN SARA EE")
104 (?\e(1a\e(B vowel-base "VOWEL SIGN SARA AA")
105 (?\e(1b\e(B vowel-base "VOWEL SIGN SARA OO")
106 (?\e(1c\e(B vowel-base "VOWEL SIGN SARA EI MAI MUAN\"")
107 (?\e(1d\e(B vowel-base "VOWEL SIGN SARA AI MAI MAY")
108 (?\e(1e\e(B invalid nil)
109 (?\e(1f\e(B special "KO LA (REPETITION)")
110 (?\e(1g\e(B invalid nil)
111 (?\e(1h\e(B tone "TONE MAI EK")
112 (?\e(1i\e(B tone "TONE MAI THO")
113 (?\e(1j\e(B tone "TONE MAI TI")
114 (?\e(1k\e(B tone "TONE MAI JADTAWAR")
115 (?\e(1l\e(B tone "CANCELLATION MARK")
116 (?\e(1m\e(B vowel-upper "VOWEL SIGN SARA OR")
117 (?\e(1n\e(B invalid nil)
118 (?\e(1o\e(B invalid nil)
119 (?\e(1p\e(B special "DIGIT ZERO")
120 (?\e(1q\e(B special "DIGIT ONE")
121 (?\e(1r\e(B special "DIGIT TWO")
122 (?\e(1s\e(B special "DIGIT THREE")
123 (?\e(1t\e(B special "DIGIT FOUR")
124 (?\e(1u\e(B special "DIGIT FIVE")
125 (?\e(1v\e(B special "DIGIT SIX")
126 (?\e(1w\e(B special "DIGIT SEVEN")
127 (?\e(1x\e(B special "DIGIT EIGHT")
128 (?\e(1y\e(B special "DIGIT NINE")
129 (?\e(1z\e(B invalid nil)
130 (?\e(1{\e(B invalid nil)
131 (?\e(1|\e(B consonant "LETTER NHOR NHUU" "MOUSE")
132 (?\e(1}\e(B consonant "LETTER MHOR MHAR" "DOG")
133 (?\e(1~\e(B invalid nil)
134 ;; Unicode equivalents
135 (?\e$,1D!\e(B consonant "LETTER KOR KAI'" "CHICKEN")
136 (?\e$,1D"\e(B consonant "LETTER KHOR KHAI'" "EGG")
137 (?\e$,1D$\e(B consonant "LETTER QHOR QHWARGN" "BUFFALO")
138 (?\e$,1D'\e(B consonant "LETTER NGOR NGUU" "SNAKE")
139 (?\e$,1D(\e(B consonant "LETTER JOR JUA" "BUDDHIST NOVICE")
140 (?\e$,1D*\e(B consonant "LETTER XOR X\"ARNG" "ELEPHANT")
141 (?\e$,1D-\e(B consonant "LETTER YOR YUNG" "MOSQUITO")
142 (?\e$,1D4\e(B consonant "LETTER DOR DANG" "NOSE")
143 (?\e$,1D5\e(B consonant "LETTER TOR TAR" "EYE")
144 (?\e$,1D6\e(B consonant "LETTER THOR THUNG" "TO ASK,QUESTION")
145 (?\e$,1D7\e(B consonant "LETTER DHOR DHARM" "FLAG")
146 (?\e$,1D9\e(B consonant "LETTER NOR NOK" "BIRD")
147 (?\e$,1D:\e(B consonant "LETTER BOR BED" "FISHHOOK")
148 (?\e$,1D;\e(B consonant "LETTER POR PAR" "FISH")
149 (?\e$,1D<\e(B consonant "LETTER HPOR HPER\"" "BEE")
150 (?\e$,1D=\e(B consonant "LETTER FHOR FHAR" "WALL")
151 (?\e$,1D>\e(B consonant "LETTER PHOR PHUU" "MOUNTAIN")
152 (?\e$,1D?\e(B consonant "LETTER FOR FAI" "FIRE")
153 (?\e$,1DA\e(B consonant "LETTER MOR MAR\"" "HORSE")
154 (?\e$,1DB\e(B consonant "LETTER GNOR GNAR" "MEDICINE")
155 (?\e$,1DC\e(B consonant "LETTER ROR ROD" "CAR")
156 (?\e$,1DE\e(B consonant "LETTER LOR LIING" "MONKEY")
157 (?\e$,1DG\e(B consonant "LETTER WOR WII" "HAND FAN")
158 (?\e$,1DJ\e(B consonant "LETTER SOR SEA" "TIGER")
159 (?\e$,1DK\e(B consonant "LETTER HHOR HHAI" "JAR")
160 (?\e$,1DM\e(B consonant "LETTER OR OOW" "TAKE")
161 (?\e$,1DN\e(B consonant "LETTER HOR HEA" "BOAT")
162 (?\e$,1DO\e(B special "ELLIPSIS")
163 (?\e$,1DP\e(B vowel-base "VOWEL SIGN SARA A")
164 (?\e$,1DQ\e(B vowel-upper "VOWEL SIGN MAI KAN")
165 (?\e$,1DR\e(B vowel-base "VOWEL SIGN SARA AR")
166 (?\e$,1DS\e(B vowel-base "VOWEL SIGN SARA AM")
167 (?\e$,1DT\e(B vowel-upper "VOWEL SIGN SARA I")
168 (?\e$,1DU\e(B vowel-upper "VOWEL SIGN SARA II")
169 (?\e$,1DV\e(B vowel-upper "VOWEL SIGN SARA EU")
170 (?\e$,1DW\e(B vowel-upper "VOWEL SIGN SARA UR")
171 (?\e$,1DX\e(B vowel-lower "VOWEL SIGN SARA U")
172 (?\e$,1DY\e(B vowel-lower "VOWEL SIGN SARA UU")
173 (?\e$,1D[\e(B vowel-upper "VOWEL SIGN MAI KONG")
174 (?\e$,1D\\e(B semivowel-lower "SEMIVOWEL SIGN LO")
175 (?\e$,1D]\e(B vowel-base "SEMIVOWEL SIGN SARA IA")
176 (?\e$,1D`\e(B vowel-base "VOWEL SIGN SARA EE")
177 (?\e$,1Da\e(B vowel-base "VOWEL SIGN SARA AA")
178 (?\e$,1Db\e(B vowel-base "VOWEL SIGN SARA OO")
179 (?\e$,1Dc\e(B vowel-base "VOWEL SIGN SARA EI MAI MUAN\"")
180 (?\e$,1Dd\e(B vowel-base "VOWEL SIGN SARA AI MAI MAY")
181 (?\e$,1Df\e(B special "KO LA (REPETITION)")
182 (?\e$,1Dh\e(B tone "TONE MAI EK")
183 (?\e$,1Di\e(B tone "TONE MAI THO")
184 (?\e$,1Dj\e(B tone "TONE MAI TI")
185 (?\e$,1Dk\e(B tone "TONE MAI JADTAWAR")
186 (?\e$,1Dl\e(B tone "CANCELLATION MARK")
187 (?\e$,1Dm\e(B vowel-upper "VOWEL SIGN SARA OR")
188 (?\e$,1Dp\e(B special "DIGIT ZERO")
189 (?\e$,1Dq\e(B special "DIGIT ONE")
190 (?\e$,1Dr\e(B special "DIGIT TWO")
191 (?\e$,1Ds\e(B special "DIGIT THREE")
192 (?\e$,1Dt\e(B special "DIGIT FOUR")
193 (?\e$,1Du\e(B special "DIGIT FIVE")
194 (?\e$,1Dv\e(B special "DIGIT SIX")
195 (?\e$,1Dw\e(B special "DIGIT SEVEN")
196 (?\e$,1Dx\e(B special "DIGIT EIGHT")
197 (?\e$,1Dy\e(B special "DIGIT NINE")
198 (?\e$,1D|\e(B consonant "LETTER NHOR NHUU" "MOUSE")
199 (?\e$,1D}\e(B consonant "LETTER MHOR MHAR" "DOG")))
200 elm)
201 (while l
202 (setq elm (car l) l (cdr l))
203 (let ((char (car elm))
204 (ptype (nth 1 elm)))
205 (cond ((eq ptype 'consonant)
206 (modify-category-entry char ?c lao-category-table))
207 ((memq ptype '(vowel-upper vowel-lower))
208 (modify-category-entry char ?v lao-category-table))
209 ((eq ptype 'semivowel-lower)
210 (modify-category-entry char ?s lao-category-table))
211 ((eq ptype 'tone)
212 (modify-category-entry char ?t lao-category-table)))
213 (put-char-code-property char 'phonetic-type ptype)
214 (put-char-code-property char 'name (nth 2 elm))
215 (put-char-code-property char 'meaning (nth 3 elm)))))
217 ;; The general composing rules are as follows:
219 ;; T
220 ;; V T V T
221 ;; CV -> C, CT -> C, CVT -> C, Cv -> C, CvT -> C
222 ;; v v
223 ;; T
224 ;; V T V T
225 ;; CsV -> C, CsT -> C, CsVT -> C, Csv -> C, CvT -> C
226 ;; s s s s s
227 ;; v v
230 ;; where C: consonant, V: vowel upper, v: vowel lower,
231 ;; T: tone mark, s: semivowel lower
233 (defvar lao-composition-pattern
234 "\\cc\\(\\ct\\|\\cv\\ct?\\|\\cs\\(\\ct\\|\\cv\\ct?\\)?\\)"
235 "Regular expression matching a Lao composite sequence.")
237 ;;;###autoload
238 (defun lao-compose-string (str)
239 (with-category-table lao-category-table
240 (let ((idx 0))
241 (while (setq idx (string-match lao-composition-pattern str idx))
242 (compose-string str idx (match-end 0))
243 (setq idx (match-end 0))))
244 str))
246 ;;; LRT: Lao <-> Roman Transcription
248 ;; Upper vowels and tone-marks are put on the letter.
249 ;; Semi-vowel-sign-lo and lower vowels are put under the letter.
251 (defconst lao-transcription-consonant-alist
252 (sort '(;; single consonants
253 ("k" . "\e(1!\e(B")
254 ("kh" . "\e(1"\e(B")
255 ("qh" . "\e(1$\e(B")
256 ("ng" . "\e(1'\e(B")
257 ("j" . "\e(1(\e(B")
258 ("s" . "\e(1J\e(B")
259 ("x" . "\e(1*\e(B")
260 ("y" . "\e(1-\e(B")
261 ("d" . "\e(14\e(B")
262 ("t" . "\e(15\e(B")
263 ("th" . "\e(16\e(B")
264 ("dh" . "\e(17\e(B")
265 ("n" . "\e(19\e(B")
266 ("b" . "\e(1:\e(B")
267 ("p" . "\e(1;\e(B")
268 ("hp" . "\e(1<\e(B")
269 ("fh" . "\e(1=\e(B")
270 ("ph" . "\e(1>\e(B")
271 ("f" . "\e(1?\e(B")
272 ("m" . "\e(1A\e(B")
273 ("gn" . "\e(1B\e(B")
274 ("l" . "\e(1E\e(B")
275 ("r" . "\e(1C\e(B")
276 ("v" . "\e(1G\e(B")
277 ("w" . "\e(1G\e(B")
278 ("hh" . "\e(1K\e(B")
279 ("O" . "\e(1M\e(B")
280 ("h" . "\e(1N\e(B")
281 ("nh" . "\e(1|\e(B")
282 ("mh" . "\e(1}\e(B")
283 ("lh" . ["\e(1K\\e(B"])
284 ;; double consonants
285 ("ngh" . ["\e(1K'\e(B"])
286 ("yh" . ["\e(1K]\e(B"])
287 ("wh" . ["\e(1KG\e(B"])
288 ("hl" . ["\e(1KE\e(B"])
289 ("hy" . ["\e(1K-\e(B"])
290 ("hn" . ["\e(1K9\e(B"])
291 ("hm" . ["\e(1KA\e(B"])
293 (function (lambda (x y) (> (length (car x)) (length (car y)))))))
295 (defconst lao-transcription-semi-vowel-alist
296 '(("r" . "\e(1\\e(B")))
298 (defconst lao-transcription-vowel-alist
299 (sort '(("a" . "\e(1P\e(B")
300 ("ar" . "\e(1R\e(B")
301 ("i" . "\e(1T\e(B")
302 ("ii" . "\e(1U\e(B")
303 ("eu" . "\e(1V\e(B")
304 ("ur" . "\e(1W\e(B")
305 ("u" . "\e(1X\e(B")
306 ("uu" . "\e(1Y\e(B")
307 ("e" . ["\e(1`P\e(B"])
308 ("ee" . "\e(1`\e(B")
309 ("ae" . ["\e(1aP\e(B"])
310 ("aa" . "\e(1a\e(B")
311 ("o" . ["\e(1bP\e(B"])
312 ("oo" . "\e(1b\e(B")
313 ("oe" . ["\e(1`RP\e(B"])
314 ("or" . "\e(1m\e(B")
315 ("er" . ["\e(1`T\e(B"])
316 ("ir" . ["\e(1`U\e(B"])
317 ("ua" . ["\e(1[GP\e(B"])
318 ("uaa" . ["\e(1[G\e(B"])
319 ("ie" . ["\e(1`Q]P\e(B"])
320 ("ia" . ["\e(1`Q]\e(B"])
321 ("ea" . ["\e(1`VM\e(B"])
322 ("eaa" . ["\e(1`WM\e(B"])
323 ("ai" . "\e(1d\e(B")
324 ("ei" . "\e(1c\e(B")
325 ("ao" . ["\e(1`[R\e(B"])
326 ("aM" . "\e(1S\e(B"))
327 (function (lambda (x y) (> (length (car x)) (length (car y)))))))
329 ;; Maa-sakod is put at the tail.
330 (defconst lao-transcription-maa-sakod-alist
331 '(("k" . "\e(1!\e(B")
332 ("g" . "\e(1'\e(B")
333 ("y" . "\e(1-\e(B")
334 ("d" . "\e(14\e(B")
335 ("n" . "\e(19\e(B")
336 ("b" . "\e(1:\e(B")
337 ("m" . "\e(1A\e(B")
338 ("v" . "\e(1G\e(B")
339 ("w" . "\e(1G\e(B")
342 (defconst lao-transcription-tone-alist
343 '(("'" . "\e(1h\e(B")
344 ("\"" . "\e(1i\e(B")
345 ("^" . "\e(1j\e(B")
346 ("+" . "\e(1k\e(B")
347 ("~" . "\e(1l\e(B")))
349 (defconst lao-transcription-punctuation-alist
350 '(("\\0" . "\e(1p\e(B")
351 ("\\1" . "\e(1q\e(B")
352 ("\\2" . "\e(1r\e(B")
353 ("\\3" . "\e(1s\e(B")
354 ("\\4" . "\e(1t\e(B")
355 ("\\5" . "\e(1u\e(B")
356 ("\\6" . "\e(1v\e(B")
357 ("\\7" . "\e(1w\e(B")
358 ("\\8" . "\e(1x\e(B")
359 ("\\9" . "\e(1y\e(B")
360 ("\\\\" . "\e(1f\e(B")
361 ("\\$" . "\e(1O\e(B")))
363 (defconst lao-transcription-pattern
364 (concat
365 "\\("
366 (mapconcat 'car lao-transcription-consonant-alist "\\|")
367 "\\)\\("
368 (mapconcat 'car lao-transcription-semi-vowel-alist "\\|")
369 "\\)?\\(\\("
370 (mapconcat 'car lao-transcription-vowel-alist "\\|")
371 "\\)\\("
372 (mapconcat 'car lao-transcription-maa-sakod-alist "\\|")
373 "\\)?\\("
374 (mapconcat (lambda (x) (regexp-quote (car x)))
375 lao-transcription-tone-alist "\\|")
376 "\\)?\\)?\\|"
377 (mapconcat (lambda (x) (regexp-quote (car x)))
378 lao-transcription-punctuation-alist "\\|")
380 "Regexp of Roman transcription pattern for one Lao syllable.")
382 (defconst lao-transcription-pattern
383 (concat
384 "\\("
385 (regexp-opt (mapcar 'car lao-transcription-consonant-alist))
386 "\\)\\("
387 (regexp-opt (mapcar 'car lao-transcription-semi-vowel-alist))
388 "\\)?\\(\\("
389 (regexp-opt (mapcar 'car lao-transcription-vowel-alist))
390 "\\)\\("
391 (regexp-opt (mapcar 'car lao-transcription-maa-sakod-alist))
392 "\\)?\\("
393 (regexp-opt (mapcar 'car lao-transcription-tone-alist))
394 "\\)?\\)?\\|"
395 (regexp-opt (mapcar 'car lao-transcription-punctuation-alist))
397 "Regexp of Roman transcription pattern for one Lao syllable.")
399 (defconst lao-vowel-reordering-rule
400 '(("\e(1P\e(B" (0 ?\e(1P\e(B) (0 ?\e(1Q\e(B))
401 ("\e(1R\e(B" (0 ?\e(1R\e(B))
402 ("\e(1T\e(B" (0 ?\e(1U\e(B))
403 ("\e(1U\e(B" (0 ?\e(1U\e(B))
404 ("\e(1V\e(B" (0 ?\e(1V\e(B))
405 ("\e(1W\e(B" (0 ?\e(1W\e(B))
406 ("\e(1X\e(B" (0 ?\e(1X\e(B))
407 ("\e(1Y\e(B" (0 ?\e(1Y\e(B))
408 ("\e(1`P\e(B" (?\e(1`\e(B 0 ?\e(1P\e(B) (?\e(1`\e(B 0 ?\e(1Q\e(B))
409 ("\e(1`\e(B" (?\e(1`\e(B 0))
410 ("\e(1aP\e(B" (?\e(1a\e(B 0 ?\e(1P\e(B) (?\e(1a\e(B 0 ?\e(1Q\e(B))
411 ("\e(1a\e(B" (?\e(1a\e(B 0))
412 ("\e(1bP\e(B" (?\e(1b\e(B 0 ?\e(1P\e(B) (0 ?\e(1[\e(B) (?\e(1-\e(B ?\e(1b\e(B 0 ?\e(1Q\e(B) (?\e(1G\e(B ?\e(1b\e(B 0 ?\e(1Q\e(B))
413 ("\e(1b\e(B" (?\e(1b\e(B 0))
414 ("\e(1`RP\e(B" (?\e(1`\e(B 0 ?\e(1R\e(B ?\e(1P\e(B) (0 ?\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1D`\e(B 0 ?\e$,1DV\e(B ?\e$,1DM\e(B))
453 ("\e$,1D`DWDM\e(B" (?\e$,1D`\e(B 0 ?\e$,1DW\e(B ?\e$,1DM\e(B))
454 ("\e$,1Dd\e(B" (?\e$,1Dd\e(B 0))
455 ("\e$,1Dc\e(B" (?\e$,1Dc\e(B 0))
456 ("\e$,1D`D[DR\e(B" (?\e$,1D`\e(B 0 ?\e$,1D[\e(B ?\e$,1DR\e(B))
457 ("\e$,1DS\e(B" (0 ?\e$,1DS\e(B)))
458 "Alist of Lao vowel string vs the corresponding re-ordering rule.
459 Each element has this form:
460 (VOWEL NO-MAA-SAKOD-RULE WITH-MAA-SAKOD-RULE (MAA-SAKOD-0 RULE-0) ...)
462 VOWEL is a vowel string (e.g. \"\e(1`Q]P\e(B\").
464 NO-MAA-SAKOD-RULE is a rule to re-order and modify VOWEL following a
465 consonant. It is a list vowel characters or 0. The element 0
466 indicate the place to embed a consonant.
468 Optional WITH-MAA-SAKOD-RULE is a rule to re-order and modify VOWEL
469 follwoing a consonant and preceding a maa-sakod character. If it is
470 nil, NO-MAA-SAKOD-RULE is used. The maa-sakod character is alwasy
471 appended at the tail.
473 For instance, rule `(\"\e(1`WM\e(B\" (?\e(1`\e(B t ?\e(1W\e(B ?\e(1M\e(B))' tells that this vowel
474 string following a consonant `\e(1!\e(B' should be re-ordered as \"\e(1`!WM\e(B\".
476 Optional (MAA-SAKOD-n RULE-n) are rules specially applied to maa-sakod
477 character MAA-SAKOD-n.")
479 ;;;###autoload
480 (defun lao-transcribe-single-roman-syllable-to-lao (from to &optional str)
481 "Transcribe a Romanized Lao syllable in the region FROM and TO to Lao string.
482 Only the first syllable is transcribed.
483 The value has the form: (START END LAO-STRING), where
484 START and END are the beggining and end positions of the Roman Lao syllable,
485 LAO-STRING is the Lao character transcription of it.
487 Optional 3rd arg STR, if non-nil, is a string to search for Roman Lao
488 syllable. In that case, FROM and TO are indexes to STR."
489 (if str
490 (if (setq from (string-match lao-transcription-pattern str from))
491 (progn
492 (if (>= from to)
493 (setq from nil)
494 (setq to (match-end 0)))))
495 (save-excursion
496 (goto-char from)
497 (if (setq to (re-search-forward lao-transcription-pattern to t))
498 (setq from (match-beginning 0))
499 (setq from nil))))
500 (if from
501 (let* ((consonant (match-string 1 str))
502 (semivowel (match-string 3 str))
503 (vowel (match-string 5 str))
504 (maa-sakod (match-string 8 str))
505 (tone (match-string 9 str))
506 lao-consonant lao-semivowel lao-vowel lao-maa-sakod lao-tone
507 clen cidx)
508 (setq to (match-end 0))
509 (if (not consonant)
510 (setq str (cdr (assoc (match-string 0 str)
511 lao-transcription-punctuation-alist)))
512 (setq lao-consonant
513 (cdr (assoc consonant lao-transcription-consonant-alist)))
514 (if (vectorp lao-consonant)
515 (setq lao-consonant (aref lao-consonant 0)))
516 (setq clen (length lao-consonant))
517 (if semivowel
518 ;; Include semivowel in STR.
519 (setq lao-semivowel
520 (cdr (assoc semivowel lao-transcription-semi-vowel-alist))
521 str (if (= clen 1)
522 (concat lao-consonant lao-semivowel)
523 (concat (substring lao-consonant 0 1) lao-semivowel
524 (substring lao-consonant 1))))
525 (setq str lao-consonant))
526 (if vowel
527 (let (rule)
528 (setq lao-vowel
529 (cdr (assoc vowel lao-transcription-vowel-alist)))
530 (if (vectorp lao-vowel)
531 (setq lao-vowel (aref lao-vowel 0)))
532 (setq rule (assoc lao-vowel lao-vowel-reordering-rule))
533 (if (null maa-sakod)
534 (setq rule (nth 1 rule))
535 (setq lao-maa-sakod
536 (cdr (assoc maa-sakod lao-transcription-maa-sakod-alist))
537 rule
538 (or (cdr (assq (aref lao-maa-sakod 0) (nthcdr 2 rule)))
539 (nth 2 rule)
540 (nth 1 rule))))
541 (or rule
542 (error "Lao vowel %S has no re-ordering rule" lao-vowel))
543 (setq lao-consonant str str "")
544 (while rule
545 (if (= (car rule) 0)
546 (setq str (concat str lao-consonant)
547 cidx (length str))
548 (setq str (concat str (list (car rule)))))
549 (setq rule (cdr rule)))
550 (or cidx
551 (error "Lao vowel %S has malformed re-ordering rule" vowel))
552 ;; Set CIDX to after upper or lower vowel if any.
553 (let ((len (length str)))
554 (while (and (< cidx len)
555 (memq (get-char-code-property (aref str cidx)
556 'phonetic-type)
557 '(vowel-lower vowel-upper)))
558 (setq cidx (1+ cidx))))
559 (if lao-maa-sakod
560 (setq str (concat str lao-maa-sakod)))
561 (if tone
562 (setq lao-tone
563 (cdr (assoc tone lao-transcription-tone-alist))
564 str (concat (substring str 0 cidx) lao-tone
565 (substring str cidx)))))))
566 (list from to (lao-compose-string str)))))
568 ;;;###autoload
569 (defun lao-transcribe-roman-to-lao-string (str)
570 "Transcribe Romanized Lao string STR to Lao character string."
571 (let ((from 0)
572 (to (length str))
573 (lao-str "")
574 val)
575 (while (setq val (lao-transcribe-single-roman-syllable-to-lao from to str))
576 (let ((start (car val))
577 (end (nth 1 val))
578 (lao (nth 2 val)))
579 (if (> start from)
580 (setq lao-str (concat lao-str (substring str from start) lao))
581 (setq lao-str (concat lao-str lao)))
582 (setq from end)))
583 (if (< from to)
584 (concat lao-str (substring str from to))
585 lao-str)))
587 ;;;###autoload
588 (defun lao-post-read-conversion (len)
589 (lao-compose-region (point) (+ (point) len))
590 len)
592 ;;;###autoload
593 (defun lao-composition-function (from to pattern &optional string)
594 "Compose Lao text in the region FROM and TO.
595 The text matches the regular expression PATTERN.
596 Optional 4th argument STRING, if non-nil, is a string containing text
597 to compose.
599 The return value is number of composed characters."
600 (if (< (1+ from) to)
601 (progn
602 (if string
603 (compose-string string from to)
604 (compose-region from to))
605 (- to from))))
607 ;;;###autoload
608 (defun lao-compose-region (from to)
609 (interactive "r")
610 (save-restriction
611 (narrow-to-region from to)
612 (goto-char (point-min))
613 (with-category-table lao-category-table
614 (while (re-search-forward lao-composition-pattern nil t)
615 (compose-region (match-beginning 0) (point))))))
618 (provide 'lao-util)
620 ;;; arch-tag: 1f828781-3cb8-4695-88af-8f33222338ce
621 ;;; lao-util.el ends here