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