summaryrefslogtreecommitdiff
path: root/lisp/language/ind-util.el
blob: 99a8d080d3b17d6eebc83f15eb00974531c5cb04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
;;; ind-util.el --- Transliteration and Misc. Tools for Indian Languages -*- coding: iso-2022-7bit; -*-

;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
;;   Free Software Foundation, Inc.

;; Maintainer:  KAWABATA, Taichi <kawabata@m17n.org>
;; Keywords: multilingual, Indian, Devanagari

;; This file is part of GNU Emacs.

;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.

;;; Commentary:

;; This file provides conversion between UCS and various
;; transliteration schemes, such as ITRANS, kyoto-harvard and aiba
;; methods.  It also provides conversion between IS 13194 and UCS.
;; Finally, this program provides the compatibility support with
;; old implementation of Devanagari script.

;;; Code:

;;; Transliteration

;; The followings provide the various transliteration schemes (such as
;; ITRANS, kyoto-harvard, and Aiba) of Indian scripts.  They are also
;; used in quail/indian.el for typing Indian script in Emacs.

(eval-and-compile

(defun indian-regexp-of-hashtbl-keys (hashtbl)
  "Returns the regular expression of hashtable keys."
  (let (keys)
    (maphash (lambda (key val) (push key keys)) hashtbl)
    (regexp-opt keys)))

(defvar indian-dev-base-table
  '(
    (;; VOWELS  (18)
     (?$,15E(B nil) (?$,15F(B ?$,15~(B) (?$,15G(B ?$,15(B) (?$,15H(B ?$,16 (B) (?$,15I(B ?$,16!(B) (?$,15J(B ?$,16"(B)
     (?$,15K(B ?$,16#(B) (?$,15L(B ?$,16B(B) (?$,15M(B ?$,16%(B) (?$,15N(B ?$,16&(B) (?$,15O(B ?$,16'(B) (?$,15P(B ?$,16((B)
     (?$,15Q(B ?$,16)(B) (?$,15R(B ?$,16*(B) (?$,15S(B ?$,16+(B) (?$,15T(B ?$,16,(B) (?$,16@(B ?$,16$(B) (?$,16A(B ?$,16C(B))
    (;; CONSONANTS (currently 42, including special cases)
     ?$,15U(B ?$,15V(B ?$,15W(B ?$,15X(B ?$,15Y(B                  ;; GUTTRULS
     ?$,15Z(B ?$,15[(B ?$,15\(B ?$,15](B ?$,15^(B                  ;; PALATALS
     ?$,15_(B ?$,15`(B ?$,15a(B ?$,15b(B ?$,15c(B                  ;; CEREBRALS
     ?$,15d(B ?$,15e(B ?$,15f(B ?$,15g(B ?$,15h(B ?$,15i(B              ;; DENTALS
     ?$,15j(B ?$,15k(B ?$,15l(B ?$,15m(B ?$,15n(B                  ;; LABIALS
     ?$,15o(B ?$,15p(B ?$,15q(B ?$,15r(B ?$,15s(B ?$,15t(B ?$,15u(B          ;; SEMIVOWELS
     ?$,15v(B ?$,15w(B ?$,15x(B ?$,15y(B                    ;; SIBILANTS
     ?$,168(B ?$,169(B ?$,16:(B ?$,16;(B ?$,16<(B ?$,16=(B ?$,16>(B ?$,16?(B      ;; NUKTAS
     "$,15\6-5^(B" "$,15U6-5w(B")
    (;; Misc Symbols (7)
     ?$,15A(B ?$,15B(B ?$,15C(B ?$,15}(B ?$,16-(B ?$,160(B ?$,16D(B)
    (;; Digits (10)
     ?$,16F(B ?$,16G(B ?$,16H(B ?$,16I(B ?$,16J(B ?$,16K(B ?$,16L(B ?$,16M(B ?$,16N(B ?$,16O(B)
    (;; Inscript-extra (4)  (#, $, ^, *, ])
     "$,16-5p(B" "$,15p6-(B" "$,15d6-5p(B" "$,15v6-5p(B" "$,15|(B")))

;; Punjabi is also known as Gurmukhi.
(defvar indian-pnj-base-table
  '(
    (;; VOWELS
     (?$,18%(B nil) (?$,18&(B ?$,18^(B) (?$,18'(B ?$,18_(B) (?$,18((B ?$,18`(B) (?$,18)(B ?$,18a(B) (?$,18*(B ?$,18b(B)
     nil nil nil nil (?$,18/(B ?$,18g(B) (?$,180(B ?$,18h(B)
     nil nil (?$,183(B ?$,18k(B) (?$,184(B ?$,18l(B) nil nil)
    (;; CONSONANTS
     ?$,185(B ?$,186(B ?$,187(B ?$,188(B ?$,189(B                  ;; GUTTRULS
     ?$,18:(B ?$,18;(B ?$,18<(B ?$,18=(B ?$,18>(B                  ;; PALATALS
     ?$,18?(B ?$,18@(B ?$,18A(B ?$,18B(B ?$,18C(B                  ;; CEREBRALS
     ?$,18D(B ?$,18E(B ?$,18F(B ?$,18G(B ?$,18H(B nil              ;; DENTALS
     ?$,18J(B ?$,18K(B ?$,18L(B ?$,18M(B ?$,18N(B                  ;; LABIALS
     ?$,18O(B ?$,18P(B nil ?$,18R(B ?$,18S(B nil ?$,18U(B          ;; SEMIVOWELS
     ?$,18V(B nil ?$,18X(B ?$,18Y(B                    ;; SIBILANTS
     nil ?$,18y(B ?$,18z(B ?$,18{(B ?$,18|(B nil ?$,18~(B nil      ;; NUKTAS
     "$,18<8m8>(B" nil)
    (;; Misc Symbols (7)
     nil ?$,18"(B nil nil ?$,18m(B nil nil) ;; ek onkar, etc.
    (;; Digits
     ?$,19&(B ?$,19'(B ?$,19((B ?$,19)(B ?$,19*(B ?$,19+(B ?$,19,(B ?$,19-(B ?$,19.(B ?$,19/(B)
    (;; Inscript-extra (4)  (#, $, ^, *, ])
     "$,18m8P(B" "$,18P8m(B" "$,18D8m8P(B" "$,18V8m8P(B" "$,18\(B")))

(defvar indian-gjr-base-table
  '(
    (;; VOWELS
     (?$,19E(B nil) (?$,19F(B ?$,19~(B) (?$,19G(B ?$,19(B) (?$,19H(B ?$,1: (B) (?$,19I(B ?$,1:!(B) (?$,19J(B ?$,1:"(B)
     (?$,19K(B ?$,1:#(B) nil (?$,19M(B ?$,1:%(B) nil (?$,19O(B ?$,1:'(B) (?$,19P(B ?$,1:((B)
     (?$,19Q(B ?$,1:)(B) nil (?$,19S(B ?$,1:+(B) (?$,19T(B ?$,1:,(B) (?$,1:@(B ?$,1:$(B) nil)
    (;; CONSONANTS
     ?$,19U(B ?$,19V(B ?$,19W(B ?$,19X(B ?$,19Y(B                  ;; GUTTRULS
     ?$,19Z(B ?$,19[(B ?$,19\(B ?$,19](B ?$,19^(B                  ;; PALATALS
     ?$,19_(B ?$,19`(B ?$,19a(B ?$,19b(B ?$,19c(B                  ;; CEREBRALS
     ?$,19d(B ?$,19e(B ?$,19f(B ?$,19g(B ?$,19h(B nil              ;; DENTALS
     ?$,19j(B ?$,19k(B ?$,19l(B ?$,19m(B ?$,19n(B                  ;; LABIALS
     ?$,19o(B ?$,19p(B nil ?$,19r(B ?$,19s(B nil ?$,19u(B          ;; SEMIVOWELS
     ?$,19v(B ?$,19w(B ?$,19x(B ?$,19y(B                    ;; SIBILANTS
     nil nil nil nil nil nil nil nil      ;; NUKTAS
     "$,19\:-9^(B" "$,19U:-9w(B")
    (;; Misc Symbols (7)
     ?$,19A(B ?$,19B(B ?$,19C(B ?$,19}(B ?$,1:-(B ?$,1:0(B nil)
    (;; Digits
     ?$,1:F(B ?$,1:G(B ?$,1:H(B ?$,1:I(B ?$,1:J(B ?$,1:K(B ?$,1:L(B ?$,1:M(B ?$,1:N(B ?$,1:O(B)
    (;; Inscript-extra (4)  (#, $, ^, *, ])
     "$,1:-9p(B" "$,19p:-(B" "$,19d:-9p(B" "$,19v:-9p(B" "$,19|(B")))

(defvar indian-ori-base-table
  '(
    (;; VOWELS
     (?$,1:e(B nil) (?$,1:f(B ?$,1;>(B) (?$,1:g(B ?$,1;?(B) (?$,1:h(B ?$,1;@(B) (?$,1:i(B ?$,1;A(B) (?$,1:j(B ?$,1;B(B)
     (?$,1:k(B ?$,1;C(B) (?$,1:l(B nil) nil nil (?$,1:o(B ?$,1;G(B) (?$,1:p(B ?$,1;H(B)
     nil nil (?$,1:s(B ?$,1;K(B) (?$,1:t(B ?$,1;L(B) (?$,1;`(B nil) (?$,1;a(B nil))
    (;; CONSONANTS
     ?$,1:u(B ?$,1:v(B ?$,1:w(B ?$,1:x(B ?$,1:y(B                  ;; GUTTRULS
     ?$,1:z(B ?$,1:{(B ?$,1:|(B ?$,1:}(B ?$,1:~(B                  ;; PALATALS
     ?$,1:(B ?$,1; (B ?$,1;!(B ?$,1;"(B ?$,1;#(B                  ;; CEREBRALS
     ?$,1;$(B ?$,1;%(B ?$,1;&(B ?$,1;'(B ?$,1;((B nil              ;; DENTALS
     ?$,1;*(B ?$,1;+(B ?$,1;,(B ?$,1;-(B ?$,1;.(B                  ;; LABIALS
     ?$,1;/(B ?$,1;0(B nil ?$,1;2(B ?$,1;3(B nil nil          ;; SEMIVOWELS
     ?$,1;6(B ?$,1;7(B ?$,1;8(B ?$,1;9(B                    ;; SIBILANTS
     nil nil nil nil ?$,1;\(B ?$,1;](B nil ?$,1;_(B      ;; NUKTAS
     "$,1:|;M:~(B" "$,1:u;M;7(B")
    (;; Misc Symbols
     ?$,1:a(B ?$,1:b(B ?$,1:c(B ?$,1;=(B ?$,1;M(B nil nil)
    (;; Digits
     ?$,1;f(B ?$,1;g(B ?$,1;h(B ?$,1;i(B ?$,1;j(B ?$,1;k(B ?$,1;l(B ?$,1;m(B ?$,1;n(B ?$,1;o(B)
    (;; Inscript-extra (4)  (#, $, ^, *, ])
     "$,1;M;0(B" "$,1;0;M(B" "$,1;$;M;0(B" "$,1;6;M;0(B" "$,1;<(B")))

(defvar indian-bng-base-table
  '(
    (;; VOWELS
     (?$,16e(B nil) (?$,16f(B ?$,17>(B) (?$,16g(B ?$,17?(B) (?$,16h(B ?$,17@(B) (?$,16i(B ?$,17A(B) (?$,16j(B ?$,17B(B)
     (?$,16k(B ?$,17C(B) (?$,16l(B ?$,17b(B) nil nil (?$,16o(B ?$,17G(B) (?$,16p(B ?$,17H(B)
     nil nil (?$,16s(B ?$,17K(B) (?$,16t(B ?$,17L(B) (?$,17`(B ?$,17D(B) (?$,17a(B ?$,17c(B))
    (;; CONSONANTS
     ?$,16u(B ?$,16v(B ?$,16w(B ?$,16x(B ?$,16y(B                  ;; GUTTRULS
     ?$,16z(B ?$,16{(B ?$,16|(B ?$,16}(B ?$,16~(B                  ;; PALATALS
     ?$,16(B ?$,17 (B ?$,17!(B ?$,17"(B ?$,17#(B                  ;; CEREBRALS
     ?$,17$(B ?$,17%(B ?$,17&(B ?$,17'(B ?$,17((B nil              ;; DENTALS
     ?$,17*(B ?$,17+(B ?$,17,(B ?$,17-(B ?$,17.(B                  ;; LABIALS
     ?$,17/(B ?$,170(B nil ?$,172(B nil nil nil          ;; SEMIVOWELS
     ?$,176(B ?$,177(B ?$,178(B ?$,179(B                    ;; SIBILANTS
     nil nil nil nil ?$,17\(B ?$,17](B nil ?$,17_(B      ;; NUKTAS
     "$,16|7M6~(B" "$,16u7M77(B")
    (;; Misc Symbols
     ?$,16a(B ?$,16b(B ?$,16c(B nil ?$,17M(B nil nil)
    (;; Digits
     ?$,17f(B ?$,17g(B ?$,17h(B ?$,17i(B ?$,17j(B ?$,17k(B ?$,17l(B ?$,17m(B ?$,17n(B ?$,17o(B)
    (;; Inscript-extra (4)  (#, $, ^, *, ])
     "$,17M70(B" "$,1707M(B" "$,17$7M70(B" "$,1767M70(B" "$,17<(B")))

(defvar indian-asm-base-table
  '(
    (;; VOWELS
     (?$,16e(B nil) (?$,16f(B ?$,17>(B) (?$,16g(B ?$,17?(B) (?$,16h(B ?$,17@(B) (?$,16i(B ?$,17A(B) (?$,16j(B ?$,17B(B)
     (?$,16k(B ?$,17C(B) (?$,16l(B ?$,17b(B) nil nil (?$,16o(B ?$,17G(B) (?$,16p(B ?$,17H(B)
     nil nil (?$,16s(B ?$,17K(B) (?$,16t(B ?$,17L(B) (?$,17`(B ?$,17D(B) (?$,17a(B ?$,17c(B))
    (;; CONSONANTS
     ?$,16u(B ?$,16v(B ?$,16w(B ?$,16x(B ?$,16y(B                  ;; GUTTRULS
     ?$,16z(B ?$,16{(B ?$,16|(B ?$,16}(B ?$,16~(B                  ;; PALATALS
     ?$,16(B ?$,17 (B ?$,17!(B ?$,17"(B ?$,17#(B                  ;; CEREBRALS
     ?$,17$(B ?$,17%(B ?$,17&(B ?$,17'(B ?$,17((B nil              ;; DENTALS
     ?$,17*(B ?$,17+(B ?$,17,(B ?$,17-(B ?$,17.(B                  ;; LABIALS
     ?$,17/(B ?$,17p(B nil ?$,172(B nil nil ?$,17q(B          ;; SEMIVOWELS
     ?$,176(B ?$,177(B ?$,178(B ?$,179(B                    ;; SIBILANTS
     nil nil nil nil ?$,17\(B ?$,17](B nil ?$,17_(B      ;; NUKTAS
     "$,16|7M6~(B" "$,16u7M77(B")
    (;; Misc Symbols
     ?$,16a(B ?$,16b(B ?$,16c(B nil ?$,17M(B nil nil)
    (;; Digits
     ?$,17f(B ?$,17g(B ?$,17h(B ?$,17i(B ?$,17j(B ?$,17k(B ?$,17l(B ?$,17m(B ?$,17n(B ?$,17o(B)
    (;; Inscript-extra (4)  (#, $, ^, *, ])
     "$,17M7p(B" "$,17p7M(B" "$,17$7M7p(B" "$,1767M7p(B" "$,17<(B")))

(defvar indian-tlg-base-table
  '(
    (;; VOWELS
     (?$,1=E(B nil) (?$,1=F(B ?$,1=~(B) (?$,1=G(B ?$,1=(B) (?$,1=H(B ?$,1> (B) (?$,1=I(B ?$,1>!(B) (?$,1=J(B ?$,1>"(B)
     (?$,1=K(B ?$,1>#(B) (?$,1=L(B nil) nil (?$,1=O(B ?$,1>'(B) (?$,1=N(B ?$,1>&(B) (?$,1=P(B ?$,1>((B)
     nil (?$,1=S(B ?$,1>+(B) (?$,1=R(B ?$,1>*(B) (?$,1=T(B ?$,1>,(B) (?$,1>@(B ?$,1>$(B) (?$,1>A(B nil))
    (;; CONSONANTS
     ?$,1=U(B ?$,1=V(B ?$,1=W(B ?$,1=X(B ?$,1=Y(B                  ;; GUTTRULS
     ?$,1=Z(B ?$,1=[(B ?$,1=\(B ?$,1=](B ?$,1=^(B                  ;; PALATALS
     ?$,1=_(B ?$,1=`(B ?$,1=a(B ?$,1=b(B ?$,1=c(B                  ;; CEREBRALS
     ?$,1=d(B ?$,1=e(B ?$,1=f(B ?$,1=g(B ?$,1=h(B nil              ;; DENTALS
     ?$,1=j(B ?$,1=k(B ?$,1=l(B ?$,1=m(B ?$,1=n(B                  ;; LABIALS
     ?$,1=o(B ?$,1=p(B ?$,1=q(B ?$,1=r(B ?$,1=s(B nil ?$,1=u(B          ;; SEMIVOWELS
     ?$,1=v(B ?$,1=w(B ?$,1=x(B ?$,1=y(B                    ;; SIBILANTS
     nil nil nil nil nil nil nil nil      ;; NUKTAS
     "$,1=\>-=^(B" "$,1=U>-=w(B")
    (;; Misc Symbols
     ?$,1=A(B ?$,1=B(B ?$,1=C(B nil ?$,1>-(B nil nil)
    (;; Digits
     ?$,1>F(B ?$,1>G(B ?$,1>H(B ?$,1>I(B ?$,1>J(B ?$,1>K(B ?$,1>L(B ?$,1>M(B ?$,1>N(B ?$,1>O(B)
    (;; Inscript-extra (4)  (#, $, ^, *, ])
     "$,1>-=p(B" "$,1=p>-(B" "$,1=d>-=p(B" "$,1=v>-=p(B" nil)))

(defvar indian-knd-base-table
  '(
    (;; VOWELS
     (?$,1>e(B nil) (?$,1>f(B ?$,1?>(B) (?$,1>g(B ?$,1??(B) (?$,1>h(B ?$,1?@(B) (?$,1>i(B ?$,1?A(B) (?$,1>j(B ?$,1?B(B)
     (?$,1>k(B ?$,1?C(B) (?$,1>l(B nil) nil (?$,1>o(B ?$,1?G(B) (?$,1>n(B ?$,1?F(B) (?$,1>p(B ?$,1?H(B)
     nil (?$,1>s(B ?$,1?K(B) (?$,1>r(B ?$,1?J(B) (?$,1>t(B ?$,1?L(B) (?$,1?`(B ?$,1?D(B) (?$,1?a(B nil))
    (;; CONSONANTS
     ?$,1>u(B ?$,1>v(B ?$,1>w(B ?$,1>x(B ?$,1>y(B                  ;; GUTTRULS
     ?$,1>z(B ?$,1>{(B ?$,1>|(B ?$,1>}(B ?$,1>~(B                  ;; PALATALS
     ?$,1>(B ?$,1? (B ?$,1?!(B ?$,1?"(B ?$,1?#(B                  ;; CEREBRALS
     ?$,1?$(B ?$,1?%(B ?$,1?&(B ?$,1?'(B ?$,1?((B nil              ;; DENTALS
     ?$,1?*(B ?$,1?+(B ?$,1?,(B ?$,1?-(B ?$,1?.(B                  ;; LABIALS
     ?$,1?/(B ?$,1?0(B ?$,1?1(B ?$,1?2(B ?$,1?3(B nil ?$,1?5(B          ;; SEMIVOWELS
     ?$,1?6(B ?$,1?7(B ?$,1?8(B ?$,1?9(B                    ;; SIBILANTS
     nil nil nil nil nil nil ?$,1?^(B nil      ;; NUKTAS
     "$,1>|?M>~(B" "$,1>u?M?7(B")
    (;; Misc Symbols
     nil ?$,1>b(B ?$,1>c(B nil ?$,1?M(B nil nil)
    (;; Digits
     ?$,1?f(B ?$,1?g(B ?$,1?h(B ?$,1?i(B ?$,1?j(B ?$,1?k(B ?$,1?l(B ?$,1?m(B ?$,1?n(B ?$,1?o(B)
    (;; Inscript-extra (4)  (#, $, ^, *, ])
     "$,1?M?0(B" "$,1?0?M(B" "$,1?$?M?0(B" "$,1?6?M?0(B" nil)))

(defvar indian-mlm-base-table
  '(
    (;; VOWELS
     (?$,1@%(B nil) (?$,1@&(B ?$,1@^(B) (?$,1@'(B ?$,1@_(B) (?$,1@((B ?$,1@`(B) (?$,1@)(B ?$,1@a(B) (?$,1@*(B ?$,1@b(B)
     (?$,1@+(B ?$,1@c(B) (?$,1@,(B nil) nil (?$,1@/(B ?$,1@g(B) (?$,1@.(B ?$,1@f(B) (?$,1@0(B ?$,1@h(B)
     nil (?$,1@3(B ?$,1@k(B) (?$,1@2(B ?$,1@j(B) (?$,1@4(B ?$,1@l(B) nil nil)
    (;; CONSONANTS
     ?$,1@5(B ?$,1@6(B ?$,1@7(B ?$,1@8(B ?$,1@9(B                  ;; GUTTRULS
     ?$,1@:(B ?$,1@;(B ?$,1@<(B ?$,1@=(B ?$,1@>(B                  ;; PALATALS
     ?$,1@?(B ?$,1@@(B ?$,1@A(B ?$,1@B(B ?$,1@C(B                  ;; CEREBRALS
     ?$,1@D(B ?$,1@E(B ?$,1@F(B ?$,1@G(B ?$,1@H(B nil              ;; DENTALS
     ?$,1@J(B ?$,1@K(B ?$,1@L(B ?$,1@M(B ?$,1@N(B                  ;; LABIALS
     ?$,1@O(B ?$,1@P(B ?$,1@Q(B ?$,1@R(B ?$,1@S(B ?$,1@T(B ?$,1@U(B          ;; SEMIVOWELS
     ?$,1@V(B ?$,1@W(B ?$,1@X(B ?$,1@Y(B                    ;; SIBILANTS
     nil nil nil nil nil nil nil nil      ;; NUKTAS
     "$,1@<@m@>(B" "$,1@5@m@W(B")
    (;; Misc Symbols
     nil ?$,1@"(B ?$,1@#(B nil ?$,1@m(B nil nil)
    (;; Digits
     ?$,1A&(B ?$,1A'(B ?$,1A((B ?$,1A)(B ?$,1A*(B ?$,1A+(B ?$,1A,(B ?$,1A-(B ?$,1A.(B ?$,1A/(B)
    (;; Inscript-extra (4)  (#, $, ^, *, ])
     "$,1@m@P(B" "$,1@P@m(B" "$,1@D@m@P(B" "$,1@V@m@P(B" nil)))

(defvar indian-tml-base-table
  '(
    (;; VOWELS
     (?$,1<%(B nil) (?$,1<&(B ?$,1<^(B) (?$,1<'(B ?$,1<_(B) (?$,1<((B ?$,1<`(B) (?$,1<)(B ?$,1<a(B) (?$,1<*(B ?$,1<b(B)
     nil nil nil (?$,1</(B ?$,1<g(B) (?$,1<.(B ?$,1<f(B) (?$,1<0(B ?$,1<h(B)
     nil (?$,1<3(B ?$,1<k(B) (?$,1<2(B ?$,1<j(B) (?$,1<4(B ?$,1<l(B) nil nil)
    (;; CONSONANTS
     ?$,1<5(B nil nil nil ?$,1<9(B                  ;; GUTTRULS
     ?$,1<:(B nil ?$,1<<(B nil ?$,1<>(B                  ;; PALATALS
     ?$,1<?(B nil nil nil ?$,1<C(B                  ;; CEREBRALS
     ?$,1<D(B nil nil nil ?$,1<H(B ?$,1<I(B              ;; DENTALS
     ?$,1<J(B nil nil nil ?$,1<N(B                  ;; LABIALS
     ?$,1<O(B ?$,1<P(B ?$,1<Q(B ?$,1<R(B ?$,1<S(B ?$,1<T(B ?$,1<U(B          ;; SEMIVOWELS
     nil ?$,1<W(B ?$,1<X(B ?$,1<Y(B                    ;; SIBILANTS
     nil nil nil nil nil nil nil nil      ;; NUKTAS
     "$,1<<<m<>(B" "$,1<5<m<W(B")
    (;; Misc Symbols
     nil ?$,1<"(B ?$,1<#(B nil ?$,1<m(B nil nil)
    (;; Digits
     nil ?$,1='(B ?$,1=((B ?$,1=)(B ?$,1=*(B ?$,1=+(B ?$,1=,(B ?$,1=-(B ?$,1=.(B ?$,1=/(B)
    (;; Inscript-extra (4)  (#, $, ^, *, ])
     "$,1<m<P(B" "$,1<P<m(B" "$,1<D<m<P(B" nil nil)))

(defvar indian-base-table-to-language-alist
  '((indian-dev-base-table . "Devanagari")
    (indian-pnj-base-table . "Punjabi")
    (indian-ori-base-table . "Oriya")
    (indian-bng-base-table . "Bengali")
    (indian-asm-base-table . "Assamese")
    (indian-tlg-base-table . "Telugu")
    (indian-knd-base-table . "Kannada")
    (indian-mlm-base-table . "Malayalam")
    (indian-tml-base-table . "Tamil")))

(defvar indian-itrans-v5-table
  '(;; for encode/decode
    (;; vowels -- 18
     "a" ("aa" "A") "i" ("ii" "I") "u" ("uu" "U")
     ("RRi" "R^i") ("LLi" "L^i") (".c" "e.c") "E" "e" "ai"
     "o.c"  "O"   "o"   "au"  ("RRI" "R^I") ("LLI" "L^I"))
    (;; consonants -- 40
     "k"   "kh"  "g"   "gh"  ("~N" "N^")
     "ch" ("Ch" "chh") "j" "jh" ("~n" "JN")
     "T"   "Th"  "D"   "Dh"  "N"
     "t"   "th"  "d"   "dh"  "n"   "nh"
     "p"   "ph"  "b"   "bh"  "m"
     "y"   "r"   "rh"  "l"   ("L" "ld") nil  ("v" "w")
     "sh" ("Sh" "shh") "s" "h"
     "q" "K" "G" ("J" "z") ".D" ".Dh" "f" ("Y" "yh")
     ("GY" "dny") "x")
    (;; misc -- 7
     ".N" (".n" "M") "H" ".a" ".h" ("AUM" "OM") "..")))

(defvar indian-kyoto-harvard-table
  '(;; for encode/decode
    (;; vowel
     "a"   ("A" "aa")  "i"   ("I" "ii")  "u"   ("U" "uu")
     "R"   ("L" "lR")  nil   nil   "e"   "ai"
     nil   nil   "o"   "au"  ("q" "RR" "Q")   ("E" "LL" "lRR"))
    (;; consonant
     "k"   "kh"  "g"   "gh"  "G"
     "c"   "ch"  "j"   "jh"  "J"
     "T"   "Th"  "D"   "Dh"  "N"
     "t"   "th"  "d"   "dh"  "n"   nil
     "p"   "ph"  "b"   "bh"  "m"
     "y"   "r"   nil   "l"   "L"   nil   "v"
     ("z" "Z")   "S"   "s"   "h"
     nil   nil   nil   nil   nil   nil   nil   nil
     nil   nil)
    (;; misc
     nil   "M"   "H"   "'"   nil   "." nil)))

(defvar indian-harvard-table
  '(;; for encode/decode
    (;; vowel
     "a"   ("A" "aa")  "i"   ("I" "ii")  "u"   ("U" "uu")
     "R"   ("L" "lR")  nil   nil   "e"   "ai"
     nil   nil   "o"   "au"  ("RR" "q" "Q")   ("LL" "E" "lRR"))
    (;; consonant
     "k"   "kh"  "g"   "gh"  "G"
     "c"   "ch"  "j"   "jh"  "J"
     "T"   "Th"  "D"   "Dh"  "N"
     "t"   "th"  "d"   "dh"  "n"   nil
     "p"   "ph"  "b"   "bh"  "m"
     "y"   "r"   nil   "l"   "L"   nil   "v"
     ("z" "Z")   "S"   "s"   "h"
     nil   nil   nil   nil   nil   nil   nil   nil
     nil   nil)
    (;; misc
     nil   "M"   "H"   "'"   nil   "." nil)))

(defvar indian-tokyo-table
  '(;; for encode/decode
    (;; vowel
     "a"   ("A" "aa")  "i"   ("I" "ii")  "u"   ("U" "uu")
     "R"   ("L" "lR")  nil   nil   "e"   "ai"
     nil   nil   "o"   "au"  ("Q" "RR" "q")   ("E" "LL" "lRR"))
    (;; consonant
     "k"   "kh"  "g"   "gh"  "G"
     "c"   "ch"  "j"   "jh"  "J"
     "T"   "Th"  "D"   "Dh"  "N"
     "t"   "th"  "d"   "dh"  "n"   nil
     "p"   "ph"  "b"   "bh"  "m"
     "y"   "r"   nil   "l"   "L"   nil   "v"
     ("Z" "z")   "S"   "s"   "h"
     nil   nil   nil   nil   nil   nil   nil   nil
     nil   nil)
    (;; misc
     nil   "M"   "H"   "'"   nil   "." nil)))

(defvar indian-aiba-table
  '(;; for encode/decode
    (;; vowel
     "a"   "aa"  "i"   "ii"  "u"   "uu"
     ".r"  ".l"   nil   nil  "e"   "ai"
     nil   nil   "o"   "au"  "~r"  "~l")
    (;; consonant
     "k"   "kh"  "g"   "gh"  "^n"
     "c"   "ch"  "j"   "jh"  "~n"
     ".t"  ".th" ".d"  ".dh" ".n"
     "t"   "th"  "d"   "dh"  "n"   nil
     "p"   "ph"  "b"   "bh"  "m"
     "y"   "r"   nil   "l"   nil  nil  "v"
     "^s"  ".s"  "s"   "h"
     nil   nil   nil   nil   nil   nil   nil   nil
     nil   nil)
    (;; misc
     nil   ".m"  ".h"  "'"   nil   "." nil)))

(defun mapthread (function seq1 &rest seqrest)
  "Apply FUNCTION to each element of SEQ1 and return result list.
If there are several SEQRESTs, FUNCTION is called with that many
arguments, with all possible combinations of these multiple SEQUENCES.
Thus, if SEQ1 contains 3 elements and SEQ2 contains 5 elements, then
FUNCTION will be called 15 times."
  (if seqrest
      (mapcar
       (lambda (x)
         (apply
          'mapthread
          `(lambda (&rest y) (apply ',function x y))
          seqrest))
       seq1)
  (mapcar function seq1)))

(defun indian--puthash-char (char trans-char hashtbls)
  (let ((encode-hash (car hashtbls))  ;; char -> trans
	(decode-hash (cdr hashtbls))  ;; trans -> char
	)
    ;; char -- nil / char / string (/ list of vowel & matra)
    ;; trans-char -- nil / string / list of strings
    (when (and char trans-char)
      (if (stringp trans-char) (setq trans-char (list trans-char)))
      (if (char-valid-p char) (setq char (char-to-string char)))
      (puthash char (car trans-char) encode-hash)
      (dolist (trans trans-char)
	 (puthash trans char decode-hash)))))

(defun indian--map (f l1 l2)
  (while l1
    (funcall f (pop l1) (pop l2))))

(defun indian--puthash-v (v trans-v hashtbls)
  (indian--map
   (lambda (v trans-v)
     (indian--puthash-char (car v) trans-v hashtbls))
   v trans-v))

(defun indian--puthash-c (c trans-c halant hashtbls)
  (indian--map
   (lambda (c trans-c)
     (if (char-valid-p c) (setq c (char-to-string c)))
     (indian--puthash-char (concat c halant) trans-c hashtbls))
   c trans-c))

(defun indian--puthash-m (m trans-m hashtbls)
  (indian--map
   (lambda (m trans-m)
     (indian--puthash-char m trans-m hashtbls))
   m trans-m))

(defun indian--puthash-cv (c trans-c v trans-v hashtbls)
  (indian--map
   (lambda (c trans-c)
     (indian--map
      (lambda (v trans-v)
	(when (and c trans-c  v trans-v)
	  (if (char-valid-p c) (setq c (char-to-string c)))
	  (setq v (if (char-valid-p (cadr v)) (char-to-string (cadr v)) ""))
	  (if (stringp trans-c) (setq trans-c (list trans-c)))
	  (if (stringp trans-v) (setq trans-v (list trans-v)))
	  (indian--puthash-char
	   (concat c v)
	   (apply 'append
		  (mapthread 'concat trans-c trans-v))
	   hashtbls)))
      v trans-v))
   c trans-c))

(defun indian-make-hash (table trans-table)
  "Indian Transliteration Hash for decode/encode"
  (let* ((encode-hash (make-hash-table :test 'equal))
	 (decode-hash (make-hash-table :test 'equal))
	 (hashtbls (cons encode-hash decode-hash))
	 (vowels     (elt table 0))
	 (consonants (elt table 1))
	 (misc       (elt table 2))
	 (digits     (elt table 3))
	 (halant     (char-to-string (elt misc  4)))
	 (trans-vowels     (elt trans-table 0))
	 (trans-consonants (elt trans-table 1))
	 (trans-misc       (elt trans-table 2))
	 (trans-digits  '("0" "1" "2" "3" "4" "5" "6" "7" "8" "9")))
    (indian--puthash-v vowels trans-vowels hashtbls)
    (indian--puthash-c consonants trans-consonants halant hashtbls)
    (indian--puthash-cv consonants trans-consonants
			      vowels trans-vowels hashtbls)
    (indian--puthash-m misc trans-misc hashtbls)
    (indian--puthash-m digits trans-digits hashtbls)
    hashtbls))

(defvar indian-dev-itrans-v5-hash
  (indian-make-hash indian-dev-base-table
			  indian-itrans-v5-table))
(defvar indian-dev-kyoto-harvard-hash
  (indian-make-hash indian-dev-base-table
			  indian-kyoto-harvard-table))
(defvar indian-dev-aiba-hash
  (indian-make-hash indian-dev-base-table
			  indian-aiba-table))

(defvar indian-pnj-itrans-v5-hash
  (indian-make-hash indian-pnj-base-table
			  indian-itrans-v5-table))

(defvar indian-gjr-itrans-v5-hash
  (indian-make-hash indian-gjr-base-table
			  indian-itrans-v5-table))

(defvar indian-ori-itrans-v5-hash
  (indian-make-hash indian-ori-base-table
			  indian-itrans-v5-table))

(defvar indian-bng-itrans-v5-hash
  (indian-make-hash indian-bng-base-table
			  indian-itrans-v5-table))

(defvar indian-asm-itrans-v5-hash
  (indian-make-hash indian-asm-base-table
			  indian-itrans-v5-table))

(defvar indian-tlg-itrans-v5-hash
  (indian-make-hash indian-tlg-base-table
			  indian-itrans-v5-table))

(defvar indian-knd-itrans-v5-hash
  (indian-make-hash indian-knd-base-table
			  indian-itrans-v5-table))

(defvar indian-mlm-itrans-v5-hash
  (indian-make-hash indian-mlm-base-table
			  indian-itrans-v5-table))

(defvar indian-tml-itrans-v5-hash
  (indian-make-hash indian-tml-base-table
			  indian-itrans-v5-table))
)

(defmacro indian-translate-region (from to hashtable encode-p)
  `(save-excursion
     (save-restriction
       (let ((regexp ,(indian-regexp-of-hashtbl-keys
		       (if encode-p (car (eval hashtable))
			 (cdr (eval hashtable))))))
	 (narrow-to-region from to)
	 (goto-char (point-min))
	 (while (re-search-forward regexp nil t)
	   (let ((matchstr (gethash (match-string 0)
				    (if ,encode-p
					(car ,hashtable)
				      (cdr ,hashtable)))))
	     (if matchstr (replace-match matchstr))))))))

;;;

(defun indian-dev-itrans-v5-encode-region (from to)
  (interactive "r")
  (indian-translate-region
   from to indian-dev-itrans-v5-hash t))

(defun indian-dev-itrans-v5-decode-region (from to)
  (interactive "r")
  (indian-translate-region
   from to indian-dev-itrans-v5-hash nil))

(defun indian-dev-kyoto-harvard-encode-region (from to)
  (interactive "r")
  (indian-translate-region
   from to indian-dev-kyoto-harvard-hash t))

(defun indian-dev-kyoto-harvard-decode-region (from to)
  (interactive "r")
  (indian-translate-region
   from to indian-dev-kyoto-harvard-hash nil))

(defun indian-dev-aiba-encode-region (from to)
  (interactive "r")
  (indian-translate-region
   from to indian-dev-aiba-hash t))

(defun indian-dev-aiba-decode-region (from to)
  (interactive "r")
  (indian-translate-region
   from to indian-dev-aiba-hash nil))




;;; IS 13194 utilities

;; The followings provide conversion between IS 13194 (ISCII) and UCS.

(defvar ucs-devanagari-to-is13194-alist
  '(;;Unicode vs IS13194  ;; only Devanagari is supported now.
    (?\x0900 . "[U+0900]")
    (?\x0901 . "(5!(B")
    (?\x0902 . "(5"(B")
    (?\x0903 . "(5#(B")
    (?\x0904 . "[U+0904]")
    (?\x0905 . "(5$(B")
    (?\x0906 . "(5%(B")
    (?\x0907 . "(5&(B")
    (?\x0908 . "(5'(B")
    (?\x0909 . "(5((B")
    (?\x090a . "(5)(B")
    (?\x090b . "(5*(B")
    (?\x090c . "(5&i(B")
    (?\x090d . "(5.(B")
    (?\x090e . "(5+(B")
    (?\x090f . "(5,(B")
    (?\x0910 . "(5-(B")
    (?\x0911 . "(52(B")
    (?\x0912 . "(5/(B")
    (?\x0913 . "(50(B")
    (?\x0914 . "(51(B")
    (?\x0915 . "(53(B")
    (?\x0916 . "(54(B")
    (?\x0917 . "(55(B")
    (?\x0918 . "(56(B")
    (?\x0919 . "(57(B")
    (?\x091a . "(58(B")
    (?\x091b . "(59(B")
    (?\x091c . "(5:(B")
    (?\x091d . "(5;(B")
    (?\x091e . "(5<(B")
    (?\x091f . "(5=(B")
    (?\x0920 . "(5>(B")
    (?\x0921 . "(5?(B")
    (?\x0922 . "(5@(B")
    (?\x0923 . "(5A(B")
    (?\x0924 . "(5B(B")
    (?\x0925 . "(5C(B")
    (?\x0926 . "(5D(B")
    (?\x0927 . "(5E(B")
    (?\x0928 . "(5F(B")
    (?\x0929 . "(5G(B")
    (?\x092a . "(5H(B")
    (?\x092b . "(5I(B")
    (?\x092c . "(5J(B")
    (?\x092d . "(5K(B")
    (?\x092e . "(5L(B")
    (?\x092f . "(5M(B")
    (?\x0930 . "(5O(B")
    (?\x0931 . "(5P(B")
    (?\x0932 . "(5Q(B")
    (?\x0933 . "(5R(B")
    (?\x0934 . "(5S(B")
    (?\x0935 . "(5T(B")
    (?\x0936 . "(5U(B")
    (?\x0937 . "(5V(B")
    (?\x0938 . "(5W(B")
    (?\x0939 . "(5X(B")
    (?\x093a . "[U+093a]")
    (?\x093b . "[U+093b]")
    (?\x093c . "(5i(B")
    (?\x093d . "(5ji(B")
    (?\x093e . "(5Z(B")
    (?\x093f . "(5[(B")
    (?\x0940 . "(5\(B")
    (?\x0941 . "(5](B")
    (?\x0942 . "(5^(B")
    (?\x0943 . "(5_(B")
    (?\x0944 . "(5_i(B")
    (?\x0945 . "(5c(B")
    (?\x0946 . "(5`(B")
    (?\x0947 . "(5a(B")
    (?\x0948 . "(5b(B")
    (?\x0949 . "(5g(B")
    (?\x094a . "(5d(B")
    (?\x094b . "(5e(B")
    (?\x094c . "(5f(B")
    (?\x094d . "(5h(B")
    (?\x094e . "[U+094e]")
    (?\x094f . "[U+094f]")
    (?\x0950 . "(5!i(B")
    (?\x0951 . "(5p5(B")
    (?\x0952 . "(5p8(B")
    (?\x0953 . "[DEVANAGARI GRAVE ACCENT]")
    (?\x0954 . "[DEVANAGARI ACUTE ACCENT]")
    (?\x0955 . "[U+0955]")
    (?\x0956 . "[U+0956]")
    (?\x0957 . "[U+0957]")
    (?\x0958 . "(53i(B")
    (?\x0959 . "(54i(B")
    (?\x095a . "(55i(B")
    (?\x095b . "(5:i(B")
    (?\x095c . "(5?i(B")
    (?\x095d . "(5@i(B")
    (?\x095e . "(5Ii(B")
    (?\x095f . "(5N(B")
    (?\x0960 . "(5*i(B")
    (?\x0961 . "(5'i(B")
    (?\x0962 . "(5[i(B")
    (?\x0963 . "(5ei(B")
    (?\x0964 . "(5j(B")
    (?\x0965 . "(5jj(B")
    (?\x0966 . "(5q(B")
    (?\x0967 . "(5r(B")
    (?\x0968 . "(5s(B")
    (?\x0969 . "(5t(B")
    (?\x096a . "(5u(B")
    (?\x096b . "(5v(B")
    (?\x096c . "(5w(B")
    (?\x096d . "(5x(B")
    (?\x096e . "(5y(B")
    (?\x096f . "(5z(B")
    (?\x0970 . "[U+0970]")
    (?\x0971 . "[U+0971]")
    (?\x0972 . "[U+0972]")
    (?\x0973 . "[U+0973]")
    (?\x0974 . "[U+0974]")
    (?\x0975 . "[U+0975]")
    (?\x0976 . "[U+0976]")
    (?\x0977 . "[U+0977]")
    (?\x0978 . "[U+0978]")
    (?\x0979 . "[U+0979]")
    (?\x097a . "[U+097a]")
    (?\x097b . "[U+097b]")
    (?\x097c . "[U+097c]")
    (?\x097d . "[U+097d]")
    (?\x097e . "[U+097e]")
    (?\x097f . "[U+097f]")))

(defvar ucs-bengali-to-is13194-alist nil)
(defvar ucs-assamese-to-is13194-alist nil)
(defvar ucs-gurmukhi-to-is13194-alist nil)
(defvar ucs-gujarati-to-is13194-alist nil)
(defvar ucs-oriya-to-is13194-alist nil)
(defvar ucs-tamil-to-is13194-alist nil)
(defvar ucs-telugu-to-is13194-alist nil)
(defvar ucs-malayalam-to-is13194-alist nil)
(defvar ucs-kannada-to-is13194-alist nil)

(defvar is13194-default-repartory 'devanagari)

(defvar is13194-repertory-to-ucs-script
  `((DEF ?\x40 ,is13194-default-repartory)
    (RMN ?\x41 ,is13194-default-repartory)
    (DEV ?\x42 devanagari)
    (BNG ?\x43 bengali)
    (TML ?\x44 tamil)
    (TLG ?\x45 telugu)
    (ASM ?\x46 bengali)
    (ORI ?\x47 oriya)
    (KND ?\x48 kannada)
    (MLM ?\x49 malayalam)
    (GJR ?\x4a gujarati)
    (PNJ ?\x4b gurmukhi)))

;; for guiding find-variable function.
(defvar is13194-to-ucs-devanagari-hashtbl nil)
(defvar is13194-to-ucs-devanagari-regexp nil)
(defvar is13194-to-ucs-bengali-hashtbl nil)
(defvar is13194-to-ucs-bengali-regexp nil)
(defvar is13194-to-ucs-assamese-hashtbl nil)
(defvar is13194-to-ucs-assamese-regexp nil)
(defvar is13194-to-ucs-gurmukhi-hashtbl nil)
(defvar is13194-to-ucs-gurmukhi-regexp nil)
(defvar is13194-to-ucs-gujarati-hashtbl nil)
(defvar is13194-to-ucs-gujarati-regexp nil)
(defvar is13194-to-ucs-oriya-hashtbl nil)
(defvar is13194-to-ucs-oriya-regexp nil)
(defvar is13194-to-ucs-tamil-hashtbl nil)
(defvar is13194-to-ucs-tamil-regexp nil)
(defvar is13194-to-ucs-telugu-hashtbl nil)
(defvar is13194-to-ucs-telugu-regexp nil)
(defvar is13194-to-ucs-malayalam-hashtbl nil)
(defvar is13194-to-ucs-malayalam-regexp nil)
(defvar is13194-to-ucs-kannada-hashtbl nil)
(defvar is13194-to-ucs-kannada-regexp nil)

(mapc
 (function (lambda (script)
   (let ((hashtable (intern (concat "is13194-to-ucs-"
                                    (symbol-name script) "-hashtbl" )))
         (regexp    (intern (concat "is13194-to-ucs-"
                                    (symbol-name script) "-regexp"))))
     (set hashtable (make-hash-table :test 'equal :size 128))
     (mapc
      (function (lambda (x)
        (put-char-code-property (decode-char 'ucs (car x))
                                'script script)
        (put-char-code-property (decode-char 'ucs (car x))
                                'iscii (cdr x))
        (puthash (cdr x) (char-to-string (decode-char 'ucs (car x)))
                 (eval hashtable))))
      (eval (intern (concat "ucs-" (symbol-name script)
                            "-to-is13194-alist"))))
     (set regexp (indian-regexp-of-hashtbl-keys (eval hashtable))))))
 '(devanagari bengali assamese gurmukhi gujarati
   oriya tamil telugu malayalam kannada))

(defvar ucs-to-is13194-regexp
  ;; only Devanagari is supported now.
  (concat "[" (char-to-string (decode-char 'ucs #x0900))
          "-" (char-to-string (decode-char 'ucs #x097f)) "]")
  "Regexp that matches to conversion")

(defun ucs-to-iscii-region (from to)
  "Converts the indian UCS characters in the region to ISCII.
Returns new end position."
  (interactive "r")
  ;; only Devanagari is supported now.
  (save-excursion
    (save-restriction
      (narrow-to-region from to)
      (goto-char (point-min))
      (let* ((current-repertory is13194-default-repartory))
        (while (re-search-forward ucs-to-is13194-regexp nil t)
          (replace-match
           (get-char-code-property (string-to-char (match-string 0))
                                   'iscii))))
      (point-max))))

(defun iscii-to-ucs-region (from to)
  "Converts the ISCII characters in the region to UCS.
Returns new end position."
  (interactive "r")
  ;; only Devanagari is supported now.
  (save-excursion
    (save-restriction
      (narrow-to-region from to)
      (goto-char (point-min))
      (let* ((current-repertory is13194-default-repartory)
             (current-hashtable
              (intern (concat "is13194-to-ucs-"
                              (symbol-name current-repertory) "-hashtbl")))
             (current-regexp
              (intern (concat "is13194-to-ucs-"
                              (symbol-name current-repertory) "-regexp"))))
        (while (re-search-forward (eval current-regexp) nil t)
          (replace-match
           (gethash (match-string 0) (eval current-hashtable) ""))))
      (point-max))))

;;;###autoload
(defun indian-compose-region (from to)
  "Compose the region according to `composition-function-table'."
  (interactive "r")
  (save-excursion
    (save-restriction
      (let ((pos from) chars (max to))
        (narrow-to-region from to)
        (while (< pos max)
          (setq chars (compose-chars-after pos))
          (if chars (setq pos (+ pos chars)) (setq pos (1+ pos))))))))

;;;###autoload
(defun indian-compose-string (string)
  (with-temp-buffer
    (insert string)
    (indian-compose-region (point-min) (point-max))
    (buffer-string)))

;;;###autoload
(defun in-is13194-post-read-conversion (len)
  (let ((pos (point)) endpos)
    (setq endpos (iscii-to-ucs-region pos (+ pos len)))
    (indian-compose-region pos endpos)
    (- endpos pos)))

;;;###autoload
(defun in-is13194-pre-write-conversion (from to)
  (let ((buf (current-buffer)))
    (set-buffer (generate-new-buffer " *temp*"))
    (if (stringp from)
	(insert from)
      (insert-buffer-substring buf from to))
    (ucs-to-iscii-region (point-min) (point-max))
    nil))




;;; Backward Compatibility support programs

;; The followings provides the conversion from old-implementation of
;; Emacs Devanagari script to UCS.

(defconst indian-2-colum-to-ucs
  '(
  ;;      0 1 2 3 4 5 6 7 8 9 a b c d e f
  ;;2120   $(5!!!"!#!$!%!&!'!(!)!*!+!,!-!.!/(B
  ("$(5!!(B" . "$,15A(B")
  ("$(5!"(B" . "$,15B(B")
  ("$(5!#(B" . "$,15C(B")
  ("$(5!$(B" . "$,15E(B")
  ("$(5!%(B" . "$,15F(B")
  ("$(5!&(B" . "$,15G(B")
  ("$(5!'(B" . "$,15H(B")
  ("$(5!((B" . "$,15I(B")
  ("$(5!)(B" . "$,15J(B")
  ("$(5!*(B" . "$,15K(B")
  ("$(5!*"p(B" . "$,15p6#(B")
  ("$(5!+(B" . "$,15N(B")
  ("$(5!,(B" . "$,15O(B")
  ("$(5!-(B" . "$,15P(B")
  ("$(5!.(B" . "$,15M(B")
  ("$(5!/(B" . "$,15R(B")
  ;;      0 1 2 3 4 5 6 7 8 9 a b c d e f
  ;;2130 $(5!0!1!2!3!4!5!6!7!8!9!:!;!<!=!>!?(B
  ("$(5!0(B" . "$,15S(B")
  ("$(5!1(B" . "$,15T(B")
  ("$(5!2(B" . "$,15Q(B")
  ("$(5!3(B" . "$,15U(B")
  ("$(5!4(B" . "$,15V(B")
  ("$(5!5(B" . "$,15W(B")
  ("$(5!6(B" . "$,15X(B")
  ("$(5!7(B" . "$,15Y(B")
  ("$(5!8(B" . "$,15Z(B")
  ("$(5!9(B" . "$,15[(B")
  ("$(5!:(B" . "$,15\(B")
  ("$(5!;(B" . "$,15](B")
  ("$(5!<(B" . "$,15^(B")
  ("$(5!=(B" . "$,15_(B")
  ("$(5!>(B" . "$,15`(B")
  ("$(5!?(B" . "$,15a(B")
  ;;      0 1 2 3 4 5 6 7 8 9 a b c d e f
  ;;2140 $(5!@!A!B!C!D!E!F!G!H!I!J!K!L!M!N!O(B
  ("$(5!@(B" . "$,15b(B")
  ("$(5!A(B" . "$,15c(B")
  ("$(5!B(B" . "$,15d(B")
  ("$(5!C(B" . "$,15e(B")
  ("$(5!D(B" . "$,15f(B")
  ("$(5!E(B" . "$,15g(B")
  ("$(5!F(B" . "$,15h(B")
  ("$(5!G(B" . "$,15i(B")
  ("$(5!H(B" . "$,15j(B")
  ("$(5!I(B" . "$,15k(B")
  ("$(5!J(B" . "$,15l(B")
  ("$(5!K(B" . "$,15m(B")
  ("$(5!L(B" . "$,15n(B")
  ("$(5!M(B" . "$,15o(B")
  ("$(5!N(B" . "$,16?(B")
  ("$(5!O(B" . "$,15p(B")
  ;;      0 1 2 3 4 5 6 7 8 9 a b c d e f
  ;;2150 $(5!P!Q!R!S!T!U!V!W!X!Y!Z![!\!]!^!_(B
  ("$(5!P(B" . "$,15q(B")
  ("$(5!Q(B" . "$,15r(B")
  ("$(5!R(B" . "$,15s(B")
  ("$(5!S(B" . "$,15t(B")
  ("$(5!T(B" . "$,15u(B")
  ("$(5!U(B" . "$,15v(B")
  ("$(5!V(B" . "$,15w(B")
  ("$(5!W(B" . "$,15x(B")
  ("$(5!X(B" . "$,15y(B")
  ("$(5!Z(B" . "$,15~(B")
  ("$(5![(B" . "$,15(B")
  ("$(5!\(B" . "$,16 (B")
  ("$(5!](B" . "$,16!(B")
  ("$(5!^(B" . "$,16"(B")
  ("$(5!_(B" . "$,16#(B")
  ;;      0 1 2 3 4 5 6 7 8 9 a b c d e f
  ;;2160 $(5!`!a!b!c!d!e!f!g!h!i!j!k!l!m!n!o(B
  ("$(5!`(B" . "$,16&(B")
  ("$(5!a(B" . "$,16'(B")
  ("$(5!b(B" . "$,16((B")
  ("$(5!c(B" . "$,16%(B")
  ("$(5!d(B" . "$,16*(B")
  ("$(5!e(B" . "$,16+(B")
  ("$(5!f(B" . "$,16,(B")
  ("$(5!g(B" . "$,16)(B")
  ("$(5!h(B" . "$,16-(B")
  ("$(5!i(B" . "$,15|(B")
  ("$(5!j(B" . "$,16D(B")
  ("$(5!j!j(B" . "$,16E(B")
  ;;      0 1 2 3 4 5 6 7 8 9 a b c d e f
  ;;2170 $(5!p!q!r!s!t!u!v!w!x!y!z!{!|!}!~(B
  ("$(5!q(B" . "$,16F(B")
  ("$(5!r(B" . "$,16G(B")
  ("$(5!s(B" . "$,16H(B")
  ("$(5!t(B" . "$,16I(B")
  ("$(5!u(B" . "$,16J(B")
  ("$(5!v(B" . "$,16K(B")
  ("$(5!w(B" . "$,16L(B")
  ("$(5!x(B" . "$,16M(B")
  ("$(5!y(B" . "$,16N(B")
  ("$(5!z(B" . "$,16O(B")
  ;;      0 1 2 3 4 5 6 7 8 9 a b c d e f
  ;;2220   $(5"!"""#"$"%"&"'"(")"*"+","-"."/(B
  ("$(5"!(B" . "$,16;6-5p(B")
  ("$(5""(B" . "$,16>6-5p(B")
  ("$(5"#(B" . "$,15U6-5p(B")
  ("$(5"$(B" . "$,15W6-5p(B")
  ("$(5"%(B" . "$,15d6-5p(B")
  ("$(5"&(B" . "$,15j6-5p(B")
  ("$(5"'(B" . "$,15k6-5p(B")
  ("$(5")(B" . "$,15v6-5p(B")
  ("$(5",(B" . "$,15p6!(B")
  ("$(5"-(B" . "$,15p6"(B")
  ("$(5".(B" . "$,15q6!(B")
  ("$(5"/(B" . "$,15q6"(B")
  ;;      0 1 2 3 4 5 6 7 8 9 a b c d e f
  ;;2230 $(5"0"1"2"3"4"5"6"7"8"9":";"<"=">"?(B
  ("$(5"3(B" . "$,15U6-(B")
  ("$(5"4(B" . "$,15V6-(B")
  ("$(5"5(B" . "$,15W6-(B")
  ("$(5"6(B" . "$,15X6-(B")
  ("$(5"8(B" . "$,15Z6-(B")
  ("$(5"8"q(B" . "$,15Z6-5p6-(B")
  ("$(5":(B" . "$,15\6-(B")
  ("$(5";(B" . "$,15]6-(B")
  ("$(5"<(B" . "$,15^6-(B")
  ("$(5"<(B" . "$,15^6-(B")
  ;;      0 1 2 3 4 5 6 7 8 9 a b c d e f
  ;;2240 $(5"@"A"B"C"D"E"F"G"H"I"J"K"L"M"N"O(B
  ("$(5"A(B" . "$,15c6-(B")
  ("$(5"B(B" . "$,15d6-(B")
  ("$(5"C(B" . "$,15e6-(B")
  ("$(5"E(B" . "$,15g6-(B")
  ("$(5"F(B" . "$,15h6-(B")
  ("$(5"G(B" . "$,15i6-(B")
  ("$(5"H(B" . "$,15j6-(B")
  ("$(5"I(B" . "$,15k6-(B")
  ("$(5"J(B" . "$,15l6-(B")
  ("$(5"J(B" . "$,15l6-(B")
  ("$(5"K(B" . "$,15m6-(B")
  ("$(5"L(B" . "$,15n6-(B")
  ("$(5"M(B" . "$,15o6-(B")
  ("$(5"N(B" . "$,16?6-(B")
  ;;      0 1 2 3 4 5 6 7 8 9 a b c d e f
  ;;2250 $(5"P"Q"R"S"T"U"V"W"X"Y"Z"["\"]"^"_(B
  ("$(5"Q(B" . "$,15r6-(B")
  ("$(5"R(B" . "$,15s6-(B")
  ("$(5"S(B" . "$,15t6-(B")
  ("$(5"T(B" . "$,15u6-(B")
  ("$(5"U(B" . "$,15v6-(B")
  ("$(5"V(B" . "$,15w6-(B")
  ("$(5"W(B" . "$,15x6-(B")
  ("$(5"](B" . "$,16-5o(B")
  ;;      0 1 2 3 4 5 6 7 8 9 a b c d e f
  ;;2260 $(5"`"a"b"c"d"e"f"g"h"i"j"k"l"m"n"o(B
  ("$(5"`(B" . "$,15W6-5p6-(B")
  ("$(5"a(B" . "$,15X6-5h6-(B")
  ("$(5"c(B" . "$,15d6-5d6-(B")
  ("$(5"d(B" . "$,15d6-5p6-(B")
  ("$(5"e(B" . "$,15g6-5h6-(B")
  ("$(5"f(B" . "$,15g6-5p6-(B")
  ("$(5"g(B" . "$,15j6-5d6-(B")
  ("$(5"h(B" . "$,15v6-5Z6-(B")
  ("$(5"i(B" . "$,15v6-5p6-(B")
  ("$(5"j(B" . "$,15v6-5u6-(B")
  ("$(5"k(B" . "$,15h6-5h6-(B")
  ("$(5"l(B" . "$,15U6-5w6-(B")
  ("$(5"m(B" . "$,15\6-5^6-(B")
  ;;      0 1 2 3 4 5 6 7 8 9 a b c d e f
  ;;2270 $(5"p"q"r"s"t"u"v"w"x"y"z"{"|"}"~(B
  ("$(5"p(B" . "$,15p6-(B")
  ("$(5"q(B" . "$,16-5p(B")
  ("$(5"r(B" . "$,16-5p(B")
  ("$(5"s(B" . "$,1686-(B")
  ("$(5"t(B" . "$,1696-(B")
  ("$(5"u(B" . "$,16:6-(B")
  ("$(5"y(B" . "$,16>6-(B")
  ("$(5"z(B" . "$,16;6-(B")
  ;;      0 1 2 3 4 5 6 7 8 9 a b c d e f
  ;;2320   $(5#!#"###$#%#&#'#(#)#*#+#,#-#.#/(B
  ("$(5#!(B" . "$,160(B")
  ("$(5#&(B" . "$,15L(B")
  ("$(5#&"p(B" . "$,15p6$(B")
  ("$(5#'(B" . "$,16A(B")
  ("$(5#'"p(B" . "$,15p6C(B")
  ("$(5#*(B" . "$,16@(B")
  ("$(5#*"p(B" . "$,15p6B(B")
  ;;      0 1 2 3 4 5 6 7 8 9 a b c d e f
  ;;2330 $(5#0#1#2#3#4#5#6#7#8#9#:#;#<#=#>#?(B
  ("$(5#3(B" . "$,168(B")
  ("$(5#4(B" . "$,169(B")
  ("$(5#5(B" . "$,16:(B")
  ("$(5#:(B" . "$,16;(B")
  ("$(5#?(B" . "$,16<(B")
  ;;      0 1 2 3 4 5 6 7 8 9 a b c d e f
  ;;2340 $(5#@#A#B#C#D#E#F#G#H#I#J#K#L#M#N#O(B
  ("$(5#@(B" . "$,16=(B")
  ("$(5#I(B" . "$,16>(B")
  ("$(5#J(B" . "$,15}(B")
  ("$(5#K(B" . "$,16$(B")
  ("$(5#L(B" . "$,16B(B")
  ("$(5#M(B" . "$,16C(B")
  ;;      0 1 2 3 4 5 6 7 8 9 a b c d e f
  ;;2350 $(5#P#Q#R#S#T#U#V#W#X#Y#Z#[#\#]#^#_(B
  ("$(5#P(B" . "$,15n6-5h(B")
  ("$(5#Q(B" . "$,15n6-5r(B")
  ("$(5#R(B" . "$,15y6#(B")
  ;;      0 1 2 3 4 5 6 7 8 9 a b c d e f
  ;;2360 $(5#`#a#b#c#d#e#f#g#h#i#j#k#l#m#n#o(B
  ("$(5#`(B" . "$,15r6-5r(B")
  ("$(5#a(B" . "$,15u6-5h(B")
  ("$(5#b(B" . "$,15u6-5u(B")
  ("$(5#c(B" . "$,15v6-5Z(B")
  ("$(5#d(B" . "$,15v6-5h(B")
  ("$(5#e(B" . "$,15v6-5l(B")
  ("$(5#f(B" . "$,15v6-5r(B")
  ("$(5#g(B" . "$,15v6-5u(B")
  ("$(5#h(B" . "$,15w6-5_6-5p6-5o(B")
  ("$(5#i(B" . "$,15w6-5_6-5o(B")
  ("$(5#j(B" . "$,15w6-5_6-5u(B")
  ("$(5#k(B" . "$,15w6-5_(B")
  ("$(5#l(B" . "$,15w6-5`(B")
  ("$(5#m(B" . "$,15x6-5h(B")
  ("$(5#n(B" . "$,15x6-5p(B")
  ;;      0 1 2 3 4 5 6 7 8 9 a b c d e f
  ;;2370 $(5#p#q#r#s#t#u#v#w#x#y#z#{#|#}#~(B
  ("$(5#p(B" . "$,15y6-5c(B")
  ("$(5#q(B" . "$,15y6-5h(B")
  ("$(5#r(B" . "$,15y6-5n(B")
  ("$(5#s(B" . "$,15y6-5o(B")
  ("$(5#t(B" . "$,15y6-5p(B")
  ("$(5#u(B" . "$,15y6-5r(B")
  ("$(5#v(B" . "$,15y6-5u(B")
  ;;      0 1 2 3 4 5 6 7 8 9 a b c d e f
  ;;2420   $(5$!$"$#$$$%$&$'$($)$*$+$,$-$.$/(B
  ("$(5$!(B" . "$,15U6-5d6-5p6-5o(B")
  ("$(5$"(B" . "$,15U6-5d6-5u(B")
  ("$(5$#(B" . "$,15U6-5d6-5o(B")
  ("$(5$$(B" . "$,15U6-5h6-5o(B")
  ("$(5$%(B" . "$,15U6-5p6-5o(B")
  ("$(5$&(B" . "$,15U6-5u6-5o(B")
  ("$(5$'(B" . "$,15U6-5U(B")
  ("$(5$((B" . "$,15U6-5d(B")
  ("$(5$)(B" . "$,15U6-5h(B")
  ("$(5$*(B" . "$,15U6-5n(B")
  ("$(5$+(B" . "$,15U6-5o(B")
  ("$(5$,(B" . "$,15U6-5r(B")
  ("$(5$-(B" . "$,15U6-5u(B")
  ("$(5$.(B" . "$,15U6-5w(B")
  ("$(5$/(B" . "$,15X6-5h(B")
  ;;      0 1 2 3 4 5 6 7 8 9 a b c d e f
  ;;2430 $(5$0$1$2$3$4$5$6$7$8$9$:$;$<$=$>$?(B
  ("$(5$0(B" . "$,15Y6-5U6-5d6-5o(B")
  ("$(5$1(B" . "$,15Y6-5U6-5w6-5u(B")
  ("$(5$2(B" . "$,15Y6-5U6-5d(B")
  ("$(5$3(B" . "$,15Y6-5U6-5w(B")
  ("$(5$4(B" . "$,15Y6-5X6-5p(B")
  ("$(5$5(B" . "$,15Y6-5U6-5o(B")
  ("$(5$6(B" . "$,15Y6-5V6-5o(B")
  ("$(5$7(B" . "$,15Y6-5W6-5o(B")
  ("$(5$8(B" . "$,15Y6-5X6-5o(B")
  ("$(5$9(B" . "$,15Y6-5U(B")
  ("$(5$:(B" . "$,15Y6-5V(B")
  ("$(5$;(B" . "$,15Y6-5W(B")
  ("$(5$<(B" . "$,15Y6-5X(B")
  ("$(5$=(B" . "$,15Y6-5Y(B")
  ("$(5$>(B" . "$,15Y6-5h(B")
  ("$(5$?(B" . "$,15Y6-5n(B")
  ;;      0 1 2 3 4 5 6 7 8 9 a b c d e f
  ;;2440 $(5$@$A$B$C$D$E$F$G$H$I$J$K$L$M$N$O(B
  ("$(5$@(B" . "$,15Y6-5o(B")
  ("$(5$A(B" . "$,15Z6-5Z(B")
  ("$(5$B(B" . "$,15Z6-5^(B")
  ("$(5$C(B" . "$,15[6-5o(B")
  ("$(5$D(B" . "$,15\6-5p(B")
  ("$(5$E(B" . "$,15\6-5^(B")
  ("$(5$F(B" . "$,15^6-5Z(B")
  ("$(5$G(B" . "$,15^6-5\(B")
  ("$(5$H(B" . "$,15_6-5U(B")
  ("$(5$I(B" . "$,15_6-5_(B")
  ("$(5$J(B" . "$,15_6-5`(B")
  ("$(5$K(B" . "$,15_6-5o(B")
  ("$(5$L(B" . "$,15`6-5o(B")
  ("$(5$M(B" . "$,15a6-5W6-5o(B")
  ("$(5$N(B" . "$,15a6-5X6-5p(B")
  ("$(5$O(B" . "$,15a6-5p6-5o(B")
  ;;      0 1 2 3 4 5 6 7 8 9 a b c d e f
  ;;2450 $(5$P$Q$R$S$T$U$V$W$X$Y$Z$[$\$]$^$_(B
  ("$(5$P(B" . "$,15a6-5W(B")
  ("$(5$Q(B" . "$,15a6-5X(B")
  ("$(5$R(B" . "$,15a6-5a(B")
  ("$(5$S(B" . "$,15a6-5n(B")
  ("$(5$T(B" . "$,15a6-5o(B")
  ;;      0 1 2 3 4 5 6 7 8 9 a b c d e f
  ;;2460 $(5$`$a$b$c$d$e$f$g$h$i$j$k$l$m$n$o(B
  ("$(5$`(B" . "$,15b6-5o(B")
  ("$(5$a(B" . "$,15d6-5d(B")
  ("$(5$b(B" . "$,15d6-5h(B")
  ("$(5$c(B" . "$,15f6-5f6-5o(B")
  ("$(5$d(B" . "$,15f6-5g6-5o(B")
  ("$(5$e(B" . "$,15f6-5m6-5o(B")
  ("$(5$f(B" . "$,15f6-5p6-5o(B")
  ("$(5$g(B" . "$,15f6-5u6-5o(B")
  ("$(5$h(B" . "$,15f6-5W6-5p(B")
  ("$(5$i(B" . "$,15f6-5X6-5p(B")
  ("$(5$j(B" . "$,15f6-5f6-5u(B")
  ("$(5$k(B" . "$,15f6-5g6-5u(B")
  ("$(5$l(B" . "$,15f6-5W(B")
  ("$(5$m(B" . "$,15f6-5X(B")
  ("$(5$n(B" . "$,15f6-5f(B")
  ("$(5$o(B" . "$,15f6-5g(B")
  ;;      0 1 2 3 4 5 6 7 8 9 a b c d e f
  ;;2470 $(5$p$q$r$s$t$u$v$w$x$y$z${$|$}$~(B
  ("$(5$p(B" . "$,15f6-5h(B")
  ("$(5$q(B" . "$,15f6-5l(B")
  ("$(5$r(B" . "$,15f6-5m(B")
  ("$(5$s(B" . "$,15f6-5n(B")
  ("$(5$t(B" . "$,15f6-5o(B")
  ("$(5$u(B" . "$,15f6-5u(B")
  ("$(5$v(B" . "$,15g6-5h(B")
  ("$(5$w(B" . "$,15h6-5h(B")
  ("$(5$x(B" . "$,15j6-5d(B")
  ("$(5$y(B" . "$,15j6-5h(B")
  ("$(5$z(B" . "$,15j6-5r(B")
  ("$(5${(B" . "$,15l6-5h(B")
  ("$(5$|(B" . "$,15l6-5l(B")
  ("$(5$}(B" . "$,15l6-5u(B")
  ("$(5$~(B" . "$,15m6-5h(B")))

(defconst indian-2-column-to-ucs-regexp
  "$(5!j!j(B\\|$(5"8"q(B\\|[$(5#&#'!*#*(B]$(5"p(B\\|[$(5!!(B-$(5$~(B]")

(put 'indian-2-column-to-ucs-chartable 'char-table-extra-slots 1)
(defconst indian-2-column-to-ucs-chartable
  (let ((table (make-char-table 'indian-2-column-to-ucs-chartable))
        (alist nil))
    (dolist (elt indian-2-colum-to-ucs)
      (if (= (length (car elt)) 1)
          (aset table (aref (car elt) 0) (cdr elt))
        (setq alist (cons elt alist))))
    (set-char-table-extra-slot table 0 alist)
    table))

(defun indian-2-column-to-ucs-region (from to)
  "Convert old Emacs Devanagari characters to UCS."
  (interactive "r")
  (save-excursion
    (save-restriction
      (let ((pos from)
            (alist (char-table-extra-slot indian-2-column-to-ucs-chartable 0)))
        (narrow-to-region from to)
        (decompose-region from to)
        (goto-char (point-min))
        (while (re-search-forward indian-2-column-to-ucs-regexp nil t)
          (let ((len (- (match-end 0) (match-beginning 0)))
                subst)
            (if (= len 1)
                (setq subst (aref indian-2-column-to-ucs-chartable
				  (char-after (match-beginning 0))))
              (setq subst (cdr (assoc (match-string 0) alist))))
            (replace-match (if subst subst "?"))))
        (indian-compose-region (point-min) (point-max))))))

;;;###autoload
(defun indian-glyph-char (index &optional script)
  "Return character of charset `indian-glyph' made from glyph index INDEX.
The variable `indian-default-script' specifies the script of the glyph.
Optional argument SCRIPT, if non-nil, overrides `indian-default-script'.
See also the function `indian-char-glyph'."
  (or script
      (setq script indian-default-script))
  (let ((offset (get script 'indian-glyph-code-offset)))
    (or (integerp offset)
	(error "Invalid script name: %s" script))
    (or (and (>= index 0) (< index 256))
	(error "Invalid glyph index: %d" index))
    (setq index (+ offset index))
    (make-char 'indian-glyph (+ (/ index 96) 32) (+ (% index 96) 32))))

(defvar indian-glyph-max-char
  (indian-glyph-char
   255 (aref indian-script-table (1- (length indian-script-table))))
  "The maximum valid code of characters in the charset `indian-glyph'.")

;;;###autoload
(defun indian-char-glyph (char)
  "Return information about the glyph code for CHAR of `indian-glyph' charset.
The value is (INDEX . SCRIPT), where INDEX is the glyph index
in the font that Indian script name SCRIPT specifies.
See also the function `indian-glyph-char'."
  (let ((split (split-char char))
	code)
    (or (eq (car split) 'indian-glyph)
	(error "Charset of `%c' is not indian-glyph" char))
    (or (<= char indian-glyph-max-char)
	(error "Invalid indian-glyph char: %d" char))
    (setq code (+ (* (- (nth 1 split) 32) 96) (nth 2 split) -32))
    (cons (% code 256) (aref indian-script-table (/ code 256)))))

(provide 'ind-util)

;;; arch-tag: 59aacd71-46c2-4cb3-bb26-e12bbad55545
;;; ind-util.el ends here