Mercurial > emacs
comparison lisp/international/ucs-tables.el @ 47386:18dd2c15c04c
Bind
utf-8-translation-table-for-decode when setting up tables and
remove useless optimize-char-table.
(ucs-mule-to-mule-unicode): Deleted.
(ucs-unify-8859): Maybe optimize ucs-mule-to-mule-unicode.
author | Dave Love <fx@gnu.org> |
---|---|
date | Tue, 10 Sep 2002 17:39:53 +0000 |
parents | 6262acd6c7ac |
children | 6c4cab602bc8 |
comparison
equal
deleted
inserted
replaced
47385:d46bcfbfdda0 | 47386:18dd2c15c04c |
---|---|
155 | 155 |
156 (defvar ucs-8859-15-encode-table nil | 156 (defvar ucs-8859-15-encode-table nil |
157 "Used as `translation-table-for-encode' for iso-8859-15. | 157 "Used as `translation-table-for-encode' for iso-8859-15. |
158 Translates from the iso8859 charsets and `mule-unicode-0100-24ff'.") | 158 Translates from the iso8859 charsets and `mule-unicode-0100-24ff'.") |
159 | 159 |
160 ;; Probably defined by utf-8.el. | |
161 (defvar ucs-mule-to-mule-unicode (make-translation-table)) | |
162 (unless (get 'ucs-mule-to-mule-unicode 'translation-table) | |
163 (define-translation-table 'ucs-mule-to-mule-unicode ucs-mule-to-mule-unicode)) | |
164 ;;; Set up the tables. | 160 ;;; Set up the tables. |
165 | 161 |
166 ;; Most of these tables were derived from ones in Mule-UCS. | 162 ;; Most of these tables were derived from ones in Mule-UCS. |
167 | 163 |
168 ;; There doesn't seem to be a need to make these let bindings into | 164 ;; There doesn't seem to be a need to make these let bindings into |
1100 l) | 1096 l) |
1101 (setq i (1+ i))) | 1097 (setq i (1+ i))) |
1102 (nreverse l)))) | 1098 (nreverse l)))) |
1103 | 1099 |
1104 ;; Convert the lists to the basic char tables. | 1100 ;; Convert the lists to the basic char tables. |
1105 (dolist (n (list 15 14 9 8 7 5 4 3 2 1)) | 1101 ;; Ensure `decode-char' doesn't use the fragmentation table. |
1106 (let ((alist (symbol-value (intern (format "ucs-8859-%d-alist" n))))) | 1102 ;; Fixme: handa suggests using the RESTRICTION arg. |
1107 (dolist (pair alist) | 1103 (let (utf-8-translation-table-for-decode) |
1108 (let ((mule (car pair)) | 1104 (dolist (n (list 15 14 9 8 7 5 4 3 2 1)) |
1109 (uc (cdr pair)) | 1105 (let ((alist (symbol-value (intern (format "ucs-8859-%d-alist" n))))) |
1110 (mu (decode-char 'ucs (cdr pair)))) | 1106 (dolist (pair alist) |
1111 (aset ucs-mule-8859-to-ucs-table mule uc) | 1107 (let ((mule (car pair)) |
1112 ;; (aset ucs-ucs-to-mule-8859-table uc mule) | 1108 (uc (cdr pair)) |
1113 ;; (aset ucs-mule-unicode-to-mule-8859 mu mule) | 1109 (mu (decode-char 'ucs (cdr pair)))) |
1114 (aset ucs-mule-8859-to-mule-unicode mule mu) | 1110 (aset ucs-mule-8859-to-ucs-table mule uc) |
1115 (aset ucs-mule-to-mule-unicode mule mu))))) | 1111 ;; (aset ucs-ucs-to-mule-8859-table uc mule) |
1116 ;; The table optimizing here and elsewhere probably isn't very | 1112 ;; (aset ucs-mule-unicode-to-mule-8859 mu mule) |
1117 ;; useful, but seems good practice. | 1113 (aset ucs-mule-8859-to-mule-unicode mule mu) |
1118 (optimize-char-table ucs-mule-to-mule-unicode) | 1114 (aset ucs-mule-to-mule-unicode mule mu))))) |
1119 (optimize-char-table ucs-mule-8859-to-mule-unicode) | 1115 ;; Derive tables that can be used as per-coding-system |
1120 ;; Derive tables that can be used as per-coding-system | 1116 ;; `translation-table-for-encode's. |
1121 ;; `translation-table-for-encode's. | 1117 (dolist (n (list 15 14 9 8 7 5 4 3 2 1)) |
1122 (dolist (n (list 15 14 9 8 7 5 4 3 2 1)) | 1118 (let* ((alist (symbol-value (intern (format "ucs-8859-%d-alist" n)))) |
1123 (let* ((alist (symbol-value (intern (format "ucs-8859-%d-alist" n)))) | 1119 (encode-translator (set (intern (format "ucs-8859-%d-encode-table" |
1124 (encode-translator (set (intern (format "ucs-8859-%d-encode-table" | 1120 n)) |
1125 n)) | 1121 (make-translation-table))) |
1126 (make-translation-table))) | 1122 elt) |
1127 elt) | 1123 ;; Start with the mule-unicode component. |
1128 ;; Start with the mule-unicode component. | 1124 (dolist (pair alist) |
1129 (dolist (pair alist) | 1125 (let ((mule (car pair)) |
1130 (let ((mule (car pair)) | 1126 (mu (decode-char 'ucs (cdr pair)))) |
1131 (mu (decode-char 'ucs (cdr pair)))) | 1127 (aset encode-translator mu mule))) |
1132 (aset encode-translator mu mule))) | 1128 ;; Find characters from other 8859 sets which map to the same |
1133 ;; Find characters from other 8859 sets which map to the same | 1129 ;; unicode as some character in this set. |
1134 ;; unicode as some character in this set. | 1130 (map-char-table (lambda (k v) |
1135 (map-char-table (lambda (k v) | 1131 (if (and (setq elt (rassq v alist)) |
1136 (if (and (setq elt (rassq v alist)) | 1132 (not (assq k alist))) |
1137 (not (assq k alist))) | 1133 (aset encode-translator k (car elt)))) |
1138 (aset encode-translator k (car elt)))) | 1134 ucs-mule-8859-to-ucs-table) |
1139 ucs-mule-8859-to-ucs-table) | 1135 (optimize-char-table encode-translator))))) |
1140 (optimize-char-table encode-translator)))) | |
1141 | 1136 |
1142 ;; Register for use in CCL. | 1137 ;; Register for use in CCL. |
1143 (define-translation-table 'ucs-mule-8859-to-mule-unicode | 1138 (define-translation-table 'ucs-mule-8859-to-mule-unicode |
1144 ucs-mule-8859-to-mule-unicode) | 1139 ucs-mule-8859-to-mule-unicode) |
1145 (define-translation-table 'ucs-mule-to-mule-unicode | 1140 (define-translation-table 'ucs-mule-to-mule-unicode |
1156 everything on input operations." | 1151 everything on input operations." |
1157 (interactive "P") | 1152 (interactive "P") |
1158 (unless encode-only | 1153 (unless encode-only |
1159 ;; Unify 8859 on decoding. (Non-CCL coding systems only.) | 1154 ;; Unify 8859 on decoding. (Non-CCL coding systems only.) |
1160 (if utf-8-fragment-on-decoding | 1155 (if utf-8-fragment-on-decoding |
1161 (map-char-table | 1156 (progn (map-char-table |
1162 (lambda (k v) | 1157 (lambda (k v) |
1163 (if v (aset ucs-mule-to-mule-unicode v nil))) | 1158 (if v (aset ucs-mule-to-mule-unicode v nil))) |
1164 utf-8-translation-table-for-decode) | 1159 utf-8-translation-table-for-decode) |
1160 (optimize-char-table ucs-mule-to-mule-unicode)) | |
1165 ;; Reset in case it was changed. | 1161 ;; Reset in case it was changed. |
1166 (map-char-table | 1162 (map-char-table |
1167 (lambda (k v) | 1163 (lambda (k v) |
1168 (if v (aset ucs-mule-to-mule-unicode v k))) | 1164 (if v (aset ucs-mule-to-mule-unicode v k))) |
1169 utf-8-translation-table-for-decode)) | 1165 utf-8-translation-table-for-decode)) |
2457 (coding-system-put 'vietnamese-viqr | 2453 (coding-system-put 'vietnamese-viqr |
2458 'translation-table-for-input | 2454 'translation-table-for-input |
2459 encode-translator)) | 2455 encode-translator)) |
2460 ((memq cs '(lao thai-tis620 tibetan-iso-8bit)) | 2456 ((memq cs '(lao thai-tis620 tibetan-iso-8bit)) |
2461 (coding-system-put cs 'translation-table-for-input cs))))) | 2457 (coding-system-put cs 'translation-table-for-input cs))))) |
2462 (optimize-char-table ucs-mule-to-mule-unicode) | |
2463 (dolist (c safe-charsets) | 2458 (dolist (c safe-charsets) |
2464 (aset table (make-char c) t)) | 2459 (aset table (make-char c) t)) |
2465 (coding-system-put 'mule-utf-8 'safe-charsets | 2460 (coding-system-put 'mule-utf-8 'safe-charsets |
2466 (append (coding-system-get 'mule-utf-8 'safe-charsets) | 2461 (append (coding-system-get 'mule-utf-8 'safe-charsets) |
2467 safe-charsets)) | 2462 safe-charsets)) |