778
|
1 ;;; indian.el --- support for Indian Languages -*- coding: iso-2022-7bit; -*-
|
771
|
2
|
|
3 ;; Copyright (C) 1995 Free Software Foundation, Inc.
|
|
4
|
|
5 ;; Author: KAWABATA, Taichi <kawabata@is.s.u-tokyo.ac.jp>
|
|
6
|
|
7 ;; Keywords: multilingual, Indian
|
|
8
|
|
9 ;; This file is part of XEmacs.
|
|
10
|
|
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)
|
|
14 ;; any later version.
|
|
15
|
|
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.
|
|
20
|
|
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
|
|
24 ;; 02111-1307, USA.
|
|
25
|
778
|
26 ;;; Synched up with: Emacs 21.1 (language/indian.el).
|
771
|
27
|
|
28 ;;; Commentary:
|
|
29
|
|
30 ;; History:
|
|
31 ;; 1996.10.18 written by KAWABATA, Taichi <kawabata@is.s.u-tokyo.ac.jp>
|
|
32
|
|
33 ;; For Indian, the character set IS 13194 is supported.
|
|
34 ;;
|
|
35 ;; IS 13194 does not specifically assign glyphs for each characters.
|
|
36 ;; Following code is not specific to each Indian language.
|
|
37 ;;
|
|
38 ;; Eventually, this code will support generic information about
|
|
39 ;; following scripts.
|
|
40 ;;
|
|
41 ;; Devanagari
|
|
42 ;; Bengali
|
|
43 ;; Gurmukhi
|
|
44 ;; Gujarati
|
|
45 ;; Oriya
|
|
46 ;; Tamil
|
|
47 ;; Telgu
|
|
48 ;; Kannada
|
|
49 ;; Malayalam
|
|
50 ;;
|
|
51 ;; In this file, charsets other than charset-ascii and charset-indian-is13194
|
|
52 ;; should not be used except in the comment.
|
|
53
|
|
54 ;;; Code:
|
|
55
|
|
56 ;; Followings are what you see when you refer to the Emacs
|
|
57 ;; representations of IS 13194 charcters. However, this is merely
|
|
58 ;; tentative apperance, and you must convert them by
|
|
59 ;; indian-to-xxxxxx(specific script) function to use them.
|
|
60 ;; Devanagari is not an exception of this rule.
|
|
61
|
|
62 ;; 0xa0 //(5!"#$%&'()*+,-./(B
|
|
63 ;; 0xb0 (50123456789:;<=>?(B
|
|
64 ;; 0xc0 (5@ABCDEFGHIJKLMNO(B
|
|
65 ;; 0xd0 (5PQRSTUVWXYZ[\]^_(B
|
|
66 ;; 0xe0 (5`abcdefghijklmno(B
|
|
67 ;; 0xf0 (5pqrstuvwxyz{|}~(B//
|
|
68
|
|
69 ;; Note - In IS 13194, several symbols are obtained by special
|
|
70 ;; combination of several characters and Nukta sign.
|
|
71 ;;
|
|
72 ;; Sanskrit Vowel R -> (5*(B + (5i(B
|
|
73 ;; Sanskrit Vowel L -> (5&(B + (5i(B
|
|
74 ;; Sanskrit Vowel LL -> (5'(B + (5i(B
|
|
75 ;; Sanskrit Avagrah -> (5j(B + (5i(B
|
|
76 ;; OM -> (5!(B + (5i(B
|
|
77 ;;
|
|
78 ;; Note - IS 13194 defines ATR(0xEF) and EXT(0xF0), but they are
|
|
79 ;; not used in Emacs.
|
|
80 ;;
|
|
81 ;; Note - the above characters DO NOT represent any script. For
|
|
82 ;; example, if you want to obtain Devanagari character, you must do
|
|
83 ;; something like the following.
|
|
84 ;;
|
|
85 ;; (char-to-string (indian-to-devanagari ?(5$(B))
|
|
86 ;; "$(5!$(B"
|
|
87
|
|
88 ;;; ITRANS
|
|
89 ;;
|
|
90 ;; ITRANS is one of the most popular method to exchange indian scripts
|
|
91 ;; electronically. Here is the table to convert between ITRANS code and
|
|
92 ;; IS 13194 code.
|
|
93
|
778
|
94 ;; Indian scripts. Symbolic charset for data exchange. Glyphs are
|
|
95 ;; not assigned. They are automatically converted to each Indian
|
|
96 ;; script which IS-13194 supports.
|
|
97
|
|
98 (make-charset 'indian-is13194
|
|
99 "Generic Indian charset for data exchange with IS 13194"
|
|
100 '(dimension
|
|
101 1
|
3659
|
102 registries ["IS13194-Devanagari"]
|
778
|
103 chars 94
|
|
104 columns 2
|
|
105 direction l2r
|
|
106 final ?5
|
|
107 graphic 1
|
|
108 short-name "IS 13194"
|
|
109 long-name "Indian IS 13194"
|
|
110 ))
|
|
111
|
|
112 ;; Actual Glyph for 1-column width.
|
|
113 (make-charset 'indian-1-column
|
|
114 "Indian charset for 2-column width glyphs"
|
|
115 '(dimension
|
|
116 2
|
3659
|
117 registries ["MuleIndian-1"]
|
778
|
118 chars 94
|
|
119 columns 1
|
|
120 direction l2r
|
|
121 final ?6
|
|
122 graphic 0
|
|
123 short-name "Indian 1-col"
|
|
124 long-name "Indian 1 Column"
|
|
125 ))
|
|
126
|
|
127 ;; Actual Glyph for 2-column width.
|
|
128 (make-charset 'indian-2-column
|
|
129 "Indian charset for 2-column width glyphs"
|
|
130 '(dimension
|
|
131 2
|
3659
|
132 registries ["MuleIndian-2"]
|
778
|
133 chars 94
|
|
134 columns 2
|
|
135 direction l2r
|
|
136 final ?5
|
|
137 graphic 0
|
|
138 short-name "Indian 2-col"
|
|
139 long-name "Indian 2 Column"
|
|
140 ))
|
|
141
|
771
|
142 (defvar indian-itrans-consonant-alist
|
|
143 '(
|
|
144 ("k" . "(53(B")
|
|
145 ("kh" . "(54(B")
|
|
146 ("g" . "(55(B")
|
|
147 ("gh" . "(56(B")
|
|
148 ("N^" . "(57(B")
|
|
149 ("ch" . "(58(B")
|
|
150 ("chh" . "(59(B")
|
|
151 ("j" . "(5:(B")
|
|
152 ("jh" . "(5;(B")
|
|
153 ("JN" . "(5<(B")
|
|
154 ("T" . "(5=(B")
|
|
155 ("Th" . "(5>(B")
|
|
156 ("D" . "(5?(B")
|
|
157 ("Dh" . "(5@(B")
|
|
158 ("N" . "(5A(B")
|
|
159 ("t" . "(5B(B")
|
|
160 ("th" . "(5C(B")
|
|
161 ("d" . "(5D(B")
|
|
162 ("dh" . "(5E(B")
|
|
163 ("n" . "(5F(B")
|
|
164 ("nh" . "(5G(B") ; For transcription of non-Devanagari Languages.
|
|
165 ("p" . "(5H(B")
|
|
166 ("ph" . "(5I(B")
|
|
167 ("b" . "(5J(B")
|
|
168 ("bh" . "(5K(B")
|
|
169 ("m" . "(5L(B")
|
|
170 ("y" . "(5M(B")
|
|
171 ("yh" . "(5N(B") ; For transcription of non-Devanagari Languages.
|
|
172 ("r" . "(5O(B")
|
|
173 ("rh" . "(5P(B") ; For transcription of non-Devanagari Languages.
|
|
174 ("l" . "(5Q(B")
|
|
175 ("v" . "(5T(B")
|
|
176 ("sh" . "(5U(B")
|
|
177 ("shh" . "(5V(B")
|
|
178 ("s" . "(5W(B")
|
|
179 ("h" . "(5X(B")
|
|
180 ("ld" . "(5R(B")
|
|
181 ("L" . "(5R(B")
|
|
182 ("ksh" . "$(5!3!h!V(B")
|
|
183 ("GY" . "***GY***") ; Must check out later.
|
|
184 ;; special consonants
|
|
185 ("q" . "(53i(B")
|
|
186 ("K" . "(54i(B")
|
|
187 ("G" . "(55i(B")
|
|
188 ("z" . "(5:i(B")
|
|
189 ("f" . "(5Ii(B")
|
|
190 (".D" . "(5?i(B")
|
|
191 (".Dh" . "(5@i(B")
|
|
192 ))
|
|
193
|
|
194 (defvar indian-itrans-vowel-sign-alist
|
|
195 '(
|
|
196 ;; Special treatment unique to IS 13194 Transliteration
|
|
197 ("" . "(5h(B")
|
|
198 ("a" . "")
|
|
199 ;; Matra (Vowel Sign)
|
|
200 ("aa" . "(5Z(B")
|
|
201 ("A" . "(5Z(B")
|
|
202 ("i" . "(5[(B")
|
|
203 ("ii" . "(5\(B")
|
|
204 ("I" . "(5\(B")
|
|
205 ("u" . "(5](B")
|
|
206 ("uu" . "(5^(B")
|
|
207 ("U" . "(5^(B")
|
|
208 ("R^i" . "(5_(B") ; These must be checked out later.
|
|
209 ("R^I" . "(5_i(B")
|
|
210 ("L^i" . "(5[i(B")
|
|
211 ("L^I" . "(5\i(B")
|
|
212 ("E" . "(5`(B") ; For transcription of non-Devanangri Languages.
|
|
213 ("e" . "(5a(B")
|
|
214 ("ai" . "(5b(B")
|
|
215 ;; ("e.c" . "(5c(B") ; Tentatively suppressed.
|
|
216 ("O" . "(5d(B") ; For transcription of non-Devanagari Languages.
|
|
217 ("o" . "(5e(B")
|
|
218 ("au" . "(5f(B")
|
|
219 ;; ("o.c" . "(5g(B") ; Tentatively suppressed.
|
|
220 ))
|
|
221
|
|
222 ;;
|
|
223 ;; Independent vowels and other signs.
|
|
224 ;;
|
|
225
|
|
226 (defvar indian-itrans-other-letters-alist
|
|
227 '(
|
|
228 ("a" . "(5$(B")
|
|
229 ("aa" . "(5%(B")
|
|
230 ("A" . "(5%(B")
|
|
231 ("i" . "(5&(B")
|
|
232 ("ii" . "(5'(B")
|
|
233 ("I" . "(5'(B")
|
|
234 ("u" . "(5((B")
|
|
235 ("uu" . "(5)(B")
|
|
236 ("U" . "(5)(B")
|
|
237 ("R^i" . "(5*(B")
|
|
238 ("R^I" . "(5*i(B")
|
|
239 ("L^i" . "(5&i(B")
|
|
240 ("L^I" . "(5'i(B")
|
|
241 ("E" . "(5+(B") ; For transcription of non-Devanagari Languages.
|
|
242 ("e" . "(5,(B")
|
|
243 ("ai" . "(5-(B")
|
|
244 ;; ("e.c" . "(5.(B") ; Candra E
|
|
245 ("O" . "(5/(B") ; For transcription of non-Devanagari Languages.
|
|
246 ("o" . "(50(B")
|
|
247 ("au" . "(51(B")
|
|
248 ;; ("o.c" . "(52(B") ; Candra O
|
|
249 ("M" . "(5$(B")
|
|
250 ("H" . "(5#(B")
|
|
251 ("AUM" . "(5!i(B")
|
|
252 ("OM" . "(5!i(B")
|
|
253 (".r" . "(5Oh(B")
|
|
254 (".n" . "(5"(B")
|
|
255 (".N" . "(5!(B")
|
|
256 (".h" . "(5h(B") ; Halant
|
|
257 (".." . "(5j(B")
|
|
258 (".a" . "(5ji(B") ; Avagrah
|
|
259 ("0" . "(5q(B")
|
|
260 ("1" . "(5r(B")
|
|
261 ("2" . "(5s(B")
|
|
262 ("3" . "(5t(B")
|
|
263 ("4" . "(5u(B")
|
|
264 ("5" . "(5v(B")
|
|
265 ("6" . "(5w(B")
|
|
266 ("7" . "(5x(B")
|
|
267 ("8" . "(5y(B")
|
|
268 ("9" . "(5z(B")
|
|
269 ))
|
|
270
|
|
271 ;; Regular expression matching single Indian character represented
|
|
272 ;; by ITRANS.
|
|
273
|
|
274 (defvar indian-itrans-regexp
|
|
275 (let ((consonant "\\([cs]hh?\\)\\|[kgjTDnpbyr]h?\\|\\(N\\^?\\)\\|\\(jN\\)\\|[mvqKGzfs]\\|\\(ld?\\)\\|\\(ksh\\)\\|\\(GY\\)\\|\\(\\.Dh?\\)")
|
|
276 (vowel "\\(a[aiu]\\)\\|\\(ii\\)\\|\\(uu\\)\\|\\([RL]\\^[iI]\\)\\|[AIEOeoaiu]")
|
|
277 (misc "[MH0-9]\\|\\(AUM\\)\\|\\(OM\\)\\|\\(\\.[rnNh\\.a]\\)")
|
|
278 (lpre "\\(") (rpre "\\)") (orre "\\|"))
|
|
279 (concat lpre misc rpre orre
|
|
280 lpre lpre consonant rpre "?" lpre vowel rpre rpre orre
|
|
281 lpre consonant rpre )))
|
|
282
|
|
283 ;;
|
|
284 ;; Regular expression matching single ITRANS unit for IS 13194 characters.
|
|
285 ;;
|
|
286
|
|
287 (defvar itrans-indian-regexp
|
|
288 (let ((vowel "[(5$(B-(52(B]")
|
|
289 (consonant "[(53(B-(5X(B]")
|
|
290 (matra "[(5Z(B-(5g(B]")
|
|
291 (misc "[(5q(B-(5z(B]")
|
|
292 (lpre "\\(") (rpre "\\)") (orre "\\|"))
|
|
293 (concat misc orre
|
|
294 lpre consonant matra "?" rpre orre
|
|
295 vowel)))
|
|
296
|
|
297 ;;
|
|
298 ;; IS13194 - ITRANS conversion table for string matching above regexp.
|
|
299 ;;
|
|
300
|
|
301 (defvar indian-itrans-alist
|
|
302 (let ((cl indian-itrans-consonant-alist)
|
|
303 (ml indian-itrans-other-letters-alist) rules)
|
|
304 (while cl
|
|
305 (let ((vl indian-itrans-vowel-sign-alist))
|
|
306 (while vl
|
|
307 (setq rules
|
|
308 (cons (cons (concat (car (car cl)) (car (car vl)))
|
|
309 (concat (cdr (car cl)) (cdr (car vl))))
|
|
310 rules))
|
|
311 (setq vl (cdr vl))))
|
|
312 (setq cl (cdr cl)))
|
|
313 (while ml
|
|
314 (setq rules (cons (cons (car (car ml))
|
|
315 (cdr (car ml)))
|
|
316 rules))
|
|
317 (setq ml (cdr ml)))
|
|
318 rules))
|
|
319
|
|
320 ;;
|
|
321 ;; Utility program to convert from ITRANS to IS 13194 in specified region.
|
|
322 ;;
|
|
323
|
|
324 (defun indian-decode-itrans-region (from to)
|
|
325 "Convert `ITRANS' mnemonics of the current region to Indian characters.
|
|
326 When called from a program, expects two arguments,
|
|
327 positions (integers or markers) specifying the stretch of the region."
|
|
328 (interactive "r")
|
|
329 (save-restriction
|
|
330 (narrow-to-region from to)
|
|
331 (goto-char (point-min))
|
|
332 (while (re-search-forward indian-itrans-regexp nil t)
|
|
333 (let* ((itrans (buffer-substring (match-beginning 0) (match-end 0)))
|
|
334 (ch (cdr (assoc itrans indian-itrans-alist))))
|
|
335 (if ch
|
|
336 (progn
|
|
337 (delete-region (match-beginning 0) (match-end 0))
|
|
338 (insert ch)))))
|
|
339 (goto-char (point-min))
|
|
340 (while (re-search-forward "\\((5h(B\\)[^\\c0]" nil t)
|
|
341 (delete-region (match-beginning 1) (match-end 1)))))
|
|
342
|
|
343 ;;
|
|
344 ;; Utility program to convert from IS 13194 to ITRANS in specified region.
|
|
345 ;;
|
|
346
|
|
347 (defun indian-encode-itrans-region (from to)
|
|
348 "Convert indian region to ITRANS mnemonics."
|
|
349 (interactive "r")
|
|
350 (save-restriction
|
|
351 (narrow-to-region from to)
|
|
352 (goto-char (point-min))
|
|
353 (while (re-search-forward itrans-indian-regexp nil t)
|
|
354 (let* ((indian (buffer-substring (match-beginning 0) (match-end 0)))
|
|
355 (ch (car (rassoc indian indian-itrans-alist))))
|
|
356 (if ch
|
|
357 (progn
|
|
358 (delete-region (match-beginning 0) (match-end 0))
|
|
359 (insert ch)))))
|
|
360 (goto-char (point-min))))
|
|
361
|
|
362 (provide 'indian)
|
|
363
|
|
364 ;;; indian.el ends here
|