1 ;;; read-maps.el --- Read mapping-tables.
3 ;; Copyright (C) 2002,2003,2004,2005 MORIOKA Tomohiko
5 ;; Author: MORIOKA Tomohiko <tomo@kanji.zinbun.kyoto-u.ac.jp>
6 ;; Keywords: mapping table, character, CCS, multiscript, multilingual
8 ;; This file is part of XEmacs CHISE.
10 ;; XEmacs CHISE is free software; you can redistribute it and/or
11 ;; modify it under the terms of the GNU General Public License as
12 ;; published by the Free Software Foundation; either version 2, or (at
13 ;; your option) any later version.
15 ;; XEmacs CHISE is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ;; General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with XEmacs CHISE; see the file COPYING. If not, write to
22 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
27 (defvar mapping-table-ccs-setting-alist
29 "^J90-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\)" 1 16
31 "\tJU[+-]\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]+\\)")
33 "^JSP-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\)" 1 16
35 "\tJU[+-]\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]+\\)")
37 "^JX1-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\)" 1 16
39 "\tJU[+-]\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]+\\)")
41 "^JX2-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\)" 1 16
43 "\tJU[+-]\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]+\\)")
45 "^G0-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\)" 1 16
47 "\tGU[+-]\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]+\\)")
49 "^C1-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\)" 1 16
51 "\tCU[+-]\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]+\\)")
53 "^C2-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\)" 1 16
55 "\tCU[+-]\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]+\\)")
57 "^C3-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\)" 1 16
59 "\tCU[+-]\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]+\\)")
61 "^C4-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\)" 1 16
63 "\tCU[+-]\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]+\\)")
65 "^C5-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\)" 1 16
67 "\tCU[+-]\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]+\\)")
69 "^B-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\)" 1 16
71 "\tBU[+-]\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]+\\)")
73 "^JC3-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\)" 1 16
77 "*List of information about mapping table formats.
78 Elements are of the form
79 \(CCS CODE-REGEXP PAREN-EXP BASE UCS-CCS UCS-REGEXP).
81 CCS is a symbol, which is a name of a target coded-charset.
83 CODE-REGEXP is a regular expression to match against
84 the representation of the target coded-charset.
86 PAREN-EXP is a number specifies which parenthesized expression
89 BASE base of code in the string specified by CODE-REGEXP and
92 UCS-CCS is a symbol, which is a name of a UCS-CCS.
94 UCS-REGEXP is a regular expression to match against
95 the representation of the UCS-CCS.")
98 (defun mapping-table-read-file (filename)
100 (interactive "fMapping table : ")
102 (buffer-disable-undo)
103 (insert-file-contents filename)
104 (goto-char (point-min))
105 (let (rest setting ccs code ucs ucs-pat ucs-ccs ucs-code chr)
107 (setq rest mapping-table-ccs-setting-alist)
110 (setq setting (car rest)
112 (when (looking-at (pop setting))
113 (setq code (string-to-int (match-string (pop setting))
115 ucs-ccs (pop setting)
116 ucs-pat (car setting))
117 (goto-char (match-end 0))
119 (setq rest (cdr rest)))
126 (looking-at ucs-pat))
128 (string-to-int (match-string 1) 16)
129 (goto-char (match-end 0)))))
132 "[ \t]*U[+-]\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]+\\)")
133 (string-to-int (match-string 1) 16)))
134 (if (and ucs-ccs ucs (not ucs-code))
137 (when (setq chr (decode-char ccs code))
138 (unless (eq (encode-char chr ccs 'defined-only)
140 (put-char-attribute chr ccs code))
144 (encode-char chr ucs-ccs 'defined-only)
146 ((memq ucs-ccs '(=ucs@jis
149 (encode-char chr '=ucs@jis/fw 'defined-only))
150 ((eq ucs-ccs '=ucs@gb)
151 (encode-char chr '=ucs@gb/fw 'defined-only))
152 ;; ((eq ucs-ccs '=ucs@big5)
155 (char-feature chr '=>ucs))))
157 (put-char-attribute chr ucs-ccs ucs-code))
159 (not (eq (or (encode-char chr '=ucs 'defined-only)
160 (and (not (memq ucs-ccs '(=ucs@jis
166 (char-feature chr '=>ucs)))
168 (if (or ucs-code (null ucs-ccs))
169 (unless (eq (char-feature chr '=>ucs) ucs)
170 (put-char-attribute chr '=>ucs ucs))
171 (unless (eq (encode-char chr ucs-ccs 'defined-only)
173 (put-char-attribute chr ucs-ccs ucs)))))
176 (defun jp-jouyou-read-file (filename)
177 (interactive "fjp-jouyou file : ")
179 (buffer-disable-undo)
180 (insert-file-contents filename)
181 (goto-char (point-min))
183 (while (re-search-forward "^[^\t\n ]+\t\\(.\\)\t*" nil t)
184 (setq char (aref (match-string 1) 0)
185 tchars (buffer-substring (match-end 0)
187 (when (> (length tchars) 0)
191 (split-string tchars " ")))
192 (unless (or (equal (char-feature char '<-simplified@JP/Jouyou)
194 (and (equal (char-feature char '<-simplified)
197 (char-feature char '<-simplified*sources))))
198 (put-char-attribute char
199 '<-simplified@JP/Jouyou
201 ;; (put-char-attribute
202 ;; char 'script (adjoin
208 ;; (get-char-attribute char 'script)))))
213 ;;; read-maps.el ends here