;;; ucs-tables.el --- translation to, from and via Unicode -*- coding: iso-2022-7bit -*-
-;; Copyright (C) 2001, 2002 Free Software Foundation, Inc.
+;; Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2003
+;; National Institute of Advanced Industrial Science and Technology (AIST)
+;; Registration Number H14PRO021
;; Author: Dave Love <fx@gnu.org>
;; Keywords: i18n
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
;;; Commentary:
"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.
The ISO 8859 characters sets overlap, e.g. 8859-1 (Latin-1) and
8859-15 (Latin-9) differ only in a few characters. Emacs normally
distinguishes equivalent characters from those ISO-8859 character sets
-which are built in to Emacs. This behaviour is essentially inherited
+which are built in to Emacs. This behavior is essentially inherited
from the European-originated international standards. Treating them
equivalently, by translating to and from a single representation is
called `unification'. (The `utf-8' coding system treats the
;; normal-mode and minibuffer-setup-hook.
(defun ucs-set-table-for-input (&optional buffer)
"Set up an appropriate `translation-table-for-input' for BUFFER.
-BUFFER defaults to the current buffer."
+BUFFER defaults to the current buffer. This function is
+automatically called directly at the end of `get-buffer-create'."
(when (and unify-8859-on-encoding-mode
+ (not unify-8859-on-decoding-mode)
(char-table-p translation-table-for-input))
(let ((cs (and buffer-file-coding-system
(coding-system-base buffer-file-coding-system)))
(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)))
+ (setq table (coding-system-get cs 'translation-table-for-input))
+ (if (and table (symbolp table))
+ (setq table (get table 'translation-table))))
(when (char-table-p table)
(if buffer
(with-current-buffer buffer
- (set (make-variable-buffer-local 'translation-table-for-input)
+ (set (make-local-variable 'translation-table-for-input)
table))
- (set (make-variable-buffer-local 'translation-table-for-input)
+ (set (make-local-variable 'translation-table-for-input)
table)))))))
;; The minibuffer needs to acquire a `buffer-file-coding-system' for
(provide 'ucs-tables)
-;;; arch-tag: b497e22b-7fe1-486a-9352-e2d7f7d76a76
+;; arch-tag: b497e22b-7fe1-486a-9352-e2d7f7d76a76
;;; ucs-tables.el ends here