1 ;;; ids-util.el --- Utilities about ideographic-structure -*- coding: utf-8 -*-
3 ;; Copyright (C) 2001,2002,2003 MORIOKA Tomohiko
5 ;; Author: MORIOKA Tomohiko <tomo@kanji.zinbun.kyoto-u.ac.jp>
6 ;; Keywords: ideographic-structure, CHISE, IDS, IDC, UCS, database
8 ;; This file is a part of Tomoyo Utilities.
10 ;; This program 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 ;; This program is distributed in the hope that it will be useful, but
16 ;; 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 this program; 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.
30 (defun ideographic-structure-convert-to-ucs (structure)
31 (let (dest cell ucs ret)
33 (setq cell (car structure))
36 (cond ((characterp cell)
37 (if (or (get-char-attribute cell 'ucs)
40 (or (get-char-attribute cell '=>ucs)
41 (get-char-attribute cell '->ucs)))))
43 (decode-char 'ucs ucs)))
47 ((setq ret (find-char cell))
48 (if (or (get-char-attribute ret 'ucs)
51 (or (get-char-attribute ret '=>ucs)
52 (get-char-attribute ret '->ucs)))))
54 (decode-char 'ucs ucs)))
55 ((setq ret (assq 'ideographic-structure cell))
56 (put-alist 'ideographic-structure
57 (ideographic-structure-convert-to-ucs
62 (setq structure (cdr structure)))
65 (defun char-cns11643-p (char &optional defined-only)
68 (intern (format "=cns11643-%d" n))
72 (defun char-representative-of-cns11643 (char)
73 (if (char-cns11643-p char)
75 (let ((ucs (char-ucs char))
79 (char-variants (decode-char 'ucs ucs))))
81 (setq char (car variants))
82 (not (char-cns11643-p char)))
83 (setq variants (cdr variants))))
86 (defun ideographic-structure-convert-to-cns11643 (structure)
87 (let (dest cell ucs ret)
89 (setq cell (car structure))
92 (cond ((characterp cell)
93 (char-representative-of-cns11643 cell))
97 ((setq ret (find-char cell))
98 (char-representative-of-cns11643 ret))
99 ((setq ret (assq 'ideographic-structure cell))
100 (put-alist 'ideographic-structure
101 (ideographic-structure-convert-to-cns11643
106 (setq structure (cdr structure)))
109 (defvar morohashi-char-replace-alist
111 (cons (decode-char 'chinese-big5-cdp #x8B42)
112 (decode-char 'chinese-big5-cdp #x8B42))
113 (cons (decode-char 'chinese-big5-cdp #x8AFC)
114 (decode-char 'chinese-big5-cdp #x8AFC))
115 (cons (decode-char 'ucs #x2EBE)
116 (decode-char 'ucs #x2EBF))
117 (cons (decode-char 'ucs #x4EA0)
118 (decode-char 'chinese-big5-cdp #x8B42))
119 (cons (decode-char 'ucs #x4EBD)
120 (decode-char 'chinese-big5-cdp #x8AFC))
121 (cons (decode-char 'ucs #x517C)
122 (decode-char 'ideograph-gt 01936))
123 (cons ?亼 (decode-char 'chinese-big5-cdp #x8AFC))
124 (cons (decode-char 'chinese-big5-cdp #x8AFC)
125 (decode-char 'chinese-big5-cdp #x8AFC))
126 (cons (decode-char 'chinese-big5-cdp #x8B69)
127 (decode-char 'chinese-big5-cdp #x8A60))
128 (cons (decode-char 'ucs #x4FDE)
129 (decode-char 'ideograph-daikanwa 01437))
130 (cons (decode-char 'ucs #x5151)
131 (decode-char 'ideograph-daikanwa 01356))
132 (cons (decode-char 'ucs #x5154)
133 (decode-char 'ideograph-daikanwa 01368))
134 (cons (decode-char 'ucs #x5179)
135 (decode-char 'ideograph-daikanwa 30911))
136 (cons (decode-char 'ucs #x518D)
137 (decode-char 'ideograph-daikanwa 01524))
138 (cons (decode-char 'ucs #x5193)
139 (decode-char 'ideograph-gt 02025))
140 (cons (decode-char 'ucs #x53CA)
141 (decode-char 'ideograph-daikanwa 03118))
142 (cons (decode-char 'ucs #x544A)
143 (decode-char 'ideograph-daikanwa 03381))
144 (cons (decode-char 'ucs #x5468)
145 (decode-char 'ideograph-daikanwa 03441))
147 (cons (decode-char 'ucs #x5922)
148 (decode-char 'ideograph-daikanwa 05802))
149 (cons (decode-char 'ucs #x5C1A)
150 (decode-char 'ucs #x5C19))
151 (cons (decode-char 'ucs #x5D29)
152 (decode-char 'ideograph-daikanwa 08212))
153 (cons (decode-char 'ucs #x5F66)
154 (decode-char 'ideograph-daikanwa 09980))
155 (cons (decode-char 'ucs #x6247)
156 (decode-char 'ideograph-daikanwa 11743))
157 (cons (decode-char 'ucs #x656C)
158 (decode-char 'ideograph-daikanwa 13303))
159 (cons (decode-char 'ucs #x65E2)
160 (decode-char 'ideograph-daikanwa 13724))
161 (cons (decode-char 'ucs #x6B21)
162 (decode-char 'ideograph-daikanwa 15992))
163 (cons (decode-char 'ucs #x7235)
164 (decode-char 'ideograph-daikanwa 19711))
165 (cons (decode-char 'ucs #x7523)
166 (decode-char 'ideograph-daikanwa 21684))
167 (cons (decode-char 'ucs #x76CA)
168 (decode-char 'ideograph-daikanwa 22972))
169 (cons (decode-char 'ucs #x771F)
170 (decode-char 'ideograph-daikanwa 23235))
171 (cons (decode-char 'ucs #x7FBD)
172 (decode-char 'ideograph-daikanwa 28614))
173 (cons (decode-char 'ucs #x7FC1)
174 (decode-char 'ideograph-daikanwa 28635))
175 (cons (decode-char 'ucs #x2EA4)
176 (decode-char 'ucs #x722B))
177 (cons (decode-char 'ucs #x8005)
178 (decode-char 'ideograph-daikanwa 28853))
179 (cons (decode-char 'ucs #x8096)
180 (decode-char 'ideograph-daikanwa 29263))
181 (cons (decode-char 'ucs #x82E5)
182 (decode-char 'ideograph-daikanwa 30796))
183 (cons (decode-char 'ucs #x82D7)
184 (decode-char 'ideograph-daikanwa 30781))
185 (cons (decode-char 'ucs #x82F1)
186 (decode-char 'ideograph-daikanwa 30808))
187 (cons (decode-char 'ucs #x8336)
188 (decode-char 'ideograph-daikanwa 30915))
189 (cons (decode-char 'ucs #x8449)
190 (decode-char 'ideograph-daikanwa 31387))
191 (cons (decode-char 'ucs #x9023)
192 (decode-char 'ideograph-daikanwa 38902))
193 (cons (decode-char 'ucs #x9053)
194 (decode-char 'ideograph-daikanwa 39010))
195 (cons (decode-char 'ucs #x9054)
196 (decode-char 'ideograph-daikanwa 39011))
197 (cons (decode-char 'ucs #x9063)
198 (decode-char 'ideograph-daikanwa 39052))
199 (cons (decode-char 'ucs #x9752)
200 (decode-char 'ucs #x9751))
201 (cons (decode-char 'ucs #x670B)
202 (decode-char 'ideograph-daikanwa 14340))
203 (cons (decode-char 'ucs #x8981)
204 (decode-char 'ideograph-daikanwa 34768))
205 (cons (decode-char 'ucs #x8AF8)
206 (decode-char 'ideograph-daikanwa 35743))
207 (cons (decode-char 'japanese-jisx0213-2 #x2327)
208 (decode-char 'japanese-jisx0213-2 #x2327))
209 (cons (decode-char 'chinese-big5-cdp #x8BFA)
210 (decode-char 'japanese-jisx0213-2 #x2327))
214 (defun ideographic-structure-convert-to-daikanwa (structure)
215 (let (dest cell morohashi ret ret2 ret3)
217 (setq cell (car structure))
220 (cond ((characterp cell)
222 (assq cell morohashi-char-replace-alist))
224 ((get-char-attribute cell 'ideograph-daikanwa)
228 cell 'morohashi-daikanwa))
229 (cond ((null (cdr (cdr morohashi)))
231 ((= (nth 1 morohashi) 0)
232 (decode-char 'ideograph-daikanwa
235 (setq morohashi (list (car morohashi)
237 (or (map-char-attribute
239 (if (equal morohashi val)
246 (symbolp (car cell)))
248 ((setq ret (find-char cell))
249 (if (or (get-char-attribute ret 'ideograph-daikanwa)
253 ret 'morohashi-daikanwa)))
254 (null (cdr (cdr morohashi))))
256 (if (= (nth 1 morohashi) 0)
257 (decode-char 'ideograph-daikanwa (car morohashi))
259 ((setq ret (assq 'ideographic-structure cell))
261 (ideographic-structure-convert-to-daikanwa
263 (if (setq ret3 (ideographic-structure-find-char ret2))
265 (put-alist 'ideographic-structure
270 (setq structure (cdr structure)))
279 ;;; ids-util.el ends here