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))
131 (setq cell (1+ cell)))
137 (setq chr (make-char 'japanese-jisx0208-1990 h l))
139 (format "J90-%02X%02X\t%c\t%s\n"
141 (decode-builtin-char 'japanese-jisx0208-1990
142 (logior (lsh h 8) l))
144 (get-char-attribute chr 'ideographic-structure))
146 (setq cell (1+ cell)))))
148 (defun ids-dump-range (file path func &rest args)
150 (let* ((coding-system-for-write 'utf-8-mcs-er))
151 (if (file-directory-p path)
152 (setq path (expand-file-name file path)))
153 (insert ";; -*- coding: utf-8-mcs-er -*-\n")
155 (write-region (point-min)(point-max) path))))
158 (defun ids-dump-ucs-basic (filename)
159 (interactive "Fdump IDS-UCS-Basic : ")
160 (ids-dump-range "IDS-UCS-Basic.txt" filename
161 #'ids-dump-insert-ccs-ranges 'ucs "U+%04X\t%c\t%s\n"
165 (defun ids-dump-ucs-ext-a (filename)
166 (interactive "Fdump IDS-UCS-Ext-A : ")
167 (ids-dump-range "IDS-UCS-Ext-A.txt" filename
168 #'ids-dump-insert-ccs-ranges 'ucs "U+%04X\t%c\t%s\n"
169 '(#x3400 . #x4DB5) #xFA1F #xFA23))
172 (defun ids-dump-ucs-compat (filename)
173 (interactive "Fdump IDS-UCS-Compat : ")
174 (ids-dump-range "IDS-UCS-Compat.txt" filename
175 #'ids-dump-insert-ccs-ranges 'ucs "U+%04X\t%c\t%s\n"
176 '(#xF900 . #xFA1E) '(#xFA20 . #xFA22) '(#xFA24 . #xFA2D)))
179 (defun ids-dump-ucs-ext-b-1 (filename)
180 (interactive "Fdump IDS-UCS-Ext-B-1 : ")
181 (ids-dump-range "IDS-UCS-Ext-B-1.txt" filename
182 #'ids-dump-insert-ccs-ranges 'ucs "U-%08X\t%c\t%s\n"
183 '(#x20000 . #x21FFF)))
186 (defun ids-dump-ucs-ext-b-2 (filename)
187 (interactive "Fdump IDS-UCS-Ext-B-2 : ")
188 (ids-dump-range "IDS-UCS-Ext-B-2.txt" filename
189 #'ids-dump-insert-ccs-ranges 'ucs "U-%08X\t%c\t%s\n"
190 '(#x22000 . #x23FFF)))
193 (defun ids-dump-ucs-ext-b-3 (filename)
194 (interactive "Fdump IDS-UCS-Ext-B-3 : ")
195 (ids-dump-range "IDS-UCS-Ext-B-3.txt" filename
196 #'ids-dump-insert-ccs-ranges 'ucs "U-%08X\t%c\t%s\n"
197 '(#x24000 . #x25FFF)))
200 (defun ids-dump-ucs-ext-b-4 (filename)
201 (interactive "Fdump IDS-UCS-Ext-B-4 : ")
202 (ids-dump-range "IDS-UCS-Ext-B-4.txt" filename
203 #'ids-dump-insert-ccs-ranges 'ucs "U-%08X\t%c\t%s\n"
204 '(#x26000 . #x27FFF)))
207 (defun ids-dump-ucs-ext-b-5 (filename)
208 (interactive "Fdump IDS-UCS-Ext-B-5 : ")
209 (ids-dump-range "IDS-UCS-Ext-B-5.txt" filename
210 #'ids-dump-insert-ccs-ranges 'ucs "U-%08X\t%c\t%s\n"
211 '(#x28000 . #x29FFF)))
214 (defun ids-dump-ucs-ext-b-6 (filename)
215 (interactive "Fdump IDS-UCS-Ext-B-6 : ")
216 (ids-dump-range "IDS-UCS-Ext-B-6.txt" filename
217 #'ids-dump-insert-ccs-ranges 'ucs "U-%08X\t%c\t%s\n"
218 '(#x2A000 . #x2A6D6)))
221 (defun ids-dump-ucs-compat-supplement (filename)
222 (interactive "Fdump IDS-UCS-Compat-Supplement : ")
223 (ids-dump-range "IDS-UCS-Compat-Supplement.txt" filename
224 #'ids-dump-insert-ccs-ranges 'ucs "U-%08X\t%c\t%s\n"
225 '(#x2F800 . #x2FA1D)))
228 (defun ids-dump-daikanwa-01 (filename)
229 (interactive "Fdump IDS-Daikanwa-01 : ")
230 (ids-dump-range "IDS-Daikanwa-01.txt" filename
231 #'ids-dump-insert-daikanwa 00001 01449))
234 (defun ids-dump-daikanwa-02 (filename)
235 (interactive "Fdump IDS-Daikanwa-02 : ")
236 (ids-dump-range "IDS-Daikanwa-02.txt" filename
237 #'ids-dump-insert-daikanwa 01450 04674))
240 (defun ids-dump-daikanwa-03 (filename)
241 (interactive "Fdump IDS-Daikanwa-03 : ")
242 (ids-dump-range "IDS-Daikanwa-03.txt" filename
243 #'ids-dump-insert-daikanwa 04675 07410))
246 (defun ids-dump-daikanwa-04 (filename)
247 (interactive "Fdump IDS-Daikanwa-04 : ")
248 (ids-dump-range "IDS-Daikanwa-04.txt" filename
249 #'ids-dump-insert-daikanwa 07411 11529))
252 (defun ids-dump-daikanwa-05 (filename)
253 (interactive "Fdump IDS-Daikanwa-05 : ")
254 (ids-dump-range "IDS-Daikanwa-05.txt" filename
255 #'ids-dump-insert-daikanwa 11530 14414))
258 (defun ids-dump-daikanwa-06 (filename)
259 (interactive "Fdump IDS-Daikanwa-06 : ")
260 (ids-dump-range "IDS-Daikanwa-06.txt" filename
261 #'ids-dump-insert-daikanwa 14415 17574))
264 (defun ids-dump-daikanwa-07 (filename)
265 (interactive "Fdump IDS-Daikanwa-07 : ")
266 (ids-dump-range "IDS-Daikanwa-07.txt" filename
267 #'ids-dump-insert-daikanwa 17575 22677))
270 (defun ids-dump-daikanwa-08 (filename)
271 (interactive "Fdump IDS-Daikanwa-08 : ")
272 (ids-dump-range "IDS-Daikanwa-08.txt" filename
273 #'ids-dump-insert-daikanwa 22678 28107))
276 (defun ids-dump-daikanwa-09 (filename)
277 (interactive "Fdump IDS-Daikanwa-09 : ")
278 (ids-dump-range "IDS-Daikanwa-09.txt" filename
279 #'ids-dump-insert-daikanwa 28108 32803))
282 (defun ids-dump-daikanwa-10 (filename)
283 (interactive "Fdump IDS-Daikanwa-10 : ")
284 (ids-dump-range "IDS-Daikanwa-10.txt" filename
285 #'ids-dump-insert-daikanwa 32804 38699))
288 (defun ids-dump-daikanwa-11 (filename)
289 (interactive "Fdump IDS-Daikanwa-11 : ")
290 (ids-dump-range "IDS-Daikanwa-11.txt" filename
291 #'ids-dump-insert-daikanwa 38700 42209))
294 (defun ids-dump-daikanwa-12 (filename)
295 (interactive "Fdump IDS-Daikanwa-12 : ")
296 (ids-dump-range "IDS-Daikanwa-12.txt" filename
297 #'ids-dump-insert-daikanwa 42210 48902))
300 (defun ids-dump-daikanwa-index (filename)
301 (interactive "Fdump IDS-Daikanwa-dx : ")
302 (ids-dump-range "IDS-Daikanwa-dx.txt" filename
303 #'ids-dump-insert-daikanwa 48903 49964))
306 (defun ids-dump-daikanwa-hokan (filename)
307 (interactive "Fdump IDS-Daikanwa-ho : ")
308 (ids-dump-range "IDS-Daikanwa-ho.txt" filename
309 #'ids-dump-insert-daikanwa-hokan))
312 (defun ids-dump-cbeta (filename)
313 (interactive "Fdump IDS-CBETA : ")
314 (ids-dump-range "IDS-CBETA.txt" filename
315 #'ids-dump-insert-ccs-ranges
316 'ideograph-cbeta "CB%05d\t%c\t%s\n"
320 (defun ids-dump-jis-x0208-1990 (filename)
321 (interactive "Fdump IDS-JIS-X0208-1990 : ")
322 (ids-dump-range "IDS-JIS-X0208-1990.txt" filename
323 #'ids-dump-insert-jis-x0208-1990))
331 ;;; ids-dump.el ends here