;;; unicode.el --- for UNICODE special features;; Copyright (C) 1997-2001 Miyashita Hisashi;; Keywords: mule, multilingual, ;; character set, coding-system, ISO10646, Unicode;; This file is part of Mule-UCS;; Mule-UCS is free software; you can redistribute it and/or modify;; it under the terms of the GNU General Public License as published by;; the Free Software Foundation; either version 2, or (at your option);; any later version.;; Mule-UCS is distributed in the hope that it will be useful,;; but WITHOUT ANY WARRANTY; without even the implied warranty of;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the;; GNU General Public License for more details.;; You should have received a copy of the GNU General Public License;; along with this program; see the file COPYING. If not, write to the;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,;; Boston, MA 02111-1307, USA.;; Comment:;; This module supports unicode translations.(require'mucs)(require'trans-util)(require'un-data);;; ucs-generic character elisp representation;; (1) ... a simple number.;; (2) ... a string that shows a number in c-format.;; E.g., "0x611A";; If any other representations are converted to elisp;; representation, normalize it to (1) form.;; Why introduce (2)? Because there is no compatible format;; on hexadecimal literal between Emacs20 and XEmacs...x_x;(defunucs-generic-elisp-representation(x)(if(numberpx)x(if(stringpx)(c-notated-string-to-numberx)(error"Invalid ucs-generic represenation:%S"x))));;;;;; UCS generic type definition.;;;(mucs-define-type'ucs-generic(functionucs-generic-elisp-representation)(functionidentity));;;;;; translation generator;;; (work in progress...);;;;;; en/decode-char backends.;;;(defunucs-representation-encoding-backend(charrepresentationrestriction)(logior(lsh(charset-id(char-charsetchar))16)(char-codepointchar))(mucs-convert'emacs-char-to-ucs-codepoint-conversionchar))(defunucs-representation-decoding-backend(representationobjectrestriction)(if(numberpobject)(mucs-convert'ucs-codepoint-to-emacs-char-conversionobject)(signal'wrong-type-argument(list'numberpobject))))(mucs-register-representation-encoding-backend'ucsnil(functionucs-representation-encoding-backend))(mucs-register-representation-decoding-backend'ucsnil(functionucs-representation-decoding-backend));;;;;; Unicode or its transformation format support function.;;; (obsoleted by encode-char/decode-char);;;(defunucs-to-char(codepoint)"Convert Unicode codepoint to an XEmacs character.CODE should be a non-negative integer.If `codepoint' cannot be represented as an XEmacs character--that is,Mule-UCS doesn't know about any registered translation from it to somecharacter in the multiple-character-set non-Unified Mule model, return nil.Beware that *many* Unicode codepoints have no representation in the Mulemodel, and since the Mule-UCS coding systems have the same backend as doesthis function, they will tend to trash data. "(ucs-representation-decoding-backend'ucscodepointnil))(defunchar-to-ucs(char)"Convert character to Unicode codepoint. "(ucs-representation-encoding-backendchar'ucsnil));;;;;; Commands for editing.;;;(defuninsert-ucs-character(codepoint)"Insert character which is converted from give UCS codepoint."(interactive"nUCS codepoint:")(insert(or(ucs-representation-decoding-backend'ucscodepointnil)(error"Invalid or cannot translate:U+%X"codepoint))))(provide'mule-ucs-unicode)(provide'unicode);;; unicode.el ends here.