]> code.delx.au - gnu-emacs/blob - lisp/language/ind-util.el
Don't require cl.
[gnu-emacs] / lisp / language / ind-util.el
1 ;;; ind-util.el --- Transliteration and Misc. Tools for Indian Languages -*- coding: iso-2022-7bit; -*-
2
3 ;; Copyright (C) 2001 Free Software Foundation, Inc.
4
5 ;; Maintainer: KAWABATA, Taichi <batta@beige.ocn.ne.jp>
6 ;; Keywords: multilingual, Indian, Devanagari
7
8 ;; This file is part of GNU Emacs.
9
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)
13 ;; any later version.
14
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.
19
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.
24
25 ;;; Commentary:
26
27 ;; This file provides conversion between UCS and various
28 ;; transliteration schemes, such as ITRANS, kyoto-harvard and aiba
29 ;; methods. It also provides conversion between IS 13194 and UCS.
30 ;; Finally, this program provides the compatibility support with
31 ;; old implementation of Devanagari script.
32
33 ;;; Code:
34
35 ;;; Transliteration
36
37 ;; The followings provide the various transliteration schemes (such as
38 ;; ITRANS, kyoto-harvard, and Aiba) of Indian scripts. They are also
39 ;; used in quail/indian.el for typing Indian script in Emacs.
40
41 (eval-and-compile
42
43 (defun range (from to)
44 "Make the list of the integers of range FROM to TO."
45 (let (result)
46 (while (<= from to) (setq result (cons to result) to (1- to))) result))
47
48 (defun regexp-of-hashtbl-keys (hashtbl)
49 "Returns the regular expression of hashtable keys."
50 (let ((max-specpdl-size 1000))
51 (regexp-opt
52 (sort
53 (let (dummy)
54 (maphash (function (lambda (key val) (setq dummy (cons key dummy))))
55 hashtbl)
56 dummy)
57 (function (lambda (x y) (> (length x) (length y))))))))
58
59 (defvar indian-dev-base-table
60 '(
61 (;; VOWELS (18)
62 (?\e$,15E\e(B nil) (?\e$,15F\e(B ?\e$,15~\e(B) (?\e$,15G\e(B ?\e$,15\7f\e(B) (?\e$,15H\e(B ?\e$,16 \e(B) (?\e$,15I\e(B ?\e$,16!\e(B) (?\e$,15J\e(B ?\e$,16"\e(B)
63 (?\e$,15K\e(B ?\e$,16#\e(B) (?\e$,15L\e(B ?\e$,16$\e(B) (?\e$,15M\e(B ?\e$,16%\e(B) (?\e$,15N\e(B ?\e$,16&\e(B) (?\e$,15O\e(B ?\e$,16'\e(B) (?\e$,15P\e(B ?\e$,16(\e(B)
64 (?\e$,15Q\e(B ?\e$,16)\e(B) (?\e$,15R\e(B ?\e$,16*\e(B) (?\e$,15S\e(B ?\e$,16+\e(B) (?\e$,15T\e(B ?\e$,16,\e(B) (?\e$,16@\e(B ?\e$,16B\e(B) (?\e$,16A\e(B ?\e$,16C\e(B))
65 (;; CONSONANTS (currently 42, including special cases)
66 ?\e$,15U\e(B ?\e$,15V\e(B ?\e$,15W\e(B ?\e$,15X\e(B ?\e$,15Y\e(B ;; GUTTRULS
67 ?\e$,15Z\e(B ?\e$,15[\e(B ?\e$,15\\e(B ?\e$,15]\e(B ?\e$,15^\e(B ;; PALATALS
68 ?\e$,15_\e(B ?\e$,15`\e(B ?\e$,15a\e(B ?\e$,15b\e(B ?\e$,15c\e(B ;; CEREBRALS
69 ?\e$,15d\e(B ?\e$,15e\e(B ?\e$,15f\e(B ?\e$,15g\e(B ?\e$,15h\e(B ?\e$,15i\e(B ;; DENTALS
70 ?\e$,15j\e(B ?\e$,15k\e(B ?\e$,15l\e(B ?\e$,15m\e(B ?\e$,15n\e(B ;; LABIALS
71 ?\e$,15o\e(B ?\e$,15p\e(B ?\e$,15q\e(B ?\e$,15r\e(B ?\e$,15s\e(B ?\e$,15t\e(B ?\e$,15u\e(B ;; SEMIVOWELS
72 ?\e$,15v\e(B ?\e$,15w\e(B ?\e$,15x\e(B ?\e$,15y\e(B ;; SIBILANTS
73 ?\e$,168\e(B ?\e$,169\e(B ?\e$,16:\e(B ?\e$,16;\e(B ?\e$,16<\e(B ?\e$,16=\e(B ?\e$,16>\e(B ?\e$,16?\e(B ;; NUKTAS
74 "\e$,15\6-5^\e(B" "\e$,15U6-5w\e(B")
75 (;; Misc Symbols (7)
76 ?\e$,15A\e(B ?\e$,15B\e(B ?\e$,15C\e(B ?\e$,15}\e(B ?\e$,16-\e(B ?\e$,160\e(B ?\e$,16D\e(B)
77 (;; Digits (10)
78 ?\e$,16F\e(B ?\e$,16G\e(B ?\e$,16H\e(B ?\e$,16I\e(B ?\e$,16J\e(B ?\e$,16K\e(B ?\e$,16L\e(B ?\e$,16M\e(B ?\e$,16N\e(B ?\e$,16O\e(B)
79 (;; Inscript-extra (4) (#, $, ^, *, ])
80 "\e$,16-5p\e(B" "\e$,15p6-\e(B" "\e$,15d6-5p\e(B" "\e$,15v6-5p\e(B" "\e$,15|\e(B")))
81
82 (defvar indian-pnj-base-table nil)
83 (defvar indian-ori-base-table nil)
84 (defvar indian-bng-base-table nil)
85 (defvar indian-asm-base-table nil)
86 (defvar indian-tlg-base-table nil)
87 (defvar indian-knd-base-table nil)
88 (defvar indian-mlm-base-table nil)
89 (defvar indian-tml-base-table nil)
90
91 (defvar indian-base-table-to-language-alist
92 '((indian-dev-base-table . "Devanagari")
93 (indian-pnj-base-table . "Punjabi")
94 (indian-ori-base-table . "Oriya")
95 (indian-bng-base-table . "Bengali")
96 (indian-asm-base-table . "Assamese")
97 (indian-tlg-base-table . "Telugu")
98 (indian-knd-base-table . "Kannada")
99 (indian-mlm-base-table . "Malayalam")
100 (indian-tml-base-table . "Tamil")))
101
102 (defvar indian-itrans-v5-table
103 '(;; for encode/decode
104 (;; vowels -- 18
105 "a" ("aa" "A") "i" ("ii" "I") "u" ("uu" "U")
106 ("RRi" "R^i") ("LLi" "L^i") (".c" "e.c") nil "e" "ai"
107 "o.c" nil "o" "au" ("RRI" "R^I") ("LLI" "L^I"))
108 (;; consonants -- 40
109 "k" "kh" "g" "gh" ("~N" "N^")
110 "ch" ("Ch" "chh") "j" "jh" ("~n" "JN")
111 "T" "Th" "D" "Dh" "N"
112 "t" "th" "d" "dh" "n" "nh"
113 "p" "ph" "b" "bh" "m"
114 "y" "r" "rh" "l" ("L" "ld") nil ("v" "w")
115 "sh" ("Sh" "shh") "s" "h"
116 "q" "K" "G" ("J" "z") ".D" ".Dh" "f" ("Y" "yh")
117 ("GY" "dny") "x")
118 (;; misc -- 7
119 ".N" (".n" "M") "H" ".a" ".h" ("AUM" "OM") "..")))
120
121 (defvar indian-kyoto-harvard-table
122 '(;; for encode/decode
123 (;; vowel
124 "a" ("A" "aa") "i" ("I" "ii") "u" ("U" "uu")
125 "R" ("L" "lR") nil nil "e" "ai"
126 nil nil "o" "au" ("q" "RR" "Q") ("E" "LL" "lRR"))
127 (;; consonant
128 "k" "kh" "g" "gh" "G"
129 "c" "ch" "j" "jh" "J"
130 "T" "Th" "D" "Dh" "N"
131 "t" "th" "d" "dh" "n" nil
132 "p" "ph" "b" "bh" "m"
133 "y" "r" nil "l" "L" nil "v"
134 ("z" "Z") "S" "s" "h"
135 nil nil nil nil nil nil nil nil
136 nil nil)
137 (;; misc
138 nil "M" "H" "'" nil "." nil)))
139
140 (defvar indian-harvard-table
141 '(;; for encode/decode
142 (;; vowel
143 "a" ("A" "aa") "i" ("I" "ii") "u" ("U" "uu")
144 "R" ("L" "lR") nil nil "e" "ai"
145 nil nil "o" "au" ("RR" "q" "Q") ("LL" "E" "lRR"))
146 (;; consonant
147 "k" "kh" "g" "gh" "G"
148 "c" "ch" "j" "jh" "J"
149 "T" "Th" "D" "Dh" "N"
150 "t" "th" "d" "dh" "n" nil
151 "p" "ph" "b" "bh" "m"
152 "y" "r" nil "l" "L" nil "v"
153 ("z" "Z") "S" "s" "h"
154 nil nil nil nil nil nil nil nil
155 nil nil)
156 (;; misc
157 nil "M" "H" "'" nil "." nil)))
158
159 (defvar indian-tokyo-table
160 '(;; for encode/decode
161 (;; vowel
162 "a" ("A" "aa") "i" ("I" "ii") "u" ("U" "uu")
163 "R" ("L" "lR") nil nil "e" "ai"
164 nil nil "o" "au" ("Q" "RR" "q") ("E" "LL" "lRR"))
165 (;; consonant
166 "k" "kh" "g" "gh" "G"
167 "c" "ch" "j" "jh" "J"
168 "T" "Th" "D" "Dh" "N"
169 "t" "th" "d" "dh" "n" nil
170 "p" "ph" "b" "bh" "m"
171 "y" "r" nil "l" "L" nil "v"
172 ("Z" "z") "S" "s" "h"
173 nil nil nil nil nil nil nil nil
174 nil nil)
175 (;; misc
176 nil "M" "H" "'" nil "." nil)))
177
178 (defvar indian-aiba-table
179 '(;; for encode/decode
180 (;; vowel
181 "a" "aa" "i" "ii" "u" "uu"
182 ".r" ".l" nil nil "e" "ai"
183 nil nil "o" "au" "~r" "~l")
184 (;; consonant
185 "k" "kh" "g" "gh" "^n"
186 "c" "ch" "j" "jh" "~n"
187 ".t" ".th" ".d" ".dh" ".n"
188 "t" "th" "d" "dh" "n" nil
189 "p" "ph" "b" "bh" "m"
190 "y" "r" nil "l" nil nil "v"
191 "^s" ".s" "s" "h"
192 nil nil nil nil nil nil nil nil
193 nil nil)
194 (;; misc
195 nil ".m" ".h" "'" nil "." nil)))
196
197 (defun mapthread (function seq1 &rest seqrest)
198 "Apply FUNCTION to each element of SEQ1 and return result list.
199 If there are several SEQRESTs, FUNCTION is called with that many
200 arguments, with all possible combinations of these multiple SEQUENCES.
201 Thus, if SEQ1 contains 3 elements and SEQ2 contains 5 elements, then
202 FUNCTION will be called 15 times."
203 (if seqrest
204 (mapcar
205 (lambda (x)
206 (apply
207 'mapthread
208 (lambda (&rest y) (apply function x y))
209 seqrest))
210 seq1)
211 (mapcar function seq1)))
212
213 (defun indian--puthash-char (char trans-char hashtbls)
214 (let ((encode-hash (car hashtbls)) ;; char -> trans
215 (decode-hash (cdr hashtbls)) ;; trans -> char
216 )
217 ;; char -- nil / char / string (/ list of vowel & matra)
218 ;; trans-char -- nil / string / list of strings
219 (when (and char trans-char)
220 (if (stringp trans-char) (setq trans-char (list trans-char)))
221 (if (char-valid-p char) (setq char (char-to-string char)))
222 (puthash char (car trans-char) encode-hash)
223 (mapc
224 (lambda (trans)
225 (puthash trans char decode-hash))
226 trans-char))))
227
228 (defun indian--map (f l1 l2)
229 (while l1
230 (funcall f (pop l1) (pop l2))))
231
232 (defun indian--puthash-v (v trans-v hashtbls)
233 (indian--map
234 (lambda (v trans-v)
235 (indian--puthash-char (car v) trans-v hashtbls))
236 v trans-v))
237
238 (defun indian--puthash-c (c trans-c halant hashtbls)
239 (indian--map
240 (lambda (c trans-c)
241 (if (char-valid-p c) (setq c (char-to-string c)))
242 (indian--puthash-char (concat c halant) trans-c hashtbls))
243 c trans-c))
244
245 (defun indian--puthash-m (m trans-m hashtbls)
246 (indian--map
247 (lambda (m trans-m)
248 (indian--puthash-char m trans-m hashtbls))
249 m trans-m))
250
251 (defun indian--puthash-cv (c trans-c v trans-v hashtbls)
252 (indian--map
253 (lambda (c trans-c)
254 (indian--map
255 (lambda (v trans-v)
256 (when (and c trans-c v trans-v)
257 (if (char-valid-p c) (setq c (char-to-string c)))
258 (setq v (if (char-valid-p (cadr v)) (char-to-string (cadr v)) ""))
259 (if (stringp trans-c) (setq trans-c (list trans-c)))
260 (if (stringp trans-v) (setq trans-v (list trans-v)))
261 (indian--puthash-char
262 (concat c v)
263 (apply 'append
264 (mapthread 'concat trans-c trans-v))
265 hashtbls)))
266 v trans-v))
267 c trans-c))
268
269 (defun indian-make-hash (table trans-table)
270 "Indian Transliteration Hash for decode/encode"
271 (let* ((encode-hash (makehash 'equal))
272 (decode-hash (makehash 'equal))
273 (hashtbls (cons encode-hash decode-hash))
274 (vowels (elt table 0))
275 (consonants (elt table 1))
276 (misc (elt table 2))
277 (digits (elt table 3))
278 (halant (char-to-string (elt misc 4)))
279 (trans-vowels (elt trans-table 0))
280 (trans-consonants (elt trans-table 1))
281 (trans-misc (elt trans-table 2))
282 (trans-digits '("0" "1" "2" "3" "4" "5" "6" "7" "8" "9")))
283 (indian--puthash-v vowels trans-vowels hashtbls)
284 (indian--puthash-c consonants trans-consonants halant hashtbls)
285 (indian--puthash-cv consonants trans-consonants
286 vowels trans-vowels hashtbls)
287 (indian--puthash-m misc trans-misc hashtbls)
288 (indian--puthash-m digits trans-digits hashtbls)
289 hashtbls))
290
291 (defvar indian-dev-itrans-v5-hash
292 (indian-make-hash indian-dev-base-table
293 indian-itrans-v5-table))
294 (defvar indian-dev-kyoto-harvard-hash
295 (indian-make-hash indian-dev-base-table
296 indian-kyoto-harvard-table))
297 (defvar indian-dev-aiba-hash
298 (indian-make-hash indian-dev-base-table
299 indian-aiba-table))
300
301 )
302
303 (defmacro indian-translate-region (from to hashtable encode-p)
304 `(save-excursion
305 (save-restriction
306 (let ((regexp ,(regexp-of-hashtbl-keys
307 (if encode-p (car (eval hashtable))
308 (cdr (eval hashtable))))))
309 (narrow-to-region from to)
310 (goto-char (point-min))
311 (while (re-search-forward regexp nil t)
312 (let ((matchstr (gethash (match-string 0)
313 (if ,encode-p
314 (car ,hashtable)
315 (cdr ,hashtable)))))
316 (if matchstr (replace-match matchstr))))))))
317
318 ;;;
319
320 (defun indian-dev-itrans-v5-encode-region (from to)
321 (interactive "r")
322 (indian-translate-region
323 from to indian-dev-itrans-v5-hash t))
324
325 (defun indian-dev-itrans-v5-decode-region (from to)
326 (interactive "r")
327 (indian-translate-region
328 from to indian-dev-itrans-v5-hash nil))
329
330 (defun indian-dev-kyoto-harvard-encode-region (from to)
331 (interactive "r")
332 (indian-translate-region
333 from to indian-dev-kyoto-harvard-hash t))
334
335 (defun indian-dev-kyoto-harvard-decode-region (from to)
336 (interactive "r")
337 (indian-translate-region
338 from to indian-dev-kyoto-harvard-hash nil))
339
340 (defun indian-dev-aiba-encode-region (from to)
341 (interactive "r")
342 (indian-translate-region
343 from to indian-dev-aiba-hash t))
344
345 (defun indian-dev-aiba-decode-region (from to)
346 (interactive "r")
347 (indian-translate-region
348 from to indian-dev-aiba-hash nil))
349
350
351
352
353 ;;; IS 13194 utilities
354
355 ;; The followings provide conversion between IS 13194 (ISCII) and UCS.
356
357 (defvar ucs-devanagari-to-is13194-alist
358 '(;;Unicode vs IS13194 ;; only Devanagari is supported now.
359 (?\x0900 . "[U+0900]")
360 (?\x0901 . "\e(5!\e(B")
361 (?\x0902 . "\e(5"\e(B")
362 (?\x0903 . "\e(5#\e(B")
363 (?\x0904 . "[U+0904]")
364 (?\x0905 . "\e(5$\e(B")
365 (?\x0906 . "\e(5%\e(B")
366 (?\x0907 . "\e(5&\e(B")
367 (?\x0908 . "\e(5'\e(B")
368 (?\x0909 . "\e(5(\e(B")
369 (?\x090a . "\e(5)\e(B")
370 (?\x090b . "\e(5*\e(B")
371 (?\x090c . "\e(5&i\e(B")
372 (?\x090d . "\e(5.\e(B")
373 (?\x090e . "\e(5+\e(B")
374 (?\x090f . "\e(5,\e(B")
375 (?\x0910 . "\e(5-\e(B")
376 (?\x0911 . "\e(52\e(B")
377 (?\x0912 . "\e(5/\e(B")
378 (?\x0913 . "\e(50\e(B")
379 (?\x0914 . "\e(51\e(B")
380 (?\x0915 . "\e(53\e(B")
381 (?\x0916 . "\e(54\e(B")
382 (?\x0917 . "\e(55\e(B")
383 (?\x0918 . "\e(56\e(B")
384 (?\x0919 . "\e(57\e(B")
385 (?\x091a . "\e(58\e(B")
386 (?\x091b . "\e(59\e(B")
387 (?\x091c . "\e(5:\e(B")
388 (?\x091d . "\e(5;\e(B")
389 (?\x091e . "\e(5<\e(B")
390 (?\x091f . "\e(5=\e(B")
391 (?\x0920 . "\e(5>\e(B")
392 (?\x0921 . "\e(5?\e(B")
393 (?\x0922 . "\e(5@\e(B")
394 (?\x0923 . "\e(5A\e(B")
395 (?\x0924 . "\e(5B\e(B")
396 (?\x0925 . "\e(5C\e(B")
397 (?\x0926 . "\e(5D\e(B")
398 (?\x0927 . "\e(5E\e(B")
399 (?\x0928 . "\e(5F\e(B")
400 (?\x0929 . "\e(5G\e(B")
401 (?\x092a . "\e(5H\e(B")
402 (?\x092b . "\e(5I\e(B")
403 (?\x092c . "\e(5J\e(B")
404 (?\x092d . "\e(5K\e(B")
405 (?\x092e . "\e(5L\e(B")
406 (?\x092f . "\e(5M\e(B")
407 (?\x0930 . "\e(5O\e(B")
408 (?\x0931 . "\e(5P\e(B")
409 (?\x0932 . "\e(5Q\e(B")
410 (?\x0933 . "\e(5R\e(B")
411 (?\x0934 . "\e(5S\e(B")
412 (?\x0935 . "\e(5T\e(B")
413 (?\x0936 . "\e(5U\e(B")
414 (?\x0937 . "\e(5V\e(B")
415 (?\x0938 . "\e(5W\e(B")
416 (?\x0939 . "\e(5X\e(B")
417 (?\x093a . "[U+093a]")
418 (?\x093b . "[U+093b]")
419 (?\x093c . "\e(5i\e(B")
420 (?\x093d . "\e(5ji\e(B")
421 (?\x093e . "\e(5Z\e(B")
422 (?\x093f . "\e(5[\e(B")
423 (?\x0940 . "\e(5\\e(B")
424 (?\x0941 . "\e(5]\e(B")
425 (?\x0942 . "\e(5^\e(B")
426 (?\x0943 . "\e(5_\e(B")
427 (?\x0944 . "\e(5_i\e(B")
428 (?\x0945 . "\e(5c\e(B")
429 (?\x0946 . "\e(5`\e(B")
430 (?\x0947 . "\e(5a\e(B")
431 (?\x0948 . "\e(5b\e(B")
432 (?\x0949 . "\e(5g\e(B")
433 (?\x094a . "\e(5d\e(B")
434 (?\x094b . "\e(5e\e(B")
435 (?\x094c . "\e(5f\e(B")
436 (?\x094d . "\e(5h\e(B")
437 (?\x094e . "[U+094e]")
438 (?\x094f . "[U+094f]")
439 (?\x0950 . "\e(5!i\e(B")
440 (?\x0951 . "\e(5p5\e(B")
441 (?\x0952 . "\e(5p8\e(B")
442 (?\x0953 . "[DEVANAGARI GRAVE ACCENT]")
443 (?\x0954 . "[DEVANAGARI ACUTE ACCENT]")
444 (?\x0955 . "[U+0955]")
445 (?\x0956 . "[U+0956]")
446 (?\x0957 . "[U+0957]")
447 (?\x0958 . "\e(53i\e(B")
448 (?\x0959 . "\e(54i\e(B")
449 (?\x095a . "\e(55i\e(B")
450 (?\x095b . "\e(5:i\e(B")
451 (?\x095c . "\e(5?i\e(B")
452 (?\x095d . "\e(5@i\e(B")
453 (?\x095e . "\e(5Ii\e(B")
454 (?\x095f . "\e(5N\e(B")
455 (?\x0960 . "\e(5*i\e(B")
456 (?\x0961 . "\e(5'i\e(B")
457 (?\x0962 . "\e(5[i\e(B")
458 (?\x0963 . "\e(5ei\e(B")
459 (?\x0964 . "\e(5j\e(B")
460 (?\x0965 . "\e(5jj\e(B")
461 (?\x0966 . "\e(5q\e(B")
462 (?\x0967 . "\e(5r\e(B")
463 (?\x0968 . "\e(5s\e(B")
464 (?\x0969 . "\e(5t\e(B")
465 (?\x096a . "\e(5u\e(B")
466 (?\x096b . "\e(5v\e(B")
467 (?\x096c . "\e(5w\e(B")
468 (?\x096d . "\e(5x\e(B")
469 (?\x096e . "\e(5y\e(B")
470 (?\x096f . "\e(5z\e(B")
471 (?\x0970 . "[U+0970]")
472 (?\x0971 . "[U+0971]")
473 (?\x0972 . "[U+0972]")
474 (?\x0973 . "[U+0973]")
475 (?\x0974 . "[U+0974]")
476 (?\x0975 . "[U+0975]")
477 (?\x0976 . "[U+0976]")
478 (?\x0977 . "[U+0977]")
479 (?\x0978 . "[U+0978]")
480 (?\x0979 . "[U+0979]")
481 (?\x097a . "[U+097a]")
482 (?\x097b . "[U+097b]")
483 (?\x097c . "[U+097c]")
484 (?\x097d . "[U+097d]")
485 (?\x097e . "[U+097e]")
486 (?\x097f . "[U+097f]")))
487
488 (defvar ucs-bengali-to-is13194-alist nil)
489 (defvar ucs-assamese-to-is13194-alist nil)
490 (defvar ucs-gurmukhi-to-is13194-alist nil)
491 (defvar ucs-gujarati-to-is13194-alist nil)
492 (defvar ucs-oriya-to-is13194-alist nil)
493 (defvar ucs-tamil-to-is13194-alist nil)
494 (defvar ucs-telugu-to-is13194-alist nil)
495 (defvar ucs-malayalam-to-is13194-alist nil)
496
497 (defvar is13194-default-repartory 'devanagari)
498
499 (defvar is13194-repertory-to-ucs-script
500 `((DEF ?\x40 ,is13194-default-repartory)
501 (RMN ?\x41 ,is13194-default-repartory)
502 (DEV ?\x42 devanagari)
503 (BNG ?\x43 bengali)
504 (TML ?\x44 tamil)
505 (TLG ?\x45 telugu)
506 (ASM ?\x46 bengali)
507 (ORI ?\x47 oriya)
508 (KND ?\x48 kannada)
509 (MLM ?\x49 malayalam)
510 (GJR ?\x4a gujarati)
511 (PNJ ?\x4b gurmukhi)))
512
513 ;; for guiding find-variable function.
514 (defvar is13194-to-ucs-devanagari-hashtbl nil)
515 (defvar is13194-to-ucs-devanagari-regexp nil)
516 (defvar is13194-to-ucs-bengali-hashtbl nil)
517 (defvar is13194-to-ucs-bengali-regexp nil)
518 (defvar is13194-to-ucs-assamese-hashtbl nil)
519 (defvar is13194-to-ucs-assamese-regexp nil)
520 (defvar is13194-to-ucs-gurmukhi-hashtbl nil)
521 (defvar is13194-to-ucs-gurmukhi-regexp nil)
522 (defvar is13194-to-ucs-gujarati-hashtbl nil)
523 (defvar is13194-to-ucs-gujarati-regexp nil)
524 (defvar is13194-to-ucs-oriya-hashtbl nil)
525 (defvar is13194-to-ucs-oriya-regexp nil)
526 (defvar is13194-to-ucs-tamil-hashtbl nil)
527 (defvar is13194-to-ucs-tamil-regexp nil)
528 (defvar is13194-to-ucs-telugu-hashtbl nil)
529 (defvar is13194-to-ucs-telugu-regexp nil)
530 (defvar is13194-to-ucs-malayalam-hashtbl nil)
531 (defvar is13194-to-ucs-malayalam-regexp nil)
532
533 (mapc
534 (function (lambda (script)
535 (let ((hashtable (intern (concat "is13194-to-ucs-"
536 (symbol-name script) "-hashtbl" )))
537 (regexp (intern (concat "is13194-to-ucs-"
538 (symbol-name script) "-regexp"))))
539 (set hashtable (make-hash-table :test 'equal :size 128))
540 (mapc
541 (function (lambda (x)
542 (put-char-code-property (decode-char 'ucs (car x))
543 'script script)
544 (put-char-code-property (decode-char 'ucs (car x))
545 'iscii (cdr x))
546 (puthash (cdr x) (char-to-string (decode-char 'ucs (car x)))
547 (eval hashtable))))
548 (eval (intern (concat "ucs-" (symbol-name script)
549 "-to-is13194-alist"))))
550 (set regexp (regexp-of-hashtbl-keys (eval hashtable))))))
551 '(devanagari bengali assamese gurmukhi gujarati
552 oriya tamil telugu malayalam))
553
554 (defvar ucs-to-is13194-regexp
555 ;; only Devanagari is supported now.
556 (concat "[" (char-to-string (decode-char 'ucs #x0900))
557 "-" (char-to-string (decode-char 'ucs #x097f)) "]")
558 "Regexp that matches to conversion")
559
560 (defun ucs-to-iscii-region (from to)
561 "Converts the indian UCS characters in the region to ISCII.
562 Returns new end position."
563 (interactive "r")
564 ;; only Devanagari is supported now.
565 (save-excursion
566 (save-restriction
567 (narrow-to-region from to)
568 (goto-char (point-min))
569 (let* ((current-repertory is13194-default-repartory))
570 (while (re-search-forward ucs-to-is13194-regexp nil t)
571 (replace-match
572 (get-char-code-property (string-to-char (match-string 0))
573 'iscii))))
574 (point-max))))
575
576 (defun iscii-to-ucs-region (from to)
577 "Converts the ISCII characters in the region to UCS.
578 Returns new end position."
579 (interactive "r")
580 ;; only Devanagari is supported now.
581 (save-excursion
582 (save-restriction
583 (narrow-to-region from to)
584 (goto-char (point-min))
585 (let* ((current-repertory is13194-default-repartory)
586 (current-hashtable
587 (intern (concat "is13194-to-ucs-"
588 (symbol-name current-repertory) "-hashtbl")))
589 (current-regexp
590 (intern (concat "is13194-to-ucs-"
591 (symbol-name current-repertory) "-regexp"))))
592 (while (re-search-forward (eval current-regexp) nil t)
593 (replace-match
594 (gethash (match-string 0) (eval current-hashtable) ""))))
595 (point-max))))
596
597 ;;;###autoload
598 (defun indian-compose-region (from to)
599 "Compose the region according to `composition-function-table'. "
600 (interactive "r")
601 (save-excursion
602 (save-restriction
603 (let ((pos from) chars (max to))
604 (narrow-to-region from to)
605 (while (< pos max)
606 (setq chars (compose-chars-after pos))
607 (if chars (setq pos (+ pos chars)) (setq pos (1+ pos))))))))
608
609 ;;;###autoload
610 (defun indian-compose-string (string)
611 (with-temp-buffer
612 (insert string)
613 (indian-compose-region (point-min) (point-max))
614 (buffer-string)))
615
616 ;;;###autoload
617 (defun in-is13194-post-read-conversion (len)
618 (let ((pos (point)) endpos)
619 (setq endpos (iscii-to-ucs-region pos (+ pos len)))
620 (indian-compose-region pos endpos)
621 (- endpos pos)))
622
623 ;;;###autoload
624 (defun in-is13194-pre-write-conversion (from to)
625 (let ((buf (current-buffer)))
626 (set-buffer (generate-new-buffer " *temp*"))
627 (if (stringp from)
628 (insert from)
629 (insert-buffer-substring buf from to))
630 (ucs-to-iscii-region (point-min) (point-max))
631 nil))
632
633
634
635
636 ;;; Backward Compatibility support programs
637
638 ;; The followings provides the conversion from old-implementation of
639 ;; Emacs Devanagari script to UCS.
640
641 (defconst indian-2-colum-to-ucs
642 '(
643 ;; 0 1 2 3 4 5 6 7 8 9 a b c d e f
644 ;;2120 \e$(5!!!"!#!$!%!&!'!(!)!*!+!,!-!.!/\e(B
645 ("\e$(5!!\e(B" . "\e$,15A\e(B")
646 ("\e$(5!"\e(B" . "\e$,15B\e(B")
647 ("\e$(5!#\e(B" . "\e$,15C\e(B")
648 ("\e$(5!$\e(B" . "\e$,15E\e(B")
649 ("\e$(5!%\e(B" . "\e$,15F\e(B")
650 ("\e$(5!&\e(B" . "\e$,15G\e(B")
651 ("\e$(5!'\e(B" . "\e$,15H\e(B")
652 ("\e$(5!(\e(B" . "\e$,15I\e(B")
653 ("\e$(5!)\e(B" . "\e$,15J\e(B")
654 ("\e$(5!*\e(B" . "\e$,15K\e(B")
655 ("\e$(5!*"p\e(B" . "\e$,15p6#\e(B")
656 ("\e$(5!+\e(B" . "\e$,15N\e(B")
657 ("\e$(5!,\e(B" . "\e$,15O\e(B")
658 ("\e$(5!-\e(B" . "\e$,15P\e(B")
659 ("\e$(5!.\e(B" . "\e$,15M\e(B")
660 ("\e$(5!/\e(B" . "\e$,15R\e(B")
661 ;; 0 1 2 3 4 5 6 7 8 9 a b c d e f
662 ;;2130 \e$(5!0!1!2!3!4!5!6!7!8!9!:!;!<!=!>!?\e(B
663 ("\e$(5!0\e(B" . "\e$,15S\e(B")
664 ("\e$(5!1\e(B" . "\e$,15T\e(B")
665 ("\e$(5!2\e(B" . "\e$,15Q\e(B")
666 ("\e$(5!3\e(B" . "\e$,15U\e(B")
667 ("\e$(5!4\e(B" . "\e$,15V\e(B")
668 ("\e$(5!5\e(B" . "\e$,15W\e(B")
669 ("\e$(5!6\e(B" . "\e$,15X\e(B")
670 ("\e$(5!7\e(B" . "\e$,15Y\e(B")
671 ("\e$(5!8\e(B" . "\e$,15Z\e(B")
672 ("\e$(5!9\e(B" . "\e$,15[\e(B")
673 ("\e$(5!:\e(B" . "\e$,15\\e(B")
674 ("\e$(5!;\e(B" . "\e$,15]\e(B")
675 ("\e$(5!<\e(B" . "\e$,15^\e(B")
676 ("\e$(5!=\e(B" . "\e$,15_\e(B")
677 ("\e$(5!>\e(B" . "\e$,15`\e(B")
678 ("\e$(5!?\e(B" . "\e$,15a\e(B")
679 ;; 0 1 2 3 4 5 6 7 8 9 a b c d e f
680 ;;2140 \e$(5!@!A!B!C!D!E!F!G!H!I!J!K!L!M!N!O\e(B
681 ("\e$(5!@\e(B" . "\e$,15b\e(B")
682 ("\e$(5!A\e(B" . "\e$,15c\e(B")
683 ("\e$(5!B\e(B" . "\e$,15d\e(B")
684 ("\e$(5!C\e(B" . "\e$,15e\e(B")
685 ("\e$(5!D\e(B" . "\e$,15f\e(B")
686 ("\e$(5!E\e(B" . "\e$,15g\e(B")
687 ("\e$(5!F\e(B" . "\e$,15h\e(B")
688 ("\e$(5!G\e(B" . "\e$,15i\e(B")
689 ("\e$(5!H\e(B" . "\e$,15j\e(B")
690 ("\e$(5!I\e(B" . "\e$,15k\e(B")
691 ("\e$(5!J\e(B" . "\e$,15l\e(B")
692 ("\e$(5!K\e(B" . "\e$,15m\e(B")
693 ("\e$(5!L\e(B" . "\e$,15n\e(B")
694 ("\e$(5!M\e(B" . "\e$,15o\e(B")
695 ("\e$(5!N\e(B" . "\e$,16?\e(B")
696 ("\e$(5!O\e(B" . "\e$,15p\e(B")
697 ;; 0 1 2 3 4 5 6 7 8 9 a b c d e f
698 ;;2150 \e$(5!P!Q!R!S!T!U!V!W!X!Y!Z![!\!]!^!_\e(B
699 ("\e$(5!P\e(B" . "\e$,15q\e(B")
700 ("\e$(5!Q\e(B" . "\e$,15r\e(B")
701 ("\e$(5!R\e(B" . "\e$,15s\e(B")
702 ("\e$(5!S\e(B" . "\e$,15t\e(B")
703 ("\e$(5!T\e(B" . "\e$,15u\e(B")
704 ("\e$(5!U\e(B" . "\e$,15v\e(B")
705 ("\e$(5!V\e(B" . "\e$,15w\e(B")
706 ("\e$(5!W\e(B" . "\e$,15x\e(B")
707 ("\e$(5!X\e(B" . "\e$,15y\e(B")
708 ("\e$(5!Z\e(B" . "\e$,15~\e(B")
709 ("\e$(5![\e(B" . "\e$,15\7f\e(B")
710 ("\e$(5!\\e(B" . "\e$,16 \e(B")
711 ("\e$(5!]\e(B" . "\e$,16!\e(B")
712 ("\e$(5!^\e(B" . "\e$,16"\e(B")
713 ("\e$(5!_\e(B" . "\e$,16#\e(B")
714 ;; 0 1 2 3 4 5 6 7 8 9 a b c d e f
715 ;;2160 \e$(5!`!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o\e(B
716 ("\e$(5!`\e(B" . "\e$,16&\e(B")
717 ("\e$(5!a\e(B" . "\e$,16'\e(B")
718 ("\e$(5!b\e(B" . "\e$,16(\e(B")
719 ("\e$(5!c\e(B" . "\e$,16%\e(B")
720 ("\e$(5!d\e(B" . "\e$,16*\e(B")
721 ("\e$(5!e\e(B" . "\e$,16+\e(B")
722 ("\e$(5!f\e(B" . "\e$,16,\e(B")
723 ("\e$(5!g\e(B" . "\e$,16)\e(B")
724 ("\e$(5!h\e(B" . "\e$,16-\e(B")
725 ("\e$(5!i\e(B" . "\e$,15|\e(B")
726 ("\e$(5!j\e(B" . "\e$,16D\e(B")
727 ("\e$(5!j!j\e(B" . "\e$,16E\e(B")
728 ;; 0 1 2 3 4 5 6 7 8 9 a b c d e f
729 ;;2170 \e$(5!p!q!r!s!t!u!v!w!x!y!z!{!|!}!~\e(B
730 ("\e$(5!q\e(B" . "\e$,16F\e(B")
731 ("\e$(5!r\e(B" . "\e$,16G\e(B")
732 ("\e$(5!s\e(B" . "\e$,16H\e(B")
733 ("\e$(5!t\e(B" . "\e$,16I\e(B")
734 ("\e$(5!u\e(B" . "\e$,16J\e(B")
735 ("\e$(5!v\e(B" . "\e$,16K\e(B")
736 ("\e$(5!w\e(B" . "\e$,16L\e(B")
737 ("\e$(5!x\e(B" . "\e$,16M\e(B")
738 ("\e$(5!y\e(B" . "\e$,16N\e(B")
739 ("\e$(5!z\e(B" . "\e$,16O\e(B")
740 ;; 0 1 2 3 4 5 6 7 8 9 a b c d e f
741 ;;2220 \e$(5"!"""#"$"%"&"'"(")"*"+","-"."/\e(B
742 ("\e$(5"!\e(B" . "\e$,16;6-5p\e(B")
743 ("\e$(5""\e(B" . "\e$,16>6-5p\e(B")
744 ("\e$(5"#\e(B" . "\e$,15U6-5p\e(B")
745 ("\e$(5"$\e(B" . "\e$,15W6-5p\e(B")
746 ("\e$(5"%\e(B" . "\e$,15d6-5p\e(B")
747 ("\e$(5"&\e(B" . "\e$,15j6-5p\e(B")
748 ("\e$(5"'\e(B" . "\e$,15k6-5p\e(B")
749 ("\e$(5")\e(B" . "\e$,15v6-5p\e(B")
750 ("\e$(5",\e(B" . "\e$,15p6!\e(B")
751 ("\e$(5"-\e(B" . "\e$,15p6"\e(B")
752 ("\e$(5".\e(B" . "\e$,15q6!\e(B")
753 ("\e$(5"/\e(B" . "\e$,15q6"\e(B")
754 ;; 0 1 2 3 4 5 6 7 8 9 a b c d e f
755 ;;2230 \e$(5"0"1"2"3"4"5"6"7"8"9":";"<"=">"?\e(B
756 ("\e$(5"3\e(B" . "\e$,15U6-\e(B")
757 ("\e$(5"4\e(B" . "\e$,15V6-\e(B")
758 ("\e$(5"5\e(B" . "\e$,15W6-\e(B")
759 ("\e$(5"6\e(B" . "\e$,15X6-\e(B")
760 ("\e$(5"8\e(B" . "\e$,15Z6-\e(B")
761 ("\e$(5"8"q\e(B" . "\e$,15Z6-5p6-\e(B")
762 ("\e$(5":\e(B" . "\e$,15\6-\e(B")
763 ("\e$(5";\e(B" . "\e$,15]6-\e(B")
764 ("\e$(5"<\e(B" . "\e$,15^6-\e(B")
765 ("\e$(5"<\e(B" . "\e$,15^6-\e(B")
766 ;; 0 1 2 3 4 5 6 7 8 9 a b c d e f
767 ;;2240 \e$(5"@"A"B"C"D"E"F"G"H"I"J"K"L"M"N"O\e(B
768 ("\e$(5"A\e(B" . "\e$,15c6-\e(B")
769 ("\e$(5"B\e(B" . "\e$,15d6-\e(B")
770 ("\e$(5"C\e(B" . "\e$,15e6-\e(B")
771 ("\e$(5"E\e(B" . "\e$,15g6-\e(B")
772 ("\e$(5"F\e(B" . "\e$,15h6-\e(B")
773 ("\e$(5"G\e(B" . "\e$,15i6-\e(B")
774 ("\e$(5"H\e(B" . "\e$,15j6-\e(B")
775 ("\e$(5"I\e(B" . "\e$,15k6-\e(B")
776 ("\e$(5"J\e(B" . "\e$,15l6-\e(B")
777 ("\e$(5"J\e(B" . "\e$,15l6-\e(B")
778 ("\e$(5"K\e(B" . "\e$,15m6-\e(B")
779 ("\e$(5"L\e(B" . "\e$,15n6-\e(B")
780 ("\e$(5"M\e(B" . "\e$,15o6-\e(B")
781 ("\e$(5"N\e(B" . "\e$,16?6-\e(B")
782 ;; 0 1 2 3 4 5 6 7 8 9 a b c d e f
783 ;;2250 \e$(5"P"Q"R"S"T"U"V"W"X"Y"Z"["\"]"^"_\e(B
784 ("\e$(5"Q\e(B" . "\e$,15r6-\e(B")
785 ("\e$(5"R\e(B" . "\e$,15s6-\e(B")
786 ("\e$(5"S\e(B" . "\e$,15t6-\e(B")
787 ("\e$(5"T\e(B" . "\e$,15u6-\e(B")
788 ("\e$(5"U\e(B" . "\e$,15v6-\e(B")
789 ("\e$(5"V\e(B" . "\e$,15w6-\e(B")
790 ("\e$(5"W\e(B" . "\e$,15x6-\e(B")
791 ("\e$(5"]\e(B" . "\e$,16-5o\e(B")
792 ;; 0 1 2 3 4 5 6 7 8 9 a b c d e f
793 ;;2260 \e$(5"`"a"b"c"d"e"f"g"h"i"j"k"l"m"n"o\e(B
794 ("\e$(5"`\e(B" . "\e$,15W6-5p6-\e(B")
795 ("\e$(5"a\e(B" . "\e$,15X6-5h6-\e(B")
796 ("\e$(5"c\e(B" . "\e$,15d6-5d6-\e(B")
797 ("\e$(5"d\e(B" . "\e$,15d6-5p6-\e(B")
798 ("\e$(5"e\e(B" . "\e$,15g6-5h6-\e(B")
799 ("\e$(5"f\e(B" . "\e$,15g6-5p6-\e(B")
800 ("\e$(5"g\e(B" . "\e$,15j6-5d6-\e(B")
801 ("\e$(5"h\e(B" . "\e$,15v6-5Z6-\e(B")
802 ("\e$(5"i\e(B" . "\e$,15v6-5p6-\e(B")
803 ("\e$(5"j\e(B" . "\e$,15v6-5u6-\e(B")
804 ("\e$(5"k\e(B" . "\e$,15h6-5h6-\e(B")
805 ("\e$(5"l\e(B" . "\e$,15U6-5w6-\e(B")
806 ("\e$(5"m\e(B" . "\e$,15\6-5^6-\e(B")
807 ;; 0 1 2 3 4 5 6 7 8 9 a b c d e f
808 ;;2270 \e$(5"p"q"r"s"t"u"v"w"x"y"z"{"|"}"~\e(B
809 ("\e$(5"p\e(B" . "\e$,15p6-\e(B")
810 ("\e$(5"q\e(B" . "\e$,16-5p\e(B")
811 ("\e$(5"r\e(B" . "\e$,16-5p\e(B")
812 ("\e$(5"s\e(B" . "\e$,1686-\e(B")
813 ("\e$(5"t\e(B" . "\e$,1696-\e(B")
814 ("\e$(5"u\e(B" . "\e$,16:6-\e(B")
815 ("\e$(5"y\e(B" . "\e$,16>6-\e(B")
816 ("\e$(5"z\e(B" . "\e$,16;6-\e(B")
817 ;; 0 1 2 3 4 5 6 7 8 9 a b c d e f
818 ;;2320 \e$(5#!#"###$#%#&#'#(#)#*#+#,#-#.#/\e(B
819 ("\e$(5#!\e(B" . "\e$,160\e(B")
820 ("\e$(5#&\e(B" . "\e$,15L\e(B")
821 ("\e$(5#&"p\e(B" . "\e$,15p6$\e(B")
822 ("\e$(5#'\e(B" . "\e$,16A\e(B")
823 ("\e$(5#'"p\e(B" . "\e$,15p6C\e(B")
824 ("\e$(5#*\e(B" . "\e$,16@\e(B")
825 ("\e$(5#*"p\e(B" . "\e$,15p6B\e(B")
826 ;; 0 1 2 3 4 5 6 7 8 9 a b c d e f
827 ;;2330 \e$(5#0#1#2#3#4#5#6#7#8#9#:#;#<#=#>#?\e(B
828 ("\e$(5#3\e(B" . "\e$,168\e(B")
829 ("\e$(5#4\e(B" . "\e$,169\e(B")
830 ("\e$(5#5\e(B" . "\e$,16:\e(B")
831 ("\e$(5#:\e(B" . "\e$,16;\e(B")
832 ("\e$(5#?\e(B" . "\e$,16<\e(B")
833 ;; 0 1 2 3 4 5 6 7 8 9 a b c d e f
834 ;;2340 \e$(5#@#A#B#C#D#E#F#G#H#I#J#K#L#M#N#O\e(B
835 ("\e$(5#@\e(B" . "\e$,16=\e(B")
836 ("\e$(5#I\e(B" . "\e$,16>\e(B")
837 ("\e$(5#J\e(B" . "\e$,15}\e(B")
838 ("\e$(5#K\e(B" . "\e$,16$\e(B")
839 ("\e$(5#L\e(B" . "\e$,16B\e(B")
840 ("\e$(5#M\e(B" . "\e$,16C\e(B")
841 ;; 0 1 2 3 4 5 6 7 8 9 a b c d e f
842 ;;2350 \e$(5#P#Q#R#S#T#U#V#W#X#Y#Z#[#\#]#^#_\e(B
843 ("\e$(5#P\e(B" . "\e$,15n6-5h\e(B")
844 ("\e$(5#Q\e(B" . "\e$,15n6-5r\e(B")
845 ("\e$(5#R\e(B" . "\e$,15y6#\e(B")
846 ;; 0 1 2 3 4 5 6 7 8 9 a b c d e f
847 ;;2360 \e$(5#`#a#b#c#d#e#f#g#h#i#j#k#l#m#n#o\e(B
848 ("\e$(5#`\e(B" . "\e$,15r6-5r\e(B")
849 ("\e$(5#a\e(B" . "\e$,15u6-5h\e(B")
850 ("\e$(5#b\e(B" . "\e$,15u6-5u\e(B")
851 ("\e$(5#c\e(B" . "\e$,15v6-5Z\e(B")
852 ("\e$(5#d\e(B" . "\e$,15v6-5h\e(B")
853 ("\e$(5#e\e(B" . "\e$,15v6-5l\e(B")
854 ("\e$(5#f\e(B" . "\e$,15v6-5r\e(B")
855 ("\e$(5#g\e(B" . "\e$,15v6-5u\e(B")
856 ("\e$(5#h\e(B" . "\e$,15w6-5_6-5p6-5o\e(B")
857 ("\e$(5#i\e(B" . "\e$,15w6-5_6-5o\e(B")
858 ("\e$(5#j\e(B" . "\e$,15w6-5_6-5u\e(B")
859 ("\e$(5#k\e(B" . "\e$,15w6-5_\e(B")
860 ("\e$(5#l\e(B" . "\e$,15w6-5`\e(B")
861 ("\e$(5#m\e(B" . "\e$,15x6-5h\e(B")
862 ("\e$(5#n\e(B" . "\e$,15x6-5p\e(B")
863 ;; 0 1 2 3 4 5 6 7 8 9 a b c d e f
864 ;;2370 \e$(5#p#q#r#s#t#u#v#w#x#y#z#{#|#}#~\e(B
865 ("\e$(5#p\e(B" . "\e$,15y6-5c\e(B")
866 ("\e$(5#q\e(B" . "\e$,15y6-5h\e(B")
867 ("\e$(5#r\e(B" . "\e$,15y6-5n\e(B")
868 ("\e$(5#s\e(B" . "\e$,15y6-5o\e(B")
869 ("\e$(5#t\e(B" . "\e$,15y6-5p\e(B")
870 ("\e$(5#u\e(B" . "\e$,15y6-5r\e(B")
871 ("\e$(5#v\e(B" . "\e$,15y6-5u\e(B")
872 ;; 0 1 2 3 4 5 6 7 8 9 a b c d e f
873 ;;2420 \e$(5$!$"$#$$$%$&$'$($)$*$+$,$-$.$/\e(B
874 ("\e$(5$!\e(B" . "\e$,15U6-5d6-5p6-5o\e(B")
875 ("\e$(5$"\e(B" . "\e$,15U6-5d6-5u\e(B")
876 ("\e$(5$#\e(B" . "\e$,15U6-5d6-5o\e(B")
877 ("\e$(5$$\e(B" . "\e$,15U6-5h6-5o\e(B")
878 ("\e$(5$%\e(B" . "\e$,15U6-5p6-5o\e(B")
879 ("\e$(5$&\e(B" . "\e$,15U6-5u6-5o\e(B")
880 ("\e$(5$'\e(B" . "\e$,15U6-5U\e(B")
881 ("\e$(5$(\e(B" . "\e$,15U6-5d\e(B")
882 ("\e$(5$)\e(B" . "\e$,15U6-5h\e(B")
883 ("\e$(5$*\e(B" . "\e$,15U6-5n\e(B")
884 ("\e$(5$+\e(B" . "\e$,15U6-5o\e(B")
885 ("\e$(5$,\e(B" . "\e$,15U6-5r\e(B")
886 ("\e$(5$-\e(B" . "\e$,15U6-5u\e(B")
887 ("\e$(5$.\e(B" . "\e$,15U6-5w\e(B")
888 ("\e$(5$/\e(B" . "\e$,15X6-5h\e(B")
889 ;; 0 1 2 3 4 5 6 7 8 9 a b c d e f
890 ;;2430 \e$(5$0$1$2$3$4$5$6$7$8$9$:$;$<$=$>$?\e(B
891 ("\e$(5$0\e(B" . "\e$,15Y6-5U6-5d6-5o\e(B")
892 ("\e$(5$1\e(B" . "\e$,15Y6-5U6-5w6-5u\e(B")
893 ("\e$(5$2\e(B" . "\e$,15Y6-5U6-5d\e(B")
894 ("\e$(5$3\e(B" . "\e$,15Y6-5U6-5w\e(B")
895 ("\e$(5$4\e(B" . "\e$,15Y6-5X6-5p\e(B")
896 ("\e$(5$5\e(B" . "\e$,15Y6-5U6-5o\e(B")
897 ("\e$(5$6\e(B" . "\e$,15Y6-5V6-5o\e(B")
898 ("\e$(5$7\e(B" . "\e$,15Y6-5W6-5o\e(B")
899 ("\e$(5$8\e(B" . "\e$,15Y6-5X6-5o\e(B")
900 ("\e$(5$9\e(B" . "\e$,15Y6-5U\e(B")
901 ("\e$(5$:\e(B" . "\e$,15Y6-5V\e(B")
902 ("\e$(5$;\e(B" . "\e$,15Y6-5W\e(B")
903 ("\e$(5$<\e(B" . "\e$,15Y6-5X\e(B")
904 ("\e$(5$=\e(B" . "\e$,15Y6-5Y\e(B")
905 ("\e$(5$>\e(B" . "\e$,15Y6-5h\e(B")
906 ("\e$(5$?\e(B" . "\e$,15Y6-5n\e(B")
907 ;; 0 1 2 3 4 5 6 7 8 9 a b c d e f
908 ;;2440 \e$(5$@$A$B$C$D$E$F$G$H$I$J$K$L$M$N$O\e(B
909 ("\e$(5$@\e(B" . "\e$,15Y6-5o\e(B")
910 ("\e$(5$A\e(B" . "\e$,15Z6-5Z\e(B")
911 ("\e$(5$B\e(B" . "\e$,15Z6-5^\e(B")
912 ("\e$(5$C\e(B" . "\e$,15[6-5o\e(B")
913 ("\e$(5$D\e(B" . "\e$,15\6-5p\e(B")
914 ("\e$(5$E\e(B" . "\e$,15\6-5^\e(B")
915 ("\e$(5$F\e(B" . "\e$,15^6-5Z\e(B")
916 ("\e$(5$G\e(B" . "\e$,15^6-5\\e(B")
917 ("\e$(5$H\e(B" . "\e$,15_6-5U\e(B")
918 ("\e$(5$I\e(B" . "\e$,15_6-5_\e(B")
919 ("\e$(5$J\e(B" . "\e$,15_6-5`\e(B")
920 ("\e$(5$K\e(B" . "\e$,15_6-5o\e(B")
921 ("\e$(5$L\e(B" . "\e$,15`6-5o\e(B")
922 ("\e$(5$M\e(B" . "\e$,15a6-5W6-5o\e(B")
923 ("\e$(5$N\e(B" . "\e$,15a6-5X6-5p\e(B")
924 ("\e$(5$O\e(B" . "\e$,15a6-5p6-5o\e(B")
925 ;; 0 1 2 3 4 5 6 7 8 9 a b c d e f
926 ;;2450 \e$(5$P$Q$R$S$T$U$V$W$X$Y$Z$[$\$]$^$_\e(B
927 ("\e$(5$P\e(B" . "\e$,15a6-5W\e(B")
928 ("\e$(5$Q\e(B" . "\e$,15a6-5X\e(B")
929 ("\e$(5$R\e(B" . "\e$,15a6-5a\e(B")
930 ("\e$(5$S\e(B" . "\e$,15a6-5n\e(B")
931 ("\e$(5$T\e(B" . "\e$,15a6-5o\e(B")
932 ;; 0 1 2 3 4 5 6 7 8 9 a b c d e f
933 ;;2460 \e$(5$`$a$b$c$d$e$f$g$h$i$j$k$l$m$n$o\e(B
934 ("\e$(5$`\e(B" . "\e$,15b6-5o\e(B")
935 ("\e$(5$a\e(B" . "\e$,15d6-5d\e(B")
936 ("\e$(5$b\e(B" . "\e$,15d6-5h\e(B")
937 ("\e$(5$c\e(B" . "\e$,15f6-5f6-5o\e(B")
938 ("\e$(5$d\e(B" . "\e$,15f6-5g6-5o\e(B")
939 ("\e$(5$e\e(B" . "\e$,15f6-5m6-5o\e(B")
940 ("\e$(5$f\e(B" . "\e$,15f6-5p6-5o\e(B")
941 ("\e$(5$g\e(B" . "\e$,15f6-5u6-5o\e(B")
942 ("\e$(5$h\e(B" . "\e$,15f6-5W6-5p\e(B")
943 ("\e$(5$i\e(B" . "\e$,15f6-5X6-5p\e(B")
944 ("\e$(5$j\e(B" . "\e$,15f6-5f6-5u\e(B")
945 ("\e$(5$k\e(B" . "\e$,15f6-5g6-5u\e(B")
946 ("\e$(5$l\e(B" . "\e$,15f6-5W\e(B")
947 ("\e$(5$m\e(B" . "\e$,15f6-5X\e(B")
948 ("\e$(5$n\e(B" . "\e$,15f6-5f\e(B")
949 ("\e$(5$o\e(B" . "\e$,15f6-5g\e(B")
950 ;; 0 1 2 3 4 5 6 7 8 9 a b c d e f
951 ;;2470 \e$(5$p$q$r$s$t$u$v$w$x$y$z${$|$}$~\e(B
952 ("\e$(5$p\e(B" . "\e$,15f6-5h\e(B")
953 ("\e$(5$q\e(B" . "\e$,15f6-5l\e(B")
954 ("\e$(5$r\e(B" . "\e$,15f6-5m\e(B")
955 ("\e$(5$s\e(B" . "\e$,15f6-5n\e(B")
956 ("\e$(5$t\e(B" . "\e$,15f6-5o\e(B")
957 ("\e$(5$u\e(B" . "\e$,15f6-5u\e(B")
958 ("\e$(5$v\e(B" . "\e$,15g6-5h\e(B")
959 ("\e$(5$w\e(B" . "\e$,15h6-5h\e(B")
960 ("\e$(5$x\e(B" . "\e$,15j6-5d\e(B")
961 ("\e$(5$y\e(B" . "\e$,15j6-5h\e(B")
962 ("\e$(5$z\e(B" . "\e$,15j6-5r\e(B")
963 ("\e$(5${\e(B" . "\e$,15l6-5h\e(B")
964 ("\e$(5$|\e(B" . "\e$,15l6-5l\e(B")
965 ("\e$(5$}\e(B" . "\e$,15l6-5u\e(B")
966 ("\e$(5$~\e(B" . "\e$,15m6-5h\e(B")))
967
968 (defconst indian-2-column-to-ucs-regexp
969 "\e$(5!j!j\e(B\\|\e$(5"8"q\e(B\\|[\e$(5#&#'!*#*\e(B]\e$(5"p\e(B\\|[\e$(5!!\e(B-\e$(5$~\e(B]")
970
971 (put 'indian-2-column-to-ucs-chartable 'char-table-extra-slots 1)
972 (defconst indian-2-column-to-ucs-chartable
973 (let ((table (make-char-table 'indian-2-column-to-ucs-chartable))
974 (alist nil))
975 (dolist (elt indian-2-colum-to-ucs)
976 (if (= (length (car elt)) 1)
977 (aset table (aref (car elt) 0) (cdr elt))
978 (setq alist (cons elt alist))))
979 (set-char-table-extra-slot table 0 alist)
980 table))
981
982 (defun indian-2-column-to-ucs-region (from to)
983 "Convert old Emacs Devanagari characters to UCS."
984 (interactive "r")
985 (save-excursion
986 (save-restriction
987 (let ((pos from)
988 (alist (char-table-extra-slot indian-2-column-to-ucs-chartable 0)))
989 (narrow-to-region from to)
990 (decompose-region from to)
991 (goto-char (point-min))
992 (while (re-search-forward indian-2-column-to-ucs-regexp nil t)
993 (let ((len (- (match-end 0) (match-beginning 0)))
994 subst)
995 (if (= len 1)
996 (setq subst (aref indian-2-column-to-ucs-chartable
997 (char-after (match-beginning 0))))
998 (setq subst (assoc (match-string 0) alist)))
999 (replace-match (if subst subst "?"))))
1000 (indian-compose-region (point-min) (point-max))))))
1001
1002 ;;;###autoload
1003 (defun indian-glyph-char (index &optional script)
1004 "Return character of charset `indian-glyph' made from glyph index INDEX.
1005 The variable `indian-default-script' specifies the script of the glyph.
1006 Optional argument SCRIPT, if non-nil, overrides `indian-default-script'.
1007 See also the function `indian-char-glyph'."
1008 (or script
1009 (setq script indian-default-script))
1010 (let ((offset (get script 'indian-glyph-code-offset)))
1011 (or (integerp offset)
1012 (error "Invalid script name: %s" script))
1013 (or (and (>= index 0) (< index 256))
1014 (error "Invalid glyph index: %d" index))
1015 (setq index (+ offset index))
1016 (make-char 'indian-glyph (+ (/ index 96) 32) (+ (% index 96) 32))))
1017
1018 (defvar indian-glyph-max-char
1019 (indian-glyph-char
1020 255 (aref indian-script-table (1- (length indian-script-table))))
1021 "The maximum valid code of characters in the charset `indian-glyph'.")
1022
1023 ;;;###autoload
1024 (defun indian-char-glyph (char)
1025 "Return information about the glphy code for CHAR of `indian-glyph' charset.
1026 The value is (INDEX . SCRIPT), where INDEX is the glyph index
1027 in the font that Indian script name SCRIPT specifies.
1028 See also the function `indian-glyph-char'."
1029 (let ((split (split-char char))
1030 code)
1031 (or (eq (car split) 'indian-glyph)
1032 (error "Charset of `%c' is not indian-glyph" char))
1033 (or (<= char indian-glyph-max-char)
1034 (error "Invalid indian-glyph char: %d" char))
1035 (setq code (+ (* (- (nth 1 split) 32) 96) (nth 2 split) -32))
1036 (cons (% code 256) (aref indian-script-table (/ code 256)))))
1037
1038 (provide 'ind-util)
1039
1040 ;;; ind-util.el ends here