comparison lisp/international/utf-8.el @ 50341:f49a20cb84ed

(utf-translate-cjk-mode): Minor mode, replaces variable utf-translate-cjk which must be set via Custom.
author Kai Großjohann <kgrossjo@eu.uu.net>
date Sat, 29 Mar 2003 17:11:42 +0000
parents b49563831bd2
children c8525ac04d76
comparison
equal deleted inserted replaced
50340:810c2ac4b064 50341:f49a20cb84ed
188 (set-default s v)) 188 (set-default s v))
189 :version "21.4" 189 :version "21.4"
190 :type 'boolean 190 :type 'boolean
191 :group 'mule) 191 :group 'mule)
192 192
193 (defcustom utf-translate-cjk nil 193 (define-minor-mode utf-translate-cjk-mode
194 "Whether the UTF based coding systems should decode/encode CJK characters. 194 "Whether the UTF based coding systems should decode/encode CJK characters.
195 Enabling this loads tables which allow the coding systems mule-utf-8, 195 Enabling this loads tables which allow the coding systems mule-utf-8,
196 mule-utf-16-le and mule-utf-16-be to encode characters in the charsets 196 mule-utf-16-le and mule-utf-16-be to encode characters in the charsets
197 `korean-ksc5601', `chinese-gb2312', `chinese-big5-1', 197 `korean-ksc5601', `chinese-gb2312', `chinese-big5-1',
198 `chinese-big5-2', `japanese-jisx0208' and `japanese-jisx0212', and to 198 `chinese-big5-2', `japanese-jisx0208' and `japanese-jisx0212', and to
203 turned on: ksc5601 for Korean, gb2312 for Chinese-GB, big5 for 203 turned on: ksc5601 for Korean, gb2312 for Chinese-GB, big5 for
204 Chinese-Big5 and jisx for other environments. 204 Chinese-Big5 and jisx for other environments.
205 205
206 The tables are large (over 40000 entries), so this option is not the 206 The tables are large (over 40000 entries), so this option is not the
207 default. Also, installing them may be rather slow." 207 default. Also, installing them may be rather slow."
208 :set (lambda (s v) 208 :init-value nil
209 (if v
210 ;; Fixme: Allow the use of the CJK charsets to be
211 ;; customized by reordering and possible omission.
212 (progn
213 ;; Redefine them with realistic initial sizes and a
214 ;; smallish rehash size to avoid wasting significant
215 ;; space after they're built.
216 (setq ucs-mule-cjk-to-unicode
217 (make-hash-table :test 'eq :size 43000 :rehash-size 1000)
218 ucs-unicode-to-mule-cjk
219 (make-hash-table :test 'eq :size 43000 :rehash-size 1000))
220 ;; Load the files explicitly, to avoid having to keep
221 ;; around the large tables they contain (as well as the
222 ;; ones which get built).
223 (cond
224 ((string= "Korean" current-language-environment)
225 (load "subst-jis")
226 (load "subst-big5")
227 (load "subst-gb2312")
228 (load "subst-ksc"))
229 ((string= "Chinese-BIG5" current-language-environment)
230 (load "subst-jis")
231 (load "subst-ksc")
232 (load "subst-gb2312")
233 (load "subst-big5"))
234 ((string= "Chinese-GB" current-language-environment)
235 (load "subst-jis")
236 (load "subst-ksc")
237 (load "subst-big5")
238 (load "subst-gb2312"))
239 (t
240 (load "subst-ksc")
241 (load "subst-gb2312")
242 (load "subst-big5")
243 (load "subst-jis"))) ; jis covers as much as big5, gb2312
244 (let ((table (make-char-table 'translation-table)))
245 (maphash (lambda (k v)
246 (aset table k t))
247 ucs-mule-cjk-to-unicode)
248 (define-translation-hash-table 'utf-subst-table-for-decode
249 ucs-unicode-to-mule-cjk)
250 (define-translation-hash-table 'utf-subst-table-for-encode
251 ucs-mule-cjk-to-unicode))
252 (define-translation-hash-table 'utf-subst-table-for-decode
253 (make-hash-table :test 'eq))
254 (define-translation-hash-table 'utf-subst-table-for-encode
255 (make-hash-table :test 'eq))))
256 (set-default s v))
257 :version "21.4" 209 :version "21.4"
258 :type 'boolean 210 :type 'boolean
259 :set-after '(current-language-environment) 211 :set-after '(current-language-environment)
260 :group 'mule) 212 :group 'mule
213 :global t
214 (if utf-translate-cjk-mode
215 ;; Fixme: Allow the use of the CJK charsets to be
216 ;; customized by reordering and possible omission.
217 (progn
218 ;; Redefine them with realistic initial sizes and a
219 ;; smallish rehash size to avoid wasting significant
220 ;; space after they're built.
221 (setq ucs-mule-cjk-to-unicode
222 (make-hash-table :test 'eq :size 43000 :rehash-size 1000)
223 ucs-unicode-to-mule-cjk
224 (make-hash-table :test 'eq :size 43000 :rehash-size 1000))
225 ;; Load the files explicitly, to avoid having to keep
226 ;; around the large tables they contain (as well as the
227 ;; ones which get built).
228 (cond
229 ((string= "Korean" current-language-environment)
230 (load "subst-jis")
231 (load "subst-big5")
232 (load "subst-gb2312")
233 (load "subst-ksc"))
234 ((string= "Chinese-BIG5" current-language-environment)
235 (load "subst-jis")
236 (load "subst-ksc")
237 (load "subst-gb2312")
238 (load "subst-big5"))
239 ((string= "Chinese-GB" current-language-environment)
240 (load "subst-jis")
241 (load "subst-ksc")
242 (load "subst-big5")
243 (load "subst-gb2312"))
244 (t
245 (load "subst-ksc")
246 (load "subst-gb2312")
247 (load "subst-big5")
248 (load "subst-jis"))) ; jis covers as much as big5, gb2312
249 (let ((table (make-char-table 'translation-table)))
250 (maphash (lambda (k v)
251 (aset table k t))
252 ucs-mule-cjk-to-unicode)
253 (define-translation-hash-table 'utf-subst-table-for-decode
254 ucs-unicode-to-mule-cjk)
255 (define-translation-hash-table 'utf-subst-table-for-encode
256 ucs-mule-cjk-to-unicode))
257 (define-translation-hash-table 'utf-subst-table-for-decode
258 (make-hash-table :test 'eq))
259 (define-translation-hash-table 'utf-subst-table-for-encode
260 (make-hash-table :test 'eq)))))
261 261
262 (define-ccl-program ccl-decode-mule-utf-8 262 (define-ccl-program ccl-decode-mule-utf-8
263 ;; 263 ;;
264 ;; charset | bytes in utf-8 | bytes in emacs 264 ;; charset | bytes in utf-8 | bytes in emacs
265 ;; -----------------------+----------------+--------------- 265 ;; -----------------------+----------------+---------------