"Returns the regular expression of hashtable keys."
(let ((max-specpdl-size 1000))
(regexp-opt
- (sort
+ (sort
(let (dummy)
(maphash (function (lambda (key val) (setq dummy (cons key dummy))))
hashtbl)
(?\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))
(;; CONSONANTS (currently 42, including special cases)
?\e$,15U\e(B ?\e$,15V\e(B ?\e$,15W\e(B ?\e$,15X\e(B ?\e$,15Y\e(B ;; GUTTRULS
- ?\e$,15Z\e(B ?\e$,15[\e(B ?\e$,15\\e(B ?\e$,15]\e(B ?\e$,15^\e(B ;; PALATALS
- ?\e$,15_\e(B ?\e$,15`\e(B ?\e$,15a\e(B ?\e$,15b\e(B ?\e$,15c\e(B ;; CEREBRALS
- ?\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
- ?\e$,15j\e(B ?\e$,15k\e(B ?\e$,15l\e(B ?\e$,15m\e(B ?\e$,15n\e(B ;; LABIALS
+ ?\e$,15Z\e(B ?\e$,15[\e(B ?\e$,15\\e(B ?\e$,15]\e(B ?\e$,15^\e(B ;; PALATALS
+ ?\e$,15_\e(B ?\e$,15`\e(B ?\e$,15a\e(B ?\e$,15b\e(B ?\e$,15c\e(B ;; CEREBRALS
+ ?\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
+ ?\e$,15j\e(B ?\e$,15k\e(B ?\e$,15l\e(B ?\e$,15m\e(B ?\e$,15n\e(B ;; LABIALS
?\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
- ?\e$,15v\e(B ?\e$,15w\e(B ?\e$,15x\e(B ?\e$,15y\e(B ;; SIBILANTS
- ?\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
+ ?\e$,15v\e(B ?\e$,15w\e(B ?\e$,15x\e(B ?\e$,15y\e(B ;; SIBILANTS
+ ?\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
"\e$,15\6-5^\e(B" "\e$,15U6-5w\e(B")
- (;; Misc Symbols (7)
+ (;; Misc Symbols (7)
?\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)
(;; Digits (10)
?\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)
(defvar indian-base-table-to-language-alist
'((indian-dev-base-table . "Devanagari")
- (indian-pnj-base-table . "Punjabi")
+ (indian-pnj-base-table . "Punjabi")
(indian-ori-base-table . "Oriya")
(indian-bng-base-table . "Bengali")
(indian-asm-base-table . "Assamese")
"a" ("aa" "A") "i" ("ii" "I") "u" ("uu" "U")
("RRi" "R^i") ("LLi" "L^i") (".c" "e.c") nil "e" "ai"
"o.c" nil "o" "au" ("RRI" "R^I") ("LLI" "L^I"))
- (;; consonants -- 40
+ (;; 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"
+ "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"
Thus, if SEQ1 contains 3 elements and SEQ2 contains 5 elements, then
FUNCTION will be called 15 times."
(if seqrest
- (mapcar
+ (mapcar
(lambda (x)
- (apply
- 'mapthread
- `(lambda (&rest y) (apply ',function x y))
- seqrest))
+ (apply
+ 'mapthread
+ `(lambda (&rest y) (apply ',function x y))
+ seqrest))
seq1)
(mapcar function seq1)))
(funcall f (pop l1) (pop l2))))
(defun indian--puthash-v (v trans-v hashtbls)
- (indian--map
+ (indian--map
(lambda (v trans-v)
(indian--puthash-char (car v) trans-v hashtbls))
v trans-v))
(setq v (if (characterp (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
+ (indian--puthash-char
(concat c v)
(apply 'append
(mapthread 'concat trans-c trans-v))
(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
+ (indian--puthash-cv consonants trans-consonants
vowels trans-vowels hashtbls)
(indian--puthash-m misc trans-misc hashtbls)
(indian--puthash-m digits trans-digits hashtbls)
(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))
+ (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)
+ (let ((matchstr (gethash (match-string 0)
(if ,encode-p
(car ,hashtable)
(cdr ,hashtable)))))
(defun indian-dev-itrans-v5-encode-region (from to)
(interactive "r")
- (indian-translate-region
+ (indian-translate-region
from to indian-dev-itrans-v5-hash t))
(defun indian-dev-itrans-v5-decode-region (from to)
(defun indian-dev-kyoto-harvard-encode-region (from to)
(interactive "r")
- (indian-translate-region
+ (indian-translate-region
from to indian-dev-kyoto-harvard-hash t))
(defun indian-dev-kyoto-harvard-decode-region (from to)
(defun indian-dev-aiba-encode-region (from to)
(interactive "r")
- (indian-translate-region
+ (indian-translate-region
from to indian-dev-aiba-hash t))
(defun indian-dev-aiba-decode-region (from to)
;;; 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 . "\e(5!\e(B")
- (?\x0902 . "\e(5"\e(B")
- (?\x0903 . "\e(5#\e(B")
- (?\x0904 . "[U+0904]")
- (?\x0905 . "\e(5$\e(B")
- (?\x0906 . "\e(5%\e(B")
- (?\x0907 . "\e(5&\e(B")
- (?\x0908 . "\e(5'\e(B")
- (?\x0909 . "\e(5(\e(B")
- (?\x090a . "\e(5)\e(B")
- (?\x090b . "\e(5*\e(B")
- (?\x090c . "\e(5&i\e(B")
- (?\x090d . "\e(5.\e(B")
- (?\x090e . "\e(5+\e(B")
- (?\x090f . "\e(5,\e(B")
- (?\x0910 . "\e(5-\e(B")
- (?\x0911 . "\e(52\e(B")
- (?\x0912 . "\e(5/\e(B")
- (?\x0913 . "\e(50\e(B")
- (?\x0914 . "\e(51\e(B")
- (?\x0915 . "\e(53\e(B")
- (?\x0916 . "\e(54\e(B")
- (?\x0917 . "\e(55\e(B")
- (?\x0918 . "\e(56\e(B")
- (?\x0919 . "\e(57\e(B")
- (?\x091a . "\e(58\e(B")
- (?\x091b . "\e(59\e(B")
- (?\x091c . "\e(5:\e(B")
- (?\x091d . "\e(5;\e(B")
- (?\x091e . "\e(5<\e(B")
- (?\x091f . "\e(5=\e(B")
- (?\x0920 . "\e(5>\e(B")
- (?\x0921 . "\e(5?\e(B")
- (?\x0922 . "\e(5@\e(B")
- (?\x0923 . "\e(5A\e(B")
- (?\x0924 . "\e(5B\e(B")
- (?\x0925 . "\e(5C\e(B")
- (?\x0926 . "\e(5D\e(B")
- (?\x0927 . "\e(5E\e(B")
- (?\x0928 . "\e(5F\e(B")
- (?\x0929 . "\e(5G\e(B")
- (?\x092a . "\e(5H\e(B")
- (?\x092b . "\e(5I\e(B")
- (?\x092c . "\e(5J\e(B")
- (?\x092d . "\e(5K\e(B")
- (?\x092e . "\e(5L\e(B")
- (?\x092f . "\e(5M\e(B")
- (?\x0930 . "\e(5O\e(B")
- (?\x0931 . "\e(5P\e(B")
- (?\x0932 . "\e(5Q\e(B")
- (?\x0933 . "\e(5R\e(B")
- (?\x0934 . "\e(5S\e(B")
- (?\x0935 . "\e(5T\e(B")
- (?\x0936 . "\e(5U\e(B")
- (?\x0937 . "\e(5V\e(B")
- (?\x0938 . "\e(5W\e(B")
- (?\x0939 . "\e(5X\e(B")
- (?\x093a . "[U+093a]")
- (?\x093b . "[U+093b]")
- (?\x093c . "\e(5i\e(B")
- (?\x093d . "\e(5ji\e(B")
- (?\x093e . "\e(5Z\e(B")
- (?\x093f . "\e(5[\e(B")
- (?\x0940 . "\e(5\\e(B")
- (?\x0941 . "\e(5]\e(B")
- (?\x0942 . "\e(5^\e(B")
- (?\x0943 . "\e(5_\e(B")
- (?\x0944 . "\e(5_i\e(B")
- (?\x0945 . "\e(5c\e(B")
- (?\x0946 . "\e(5`\e(B")
- (?\x0947 . "\e(5a\e(B")
- (?\x0948 . "\e(5b\e(B")
- (?\x0949 . "\e(5g\e(B")
- (?\x094a . "\e(5d\e(B")
- (?\x094b . "\e(5e\e(B")
- (?\x094c . "\e(5f\e(B")
- (?\x094d . "\e(5h\e(B")
- (?\x094e . "[U+094e]")
- (?\x094f . "[U+094f]")
- (?\x0950 . "\e(5!i\e(B")
- (?\x0951 . "\e(5p5\e(B")
- (?\x0952 . "\e(5p8\e(B")
- (?\x0953 . "[DEVANAGARI GRAVE ACCENT]")
- (?\x0954 . "[DEVANAGARI ACUTE ACCENT]")
- (?\x0955 . "[U+0955]")
- (?\x0956 . "[U+0956]")
- (?\x0957 . "[U+0957]")
- (?\x0958 . "\e(53i\e(B")
- (?\x0959 . "\e(54i\e(B")
- (?\x095a . "\e(55i\e(B")
- (?\x095b . "\e(5:i\e(B")
- (?\x095c . "\e(5?i\e(B")
- (?\x095d . "\e(5@i\e(B")
- (?\x095e . "\e(5Ii\e(B")
- (?\x095f . "\e(5N\e(B")
- (?\x0960 . "\e(5*i\e(B")
- (?\x0961 . "\e(5'i\e(B")
- (?\x0962 . "\e(5[i\e(B")
- (?\x0963 . "\e(5ei\e(B")
- (?\x0964 . "\e(5j\e(B")
- (?\x0965 . "\e(5jj\e(B")
- (?\x0966 . "\e(5q\e(B")
- (?\x0967 . "\e(5r\e(B")
- (?\x0968 . "\e(5s\e(B")
- (?\x0969 . "\e(5t\e(B")
- (?\x096a . "\e(5u\e(B")
- (?\x096b . "\e(5v\e(B")
- (?\x096c . "\e(5w\e(B")
- (?\x096d . "\e(5x\e(B")
- (?\x096e . "\e(5y\e(B")
- (?\x096f . "\e(5z\e(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]")))
+;; The following provide conversion between IS 13194 (ISCII) and UCS.
(defvar ucs-bengali-to-is13194-alist nil)
(defvar ucs-assamese-to-is13194-alist nil)
(defvar ucs-telugu-to-is13194-alist nil)
(defvar ucs-malayalam-to-is13194-alist nil)
-(defvar is13194-default-repartory 'devanagari)
+(defvar is13194-default-repertory 'devanagari)
(defvar is13194-repertory-to-ucs-script
- `((DEF ?\x40 ,is13194-default-repartory)
- (RMN ?\x41 ,is13194-default-repartory)
+ `((DEF ?\x40 ,is13194-default-repertory)
+ (RMN ?\x41 ,is13194-default-repertory)
(DEV ?\x42 devanagari)
(BNG ?\x43 bengali)
(TML ?\x44 tamil)
(defvar is13194-to-ucs-malayalam-hashtbl nil)
(defvar is13194-to-ucs-malayalam-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"))))
+(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 (car x) 'script script)
- (put-char-code-property (car x) 'iscii (cdr x))
- (puthash (cdr x) (char-to-string (car x))
- (eval hashtable))))
+ (put-char-code-property (car x) 'script script)
+ (put-char-code-property (car x) 'iscii (cdr x))
+ (puthash (cdr x) (char-to-string (car x))
+ (eval hashtable))))
(eval (intern (concat "ucs-" (symbol-name script)
- "-to-is13194-alist"))))
+ "-to-is13194-alist"))))
(set regexp (indian-regexp-of-hashtbl-keys (eval hashtable))))))
'(devanagari bengali assamese gurmukhi gujarati
oriya tamil telugu malayalam))
(defvar ucs-to-is13194-regexp
;; only Devanagari is supported now.
(concat "[" (char-to-string #x0900)
- "-" (char-to-string #x097f) "]")
+ "-" (char-to-string #x097f) "]")
"Regexp that matches to conversion")
(defun ucs-to-iscii-region (from to)
- "Converts the indian UCS characters in the region to ISCII.
+ "Converts the indian UCS characters in the region to ISCII.
Returns new end position."
(interactive "r")
;; only Devanagari is supported now.
(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))))
+ (let* ((current-repertory is13194-default-repertory))
+ (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.
+ "Converts the ISCII characters in the region to UCS.
Returns new end position."
(interactive "r")
;; only Devanagari is supported now.
(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) ""))))
+ (let* ((current-repertory is13194-default-repertory)
+ (current-hashtable
+ (intern (concat "is13194-to-ucs-"
+ (symbol-name current-repertory) "-hashtbl")))
+ (current-regexp
+ (intern (concat "is13194-to-ucs-"
+ (symbol-name current-repertory) "-regexp")))
+ (re (eval current-regexp))
+ (hahsh (eval current-hashtable)))
+ (while (re-search-forward re nil t)
+ (replace-match (gethash (match-string 0) hash ""))))
(point-max))))
;;;###autoload
(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))))))))
+ (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
+ (with-temp-buffer
(insert string)
(indian-compose-region (point-min) (point-max))
(buffer-string)))
;;; Backward Compatibility support programs
-;; The followings provides the conversion from old-implementation of
+;; The following provides the conversion from old-implementation of
;; Emacs Devanagari script to UCS.
(defconst indian-2-colum-to-ucs
(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))
+ (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))))
+ (aset table (aref (car elt) 0) (cdr elt))
+ (setq alist (cons elt alist))))
(set-char-table-extra-slot table 0 alist)
table))
(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
+ (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 (assoc (match-string 0) alist)))
- (replace-match (if subst subst "?"))))
- (indian-compose-region (point-min) (point-max))))))
+ (setq subst (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)
-
+
;;; ind-util.el ends here