(when for-encode
;; Make mule-utf-* encode all characters in ucs-mule-to-mule-unicode.
- (let ((coding-list '(mule-utf-8 mule-utf-16-be mule-utf-16-le)))
+ (let ((coding-list '(mule-utf-8 mule-utf-16be mule-utf-16le
+ mule-utf-16be-with-signature
+ mule-utf-16le-with-signature)))
(define-translation-table 'utf-translation-table-for-encode
ucs-mule-to-mule-unicode)
(dolist (coding coding-list)
(set-char-table-parent (coding-system-get coding 'safe-chars)
- ucs-mule-to-mule-unicode)
- (register-char-codings coding ucs-mule-to-mule-unicode)))
+ ucs-mule-to-mule-unicode)))
;; Adjust the 8859 coding systems to fragment the unified characters
;; on encoding.
;; used after they've been registered, but we might as well
;; record them. Setting the parent here is a convenience.
(set-char-table-parent safe table)
- ;; Update the table of what encodes to what.
- (register-char-codings coding-system table)
(coding-system-put coding-system 'translation-table-for-encode table)))
- (add-hook 'minibuffer-setup-hook 'ucs-minibuffer-setup))
- (optimize-char-coding-system-table))
+ (add-hook 'minibuffer-setup-hook 'ucs-minibuffer-setup)))
(defun ucs-fragment-8859 (for-encode for-decode)
"Undo the unification done by `ucs-unify-8859'.
;; ucs-mule-to-mule-unicode except what was originally supported
;; and what is translated by utf-translation-table-for-decode when
;; `utf-fragment-on-decoding' is non-nil.
- (let ((coding-list '(mule-utf-8 mule-utf-16-be mule-utf-16-le))
+ (let ((coding-list '(mule-utf-8 mule-utf-16be mule-utf-16le
+ mule-utf-16be-with-signature
+ mule-utf-16le-with-signature))
(safe (coding-system-get 'mule-utf-8 'safe-chars)))
(dolist (coding coding-list)
(set-char-table-parent (coding-system-get coding 'safe-chars) nil))
- ;; Here we assume that all mule-utf-* have the same character
- ;; repertory, thus we can use SAFE for all of them.
- (map-char-table
- (lambda (key val)
- (if (and (>= key 128) val
- (not (aref safe key)))
- (aset char-coding-system-table key
- (remq 'mule-utf-8
- (remq 'mule-utf-16-le
- (remq 'mule-utf-16-be
- (aref char-coding-system-table key)))))))
- ucs-mule-to-mule-unicode)
-
(if (not utf-fragment-on-decoding)
(define-translation-table 'utf-translation-table-for-encode)
(define-translation-table 'utf-translation-table-for-encode
- utf-defragmentation-table)
- (dolist (coding coding-list)
- (register-char-codings coding utf-defragmentation-table))))
+ utf-defragmentation-table)))
- ;; For each charset, remove the entries in
- ;; `char-coding-system-table' added to its safe-chars table (as
- ;; its parent).
+ ;; For each charset, remove the parent of `safe-chars' property of
+ ;; the corresponding coding system.
(dolist (n '(1 2 3 4 5 7 8 9 14 15))
(let* ((coding-system
(coding-system-base (intern (format "iso-8859-%d" n))))
- (table (symbol-value
- (intern (format "ucs-8859-%d-encode-table" n))))
(safe (coding-system-get coding-system 'safe-chars)))
- (when (char-table-parent safe)
- (map-char-table
- (lambda (key val)
- (if (and (>= key 128) val)
- (let ((codings (aref char-coding-system-table key)))
- (aset char-coding-system-table key
- (remq coding-system codings)))))
- (char-table-parent safe))
- (set-char-table-parent safe nil))
+ (if (char-table-parent safe)
+ (set-char-table-parent safe nil))
(coding-system-put coding-system 'translation-table-for-encode nil)))
- (optimize-char-coding-system-table)
- (remove-hook 'minibuffer-setup-hook 'ucs-minibuffer-setup))
- (optimize-char-coding-system-table))
+ (remove-hook 'minibuffer-setup-hook 'ucs-minibuffer-setup)))
(defun ucs-insert (arg)
"Insert the Emacs character representation of the given Unicode.
Interactively, prompts for a hex string giving the code."
(interactive "sUnicode (hex): ")
- (let ((c (decode-char 'ucs (if (integerp arg)
- arg
- (string-to-number arg 16)))))
+ (or (integerp arg)
+ (setq arg (string-to-number arg 16)))
+ (let ((c (decode-char 'ucs arg)))
(if c
(insert c)
- (error "Character can't be decoded to UCS"))))
+ (if (or (< arg 0) (> arg #x10FFFF))
+ (error "Not a Unicode character code: 0x%X" arg)
+ (error "Character U+%04X is not yet supported" arg)))))
;;; Dealing with non-8859 character sets.
(coding-system-base default-buffer-file-coding-system))))
(when cs
(setq table (coding-system-get cs 'translation-table-for-encode))
+ (if (and table (symbolp table))
+ (setq table (get table 'translation-table)))
(unless (char-table-p table)
(setq table (coding-system-get cs 'translation-table-for-input)))
(when (char-table-p table)
(provide 'ucs-tables)
+;;; arch-tag: b497e22b-7fe1-486a-9352-e2d7f7d76a76
;;; ucs-tables.el ends here