comparison lisp/international/utf-8.el @ 50179:65bb5afb37ef

(utf-fragment-on-decoding): Don't call register-char-codings. (utf-fragment-on-decoding): Don't update char-coding-system-table. (utf-translate-cjk): Don't call register-char-codings nor optimize-char-coding-system-table. Don't update char-coding-system-table.
author Kenichi Handa <handa@m17n.org>
date Tue, 18 Mar 2003 04:06:48 +0000
parents 575609f03daa
children b49563831bd2
comparison
equal deleted inserted replaced
50178:61194aef8668 50179:65bb5afb37ef
46 ;; Fixme: note that reading and writing invalid utf-8 may not be 46 ;; Fixme: note that reading and writing invalid utf-8 may not be
47 ;; idempotent -- to represent the bytes to fix that needs a new charset. 47 ;; idempotent -- to represent the bytes to fix that needs a new charset.
48 ;; 48 ;;
49 ;; Characters from other character sets can be encoded with mule-utf-8 49 ;; Characters from other character sets can be encoded with mule-utf-8
50 ;; by populating the translation table 50 ;; by populating the translation table
51 ;; `utf-translation-table-for-encode' and registering the translation 51 ;; `utf-translation-table-for-encode'. Hash tables
52 ;; with `register-char-codings'. Hash tables
53 ;; `utf-subst-table-for-decode' and `utf-subst-table-for-encode' are 52 ;; `utf-subst-table-for-decode' and `utf-subst-table-for-encode' are
54 ;; used to support encoding and decoding of about a quarter of the CJK 53 ;; used to support encoding and decoding of about a quarter of the CJK
55 ;; space between U+3400 and U+DFFF. 54 ;; space between U+3400 and U+DFFF.
56 55
57 ;; UTF-8 is defined in RFC 2279. A sketch of the encoding is: 56 ;; UTF-8 is defined in RFC 2279. A sketch of the encoding is:
175 ;; utf-fragmentation-table. 174 ;; utf-fragmentation-table.
176 (unless (eq (get 'utf-translation-table-for-encode 175 (unless (eq (get 'utf-translation-table-for-encode
177 'translation-table) 176 'translation-table)
178 ucs-mule-to-mule-unicode) 177 ucs-mule-to-mule-unicode)
179 (define-translation-table 'utf-translation-table-for-encode 178 (define-translation-table 'utf-translation-table-for-encode
180 utf-defragmentation-table) 179 utf-defragmentation-table)))
181 (dolist (coding '(mule-utf-8 mule-utf-16-be mule-utf-16-le))
182 (register-char-codings coding utf-defragmentation-table))))
183 (define-translation-table 'utf-translation-table-for-decode) 180 (define-translation-table 'utf-translation-table-for-decode)
184 ;; When unify-8859-on-encoding-mode is off, be sure to make 181 ;; When unify-8859-on-encoding-mode is off, be sure to make
185 ;; mule-utf-* disabled for characters in 182 ;; mule-utf-* disabled for characters in
186 ;; utf-fragmentation-table. 183 ;; utf-fragmentation-table.
187 (unless (eq (get 'utf-translation-table-for-encode 184 (unless (eq (get 'utf-translation-table-for-encode
188 'translation-table) 185 'translation-table)
189 ucs-mule-to-mule-unicode) 186 ucs-mule-to-mule-unicode)
190 (define-translation-table 'utf-translation-table-for-encode) 187 (define-translation-table 'utf-translation-table-for-encode)))
191 (map-char-table
192 (lambda (key val)
193 (if (and (>= key 128) val)
194 (aset char-coding-system-table key
195 (remq 'mule-utf-8
196 (remq 'mule-utf-16-le
197 (remq 'mule-utf-16-be
198 (aref char-coding-system-table
199 key)))))))
200 utf-defragmentation-table)))
201 (set-default s v)) 188 (set-default s v))
202 :version "21.4" 189 :version "21.4"
203 :type 'boolean 190 :type 'boolean
204 :group 'mule) 191 :group 'mule)
205 192
256 (load "subst-jis"))) ; jis covers as much as big5, gb2312 243 (load "subst-jis"))) ; jis covers as much as big5, gb2312
257 (let ((table (make-char-table 'translation-table))) 244 (let ((table (make-char-table 'translation-table)))
258 (maphash (lambda (k v) 245 (maphash (lambda (k v)
259 (aset table k t)) 246 (aset table k t))
260 ucs-mule-cjk-to-unicode) 247 ucs-mule-cjk-to-unicode)
261 (register-char-codings 'mule-utf-8 table)
262 (register-char-codings 'mule-utf-16-le table)
263 (register-char-codings 'mule-utf-16-be table))
264 (define-translation-hash-table 'utf-subst-table-for-decode 248 (define-translation-hash-table 'utf-subst-table-for-decode
265 ucs-unicode-to-mule-cjk) 249 ucs-unicode-to-mule-cjk)
266 (define-translation-hash-table 'utf-subst-table-for-encode 250 (define-translation-hash-table 'utf-subst-table-for-encode
267 ucs-mule-cjk-to-unicode)) 251 ucs-mule-cjk-to-unicode))
268 (map-char-table
269 (lambda (k v)
270 (if (gethash k ucs-mule-cjk-to-unicode)
271 (aset char-coding-system-table k
272 (remq 'mule-utf-8
273 (remq 'mule-utf-16-le
274 (remq 'mule-utf-16-be v))))))
275 char-coding-system-table)
276 (define-translation-hash-table 'utf-subst-table-for-decode 252 (define-translation-hash-table 'utf-subst-table-for-decode
277 (make-hash-table :test 'eq)) 253 (make-hash-table :test 'eq))
278 (define-translation-hash-table 'utf-subst-table-for-encode 254 (define-translation-hash-table 'utf-subst-table-for-encode
279 (make-hash-table :test 'eq))) 255 (make-hash-table :test 'eq))))
280 (optimize-char-coding-system-table)
281 (set-default s v)) 256 (set-default s v))
282 :version "21.4" 257 :version "21.4"
283 :type 'boolean 258 :type 'boolean
284 :set-after '(current-language-environment) 259 :set-after '(current-language-environment)
285 :group 'mule) 260 :group 'mule)