-(define-public (reencode-string mapping str)
- "Apply MAPPING, a vector of [0..256) -> char, to STR"
- (string-map (lambda (chr)
- (vector-ref mapping (char->integer chr)))
- str))
-
-(define-public (make-encoding-mapping input-encoding output-encoding)
- "Contruct a mapping by applying output-encoding after input-encoding "
- (list->vector
- (map
- (lambda (byte)
- (let ((new-char (hash-ref
- output-encoding (vector-ref input-encoding byte) #f)))
- ;;input-encoding (vector-ref output-encoding byte) #f)))
-
- ;; substitute space for unknown characters.
- (if (char? new-char)
- new-char
- #\ )))
- (iota 256))))
-
-
-(define (get-coding-from-file filename)
- "Read FILENAME, return a list containing encoding vector and table"
- (let* ((coding (read-encoding-file filename))
- (com (car coding))
- (vec (cdr coding))
- (tab (make-encoding-table vec)))
- (list com vec tab)))
-
-;; coding-alist maps NAME -> (list FILENAME COMMAND VECTOR TAB)
-(define coding-alist
-
- (map (lambda (x)
- (cons (car x)
- (cons (cdr x) (delay (get-coding-from-file (cdr x))))))
-
- '(
- ;; teTeX
- ("TeX-typewriter-text" . "09fbbfac.enc") ;; cmtt10
- ("TeX-math-symbols" . "10037936.enc") ;; cmbsy
- ("ASCII-caps-and-digits" . "1b6d048e.enc") ;; cminch
- ("TeX-math-italic" . "aae443f0.enc") ;; cmmi10
- ("TeX-extended-ASCII" . "d9b29452.enc")
- ("TeX-text" . "cmr.enc")
- ("TeX-text-without-f-ligatures" . "0ef0afca.enc")
- ("Extended-TeX-Font-Encoding---Latin" . "tex256.enc")
- ("AdobeStandardEncoding" . "8a.enc")
-
- ;; aliases
- ("T1" . "tex256.enc")
- ("adobe" . "8a.enc")
- ("latin1" . "cork.enc")
-
- ;; LilyPond.
- ("fetaBraces" . "feta-braces-a.enc")
- ("fetaNumber" . "feta-nummer10.enc")
- ("fetaMusic" . "feta20.enc")
- ("parmesanMusic" . "parmesan20.enc"))
- ))
-
-(define (get-coding coding-name)
- (let ((entry (assoc-get coding-name coding-alist)))
- (cons (car entry) (force (cdr entry)))))
-
-(define-public (get-coding-filename coding-name)
- (car (get-coding coding-name)))
-
-(define-public (get-coding-command coding-name)
- (cadr (get-coding coding-name)))
-
-(define-public (get-coding-vector coding-name)
- (caddr (get-coding coding-name)))
-
-(define-public (get-coding-table coding-name)
- (cadddr (get-coding coding-name)))