This package provides extensions to the standard Emacs ind-util.el
functions.
You can install it from Melpa, with M-x package-install indian-ext
This library is currently focused on providing conversion methods
between Devanāgarī and its romanized transliterations, but additions
for other South Asian scripts are very welcome (but check
ind-util.el
first).
It defines the following extra decode/encode functions:
- between Velthuis and Devanāgarī:
- `indian-ext-dev-velthuis-encode-region’
- `indian-ext-dev-velthuis-decode-region’
- between SLP1 and Devanāgarī:
- `indian-ext-dev-slp1-encode-region’
- `indian-ext-dev-slp1-decode-region’
- between IAST and Devanāgarī:
- `indian-ext-dev-iast-encode-region’
- `indian-ext-dev-iast-decode-region’
The IAST and Velthuis are not case sensitive.
It also defines an additional input method, sanskrit-iast (use with `M-x set-input-method’).
You can find other input methods here:
- Including Karoṣṭhī: http://stefanbaums.com/unicode/sanskrit.el
- Requires login: http://indica-et-buddhica.org/repositorium/software/emacs-utf8-input-framework
See also the thread about websites for transliteration on the INDOLOGY.info mailing list starting here (October 2023): https://list.indology.info/pipermail/indology/2023-October/058241.html
There are functions to use these extensions in emacs-lisp programs:
- between Velthuis and Devanāgarī:
- `indian-ext-dev-velthuis-encode-string’
- `indian-ext-dev-velthuis-decode-string’
- between SLP1 and Devanāgarī:
- `indian-ext-dev-slp1-encode-string’
- `indian-ext-dev-slp1-decode-string’
- between IAST and Devanāgarī:
- `indian-ext-dev-iast-encode-string’
- `indian-ext-dev-iast-decode-string’
Speed is an issue, however:
(benchmark-run
(dotimes (x 500)
(cl-assert
(string=
(indian-ext-dev-iast-encode-string "ख.")
"kha."))))
;; (4.902170626 30 4.18154369399997) most of the time seems to be
;; spent in ‘regex-opt’, called by ‘indian-regexp-of-hashtbl-keys’
;; Once it’s been byte-compiled, it’s okay though:
(byte-compile 'indian-ext-dev-iast-encode-string)
(benchmark-run
(dotimes (x 500)
(cl-assert
(string=
(indian-ext-dev-iast-encode-string "ख.")
"kha."))))
;; (0.019145428 0 0.0)
;; and for comparison:
(benchmark-run
(dotimes (x 500)
(with-temp-buffer
(insert "ख.")
(goto-char (point-min))
(while (re-search-forward "ख" nil t)
(replace-match "kha"))
(cl-assert
(string=
(buffer-string)
"kha.")))))
;; (0.01554602 0 0.0)
;; Interfacing to ind-util.el
(require 'ind-util)
(with-temp-buffer
(insert
(indian-ext-dev-iast-decode-string "na yuktaḥ!"))
(indian-dev-itrans-v5-encode-region (point-min) (point-max))
(buffer-string))
;; Not working:
;; ;; To Bengali
;; (defun hacks/indian-bng-itrans-v5-encode-region (from to)
;; (interactive "r")
;; (indian-translate-region
;; from to indian-bng-itrans-v5-hash t))
;; (defun hacks/indian-bng-itrans-v5-decode-region (from to)
;; (interactive "r")
;; (indian-translate-region
;; from to indian-bng-itrans-v5-hash f))
;; (with-temp-buffer
;; ;; convert to devanāgarī
;; (insert
;; (indian-ext-dev-iast-decode-string "na yuktaḥ!"))
;; ;; encode it to itrans-v5
;; (indian-dev-itrans-v5-encode-region (point-min) (point-max))
;; ;; and convert that to Bengali (not working?)
;; (hacks/indian-bng-itrans-v5-decode-region (point-min) (point-max))
;; (buffer-string))