Mercurial > emacs
comparison lisp/international/utf-8.el @ 48882:d17c0d3e36ba
(ucs-mule-cjk-to-unicode)
(ucs-unicode-to-mule-cjk): Revert last change.
(utf-subst-table-for-encode): Initially use
ucs-mule-cjk-to-unicode.
(utf-subst-table-for-decode): Initially use
ucs-unicode-to-mule-cjk.
(utf-fragment-on-decoding, utf-translate-cjk): Don't modify
char-coding-system-table elements destructively.
(utf-translate-cjk): Set ucs-mule-cjk-to-unicode,
ucs-unicode-to-mule-cjk to new hash tables with realistic
parameters.
author | Dave Love <fx@gnu.org> |
---|---|
date | Tue, 17 Dec 2002 17:58:13 +0000 |
parents | 4eb835c1257d |
children | 79573bfb2899 |
comparison
equal
deleted
inserted
replaced
48881:23fcd656a17e | 48882:d17c0d3e36ba |
---|---|
93 translation-table named `utf-translation-table-for-encode'") | 93 translation-table named `utf-translation-table-for-encode'") |
94 | 94 |
95 (define-translation-table 'utf-translation-table-for-decode) | 95 (define-translation-table 'utf-translation-table-for-decode) |
96 | 96 |
97 | 97 |
98 (defvar ucs-mule-cjk-to-unicode (make-hash-table :test 'eq :size 43000 | 98 (defvar ucs-mule-cjk-to-unicode (make-hash-table :test 'eq) |
99 :rehash-size 1000) | |
100 "Hash table mapping Emacs CJK character sets to Unicode code points. | 99 "Hash table mapping Emacs CJK character sets to Unicode code points. |
101 | 100 |
102 If `utf-translate-cjk' is non-nil, this table populates the | 101 If `utf-translate-cjk' is non-nil, this table populates the |
103 translation-hash-table named `utf-subst-table-for-encode'.") | 102 translation-hash-table named `utf-subst-table-for-encode'.") |
104 | 103 |
105 (define-translation-hash-table 'utf-subst-table-for-encode | 104 (define-translation-hash-table 'utf-subst-table-for-encode |
106 (make-hash-table :test 'eq :size 43000 :rehash-size 1000)) | 105 ucs-mule-cjk-to-unicode) |
107 | 106 |
108 (defvar ucs-unicode-to-mule-cjk (make-hash-table :test 'eq :size 43000 | 107 (defvar ucs-unicode-to-mule-cjk (make-hash-table :test 'eq) |
109 :rehash-size 1000) | |
110 "Hash table mapping Unicode code points to Emacs CJK character sets. | 108 "Hash table mapping Unicode code points to Emacs CJK character sets. |
111 | 109 |
112 If `utf-translate-cjk' is non-nil, this table populates the | 110 If `utf-translate-cjk' is non-nil, this table populates the |
113 translation-hash-table named `utf-subst-table-for-decode'.") | 111 translation-hash-table named `utf-subst-table-for-decode'.") |
114 | 112 |
115 (define-translation-hash-table 'utf-subst-table-for-decode | 113 (define-translation-hash-table 'utf-subst-table-for-decode |
116 (make-hash-table :test 'eq :size 21500 :rehash-size 200)) | 114 ucs-unicode-to-mule-cjk) |
117 | 115 |
118 (mapc | 116 (mapc |
119 (lambda (pair) | 117 (lambda (pair) |
120 (aset utf-fragmentation-table (car pair) (cdr pair)) | 118 (aset utf-fragmentation-table (car pair) (cdr pair)) |
121 (aset utf-defragmentation-table (cdr pair) (car pair))) | 119 (aset utf-defragmentation-table (cdr pair) (car pair))) |
192 (define-translation-table 'utf-translation-table-for-encode) | 190 (define-translation-table 'utf-translation-table-for-encode) |
193 (map-char-table | 191 (map-char-table |
194 (lambda (key val) | 192 (lambda (key val) |
195 (if (and (>= key 128) val) | 193 (if (and (>= key 128) val) |
196 (aset char-coding-system-table key | 194 (aset char-coding-system-table key |
197 (delq 'mule-utf-8 | 195 (remq 'mule-utf-8 |
198 (delq 'mule-utf-16-le | 196 (remq 'mule-utf-16-le |
199 (delq 'mule-utf-16-be | 197 (remq 'mule-utf-16-be |
200 (aref char-coding-system-table | 198 (aref char-coding-system-table |
201 key))))))) | 199 key))))))) |
202 utf-defragmentation-table))) | 200 utf-defragmentation-table))) |
203 (set-default s v)) | 201 (set-default s v)) |
204 :version "21.4" | 202 :version "21.4" |
220 | 218 |
221 The tables are large (over 40000 entries), so this option is not the | 219 The tables are large (over 40000 entries), so this option is not the |
222 default. Also, installing them may be rather slow." | 220 default. Also, installing them may be rather slow." |
223 :set (lambda (s v) | 221 :set (lambda (s v) |
224 (if v | 222 (if v |
223 ;; Fixme: Allow the use of the CJK charsets to be | |
224 ;; customized by reordering and possible omission. | |
225 (progn | 225 (progn |
226 ;; Redefine them with realistic initial sizes and a | |
227 ;; smallish rehash size to avoid wasting significant | |
228 ;; space after they're built. | |
229 (setq ucs-mule-cjk-to-unicode | |
230 (make-hash-table :test 'eq :size 43000 :rehash-size 1000) | |
231 ucs-unicode-to-mule-cjk | |
232 (make-hash-table :test 'eq :size 43000 :rehash-size 1000)) | |
226 ;; Load the files explicitly, to avoid having to keep | 233 ;; Load the files explicitly, to avoid having to keep |
227 ;; around the large tables they contain (as well as the | 234 ;; around the large tables they contain (as well as the |
228 ;; ones which get built). | 235 ;; ones which get built). |
229 (cond | 236 (cond |
230 ((string= "Korean" current-language-environment) | 237 ((string= "Korean" current-language-environment) |
260 ucs-mule-cjk-to-unicode)) | 267 ucs-mule-cjk-to-unicode)) |
261 (map-char-table | 268 (map-char-table |
262 (lambda (k v) | 269 (lambda (k v) |
263 (if (gethash k ucs-mule-cjk-to-unicode) | 270 (if (gethash k ucs-mule-cjk-to-unicode) |
264 (aset char-coding-system-table k | 271 (aset char-coding-system-table k |
265 (delq 'mule-utf-8 | 272 (remq 'mule-utf-8 |
266 (delq 'mule-utf-16-le | 273 (remq 'mule-utf-16-le |
267 (delq 'mule-utf-16-be v)))))) | 274 (remq 'mule-utf-16-be v)))))) |
268 char-coding-system-table) | 275 char-coding-system-table) |
269 (define-translation-hash-table 'utf-subst-table-for-decode | 276 (define-translation-hash-table 'utf-subst-table-for-decode |
270 (make-hash-table :test 'eq)) | 277 (make-hash-table :test 'eq)) |
271 (define-translation-hash-table 'utf-subst-table-for-encode | 278 (define-translation-hash-table 'utf-subst-table-for-encode |
272 (make-hash-table :test 'eq))) | 279 (make-hash-table :test 'eq))) |