1 ;;; ids-dump.el --- Dump utility of IDS-* files
3 ;; Copyright (C) 2002 MORIOKA Tomohiko
5 ;; Author: MORIOKA Tomohiko <tomo@kanji.zinbun.kyoto-u.ac.jp>
6 ;; Keywords: IDS, IDC, Ideographs, UCS, Unicode
8 ;; This file is a part of IDS.
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.
29 (defun ids-dump-insert-line (ccs line-spec code)
30 (let ((chr (decode-char ccs code))
33 (setq id-list (get-char-attribute chr 'ideographic-structure))
34 (insert (format line-spec
35 code (decode-builtin-char ccs code)
37 (ids-format-list id-list)
38 (char-to-string chr)))))))
40 (defun ids-dump-insert-ccs-ranges (ccs line-spec &rest ranges)
41 (let (range code max-code)
43 (setq range (car ranges))
45 (setq code (car range)
47 (while (<= code max-code)
48 (ids-dump-insert-line ccs line-spec code)
49 (setq code (1+ code))))
51 (ids-dump-insert-line ccs line-spec range))
52 (t (error 'wrong-type-argument range)))
53 (setq ranges (cdr ranges)))))
55 (defun ids-dump-insert-daikanwa (start end)
61 (when (= (length val) 2)
64 (put-alist (nth 1 val)
66 (cdr (assq (car val) mdh-alist)))))
70 (when (setq chr (decode-char 'ideograph-daikanwa i))
72 (format "M-%05d \t%c\t%s\n"
73 i (decode-builtin-char 'ideograph-daikanwa i)
75 (get-char-attribute chr 'ideographic-structure)))))
76 (when (setq sal (assq i mdh-alist))
78 (when (setq chr (assq 1 sal))
81 (format "M-%05d'\t%c\t%s\n"
84 (get-char-attribute chr 'ideographic-structure)))))
85 (when (setq chr (assq 2 sal))
88 (format "M-%05d\"\t%c\t%s\n"
91 (get-char-attribute chr 'ideographic-structure)))))
95 (defun ids-dump-insert-daikanwa-hokan ()
99 (when (and (eq (car val) 'ho)
100 (null (nthcdr 2 val)))
101 (setq sal (cons (cons (nth 1 val) key) sal)))
104 (setq sal (sort sal (lambda (a b) (< (car a)(car b)))))
106 (setq chr (cdr cell))
108 (format "MH-%04d \t%c\t%s\n"
112 (get-char-attribute chr 'ideographic-structure)))))))
114 (defun ids-dump-insert-jis-x0208-1990 ()
122 (setq chr (make-char 'japanese-jisx0208-1990 h l))
124 (format "J90-%02X%02X\t%c\t%s\n"
126 (decode-builtin-char 'japanese-jisx0208-1990
127 (logior (lsh h 8) l))
129 (get-char-attribute chr 'ideographic-structure))))
130 (setq cell (1+ cell)))
136 (setq chr (make-char 'japanese-jisx0208-1990 h l))
138 (format "J90-%02X%02X\t%c\t%s\n"
140 (decode-builtin-char 'japanese-jisx0208-1990
141 (logior (lsh h 8) l))
143 (get-char-attribute chr 'ideographic-structure))))
144 (setq cell (1+ cell)))))
146 (defun ids-dump-range (file path func &rest args)
148 (let* ((coding-system-for-write 'utf-8-mcs-er))
149 (if (file-directory-p path)
150 (setq path (expand-file-name file path)))
151 (insert ";; -*- coding: utf-8-mcs-er -*-\n")
153 (write-region (point-min)(point-max) path))))
156 (defun ids-dump-ucs-basic (filename)
157 (interactive "Fdump IDS-UCS-Basic : ")
158 (ids-dump-range "IDS-UCS-Basic.txt" filename
159 #'ids-dump-insert-ccs-ranges 'ucs "U+%04X\t%c\t%s\n"
163 (defun ids-dump-ucs-ext-a (filename)
164 (interactive "Fdump IDS-UCS-Ext-A : ")
165 (ids-dump-range "IDS-UCS-Ext-A.txt" filename
166 #'ids-dump-insert-ccs-ranges 'ucs "U+%04X\t%c\t%s\n"
167 '(#x3400 . #x4DB5) #xFA1F #xFA23))
170 (defun ids-dump-ucs-compat (filename)
171 (interactive "Fdump IDS-UCS-Compat : ")
172 (ids-dump-range "IDS-UCS-Compat.txt" filename
173 #'ids-dump-insert-ccs-ranges 'ucs "U+%04X\t%c\t%s\n"
174 '(#xF900 . #xFA1E) '(#xFA20 . #xFA22) '(#xFA24 . #xFA2D)))
177 (defun ids-dump-ucs-ext-b-1 (filename)
178 (interactive "Fdump IDS-UCS-Ext-B-1 : ")
179 (ids-dump-range "IDS-UCS-Ext-B-1.txt" filename
180 #'ids-dump-insert-ccs-ranges 'ucs "U-%08X\t%c\t%s\n"
181 '(#x20000 . #x21FFF)))
184 (defun ids-dump-ucs-ext-b-2 (filename)
185 (interactive "Fdump IDS-UCS-Ext-B-2 : ")
186 (ids-dump-range "IDS-UCS-Ext-B-2.txt" filename
187 #'ids-dump-insert-ccs-ranges 'ucs "U-%08X\t%c\t%s\n"
188 '(#x22000 . #x23FFF)))
191 (defun ids-dump-ucs-ext-b-3 (filename)
192 (interactive "Fdump IDS-UCS-Ext-B-3 : ")
193 (ids-dump-range "IDS-UCS-Ext-B-3.txt" filename
194 #'ids-dump-insert-ccs-ranges 'ucs "U-%08X\t%c\t%s\n"
195 '(#x24000 . #x25FFF)))
198 (defun ids-dump-ucs-ext-b-4 (filename)
199 (interactive "Fdump IDS-UCS-Ext-B-4 : ")
200 (ids-dump-range "IDS-UCS-Ext-B-4.txt" filename
201 #'ids-dump-insert-ccs-ranges 'ucs "U-%08X\t%c\t%s\n"
202 '(#x26000 . #x27FFF)))
205 (defun ids-dump-ucs-ext-b-5 (filename)
206 (interactive "Fdump IDS-UCS-Ext-B-5 : ")
207 (ids-dump-range "IDS-UCS-Ext-B-5.txt" filename
208 #'ids-dump-insert-ccs-ranges 'ucs "U-%08X\t%c\t%s\n"
209 '(#x28000 . #x29FFF)))
212 (defun ids-dump-ucs-ext-b-6 (filename)
213 (interactive "Fdump IDS-UCS-Ext-B-6 : ")
214 (ids-dump-range "IDS-UCS-Ext-B-6.txt" filename
215 #'ids-dump-insert-ccs-ranges 'ucs "U-%08X\t%c\t%s\n"
216 '(#x2A000 . #x2A6D6)))
219 (defun ids-dump-ucs-compat-supplement (filename)
220 (interactive "Fdump IDS-UCS-Compat-Supplement : ")
221 (ids-dump-range "IDS-UCS-Compat-Supplement.txt" filename
222 #'ids-dump-insert-ccs-ranges 'ucs "U-%08X\t%c\t%s\n"
223 '(#x2F800 . #x2FA1D)))
226 (defun ids-dump-daikanwa-01 (filename)
227 (interactive "Fdump IDS-Daikanwa-01 : ")
228 (ids-dump-range "IDS-Daikanwa-01.txt" filename
229 #'ids-dump-insert-daikanwa 00001 01449))
232 (defun ids-dump-daikanwa-02 (filename)
233 (interactive "Fdump IDS-Daikanwa-02 : ")
234 (ids-dump-range "IDS-Daikanwa-02.txt" filename
235 #'ids-dump-insert-daikanwa 01450 04674))
238 (defun ids-dump-daikanwa-03 (filename)
239 (interactive "Fdump IDS-Daikanwa-03 : ")
240 (ids-dump-range "IDS-Daikanwa-03.txt" filename
241 #'ids-dump-insert-daikanwa 04675 07410))
244 (defun ids-dump-daikanwa-04 (filename)
245 (interactive "Fdump IDS-Daikanwa-04 : ")
246 (ids-dump-range "IDS-Daikanwa-04.txt" filename
247 #'ids-dump-insert-daikanwa 07411 11529))
250 (defun ids-dump-daikanwa-05 (filename)
251 (interactive "Fdump IDS-Daikanwa-05 : ")
252 (ids-dump-range "IDS-Daikanwa-05.txt" filename
253 #'ids-dump-insert-daikanwa 11530 14414))
256 (defun ids-dump-daikanwa-06 (filename)
257 (interactive "Fdump IDS-Daikanwa-06 : ")
258 (ids-dump-range "IDS-Daikanwa-06.txt" filename
259 #'ids-dump-insert-daikanwa 14415 17574))
262 (defun ids-dump-daikanwa-07 (filename)
263 (interactive "Fdump IDS-Daikanwa-07 : ")
264 (ids-dump-range "IDS-Daikanwa-07.txt" filename
265 #'ids-dump-insert-daikanwa 17575 22677))
268 (defun ids-dump-daikanwa-08 (filename)
269 (interactive "Fdump IDS-Daikanwa-08 : ")
270 (ids-dump-range "IDS-Daikanwa-08.txt" filename
271 #'ids-dump-insert-daikanwa 22678 28107))
274 (defun ids-dump-daikanwa-09 (filename)
275 (interactive "Fdump IDS-Daikanwa-09 : ")
276 (ids-dump-range "IDS-Daikanwa-09.txt" filename
277 #'ids-dump-insert-daikanwa 28108 32803))
280 (defun ids-dump-daikanwa-10 (filename)
281 (interactive "Fdump IDS-Daikanwa-10 : ")
282 (ids-dump-range "IDS-Daikanwa-10.txt" filename
283 #'ids-dump-insert-daikanwa 32804 38699))
286 (defun ids-dump-daikanwa-11 (filename)
287 (interactive "Fdump IDS-Daikanwa-11 : ")
288 (ids-dump-range "IDS-Daikanwa-11.txt" filename
289 #'ids-dump-insert-daikanwa 38700 42209))
292 (defun ids-dump-daikanwa-12 (filename)
293 (interactive "Fdump IDS-Daikanwa-12 : ")
294 (ids-dump-range "IDS-Daikanwa-12.txt" filename
295 #'ids-dump-insert-daikanwa 42210 48902))
298 (defun ids-dump-daikanwa-index (filename)
299 (interactive "Fdump IDS-Daikanwa-dx : ")
300 (ids-dump-range "IDS-Daikanwa-dx.txt" filename
301 #'ids-dump-insert-daikanwa 48903 49964))
304 (defun ids-dump-daikanwa-hokan (filename)
305 (interactive "Fdump IDS-Daikanwa-ho : ")
306 (ids-dump-range "IDS-Daikanwa-ho.txt" filename
307 #'ids-dump-insert-daikanwa-hokan))
310 (defun ids-dump-cbeta (filename)
311 (interactive "Fdump IDS-CBETA : ")
312 (ids-dump-range "IDS-CBETA.txt" filename
313 #'ids-dump-insert-ccs-ranges
314 'ideograph-cbeta "CB%05d\t%c\t%s\n"
318 (defun ids-dump-jis-x0208-1990 (filename)
319 (interactive "Fdump IDS-JIS-X0208-1990 : ")
320 (ids-dump-range "IDS-JIS-X0208-1990.txt" filename
321 #'ids-dump-insert-jis-x0208-1990))
329 ;;; ids-dump.el ends here