Function: ogonek-build-table

ogonek-build-table is a byte-compiled function defined in ogonek.el.gz.

Signature

(ogonek-build-table RECODING-PAIRS)

Documentation

Build a table required by Emacs's translate-region function.

RECODING-PAIRS is a list of character pairs for which recoding is not an identity. By using the built-in translate-region function we gain better performance compared to converting characters by a hand-written routine as it is done for prefix encodings.

Source Code

;; Defined in /usr/src/emacs/lisp/international/ogonek.el.gz
;; ---- An auxiliary function building a one-to-one recoding table -----

(defun ogonek-build-table (recoding-pairs)
  "Build a table required by Emacs's `translate-region' function.
RECODING-PAIRS is a list of character pairs for which recoding
is not an identity.
By using the built-in `translate-region' function
we gain better performance compared to converting characters
by a hand-written routine as it is done for prefix encodings."
  (let ((table (make-string 256 0))
        (i 0))
    (while (< i 256)
      (aset table i i)
      (setq i (1+ i)))
    ;; make changes in `table' according to `recoding-pairs'
    (while recoding-pairs
      (aset table (car (car recoding-pairs)) (cdr (car recoding-pairs)))
      (setq recoding-pairs (cdr recoding-pairs)))
    ;; return the table just built
    table))