1 ;;; ids-dump.el --- Dump utility of IDS-* files
3 ;; Copyright (C) 2002,2003 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-94x94-ccs-ranges (ccs line-spec &rest ranges)
56 (let (range code max-code l)
58 (setq range (car ranges))
60 (setq code (car range)
62 (while (<= code max-code)
63 (setq l (logand code 255))
64 (if (and (<= #x21 l)(<= l #x7E))
65 (ids-dump-insert-line ccs line-spec code))
66 (setq code (1+ code))))
68 (ids-dump-insert-line ccs line-spec range))
69 (t (error 'wrong-type-argument range)))
70 (setq ranges (cdr ranges)))))
72 (defun ids-dump-insert-daikanwa (start end)
78 (when (= (length val) 2)
81 (put-alist (nth 1 val)
83 (cdr (assq (car val) mdh-alist)))))
87 (when (setq chr (decode-char 'ideograph-daikanwa i))
89 (format "M-%05d \t%c\t%s\n"
90 i (decode-builtin-char 'ideograph-daikanwa i)
92 (get-char-attribute chr 'ideographic-structure))
94 (when (setq sal (assq i mdh-alist))
96 (when (setq chr (assq 1 sal))
99 (format "M-%05d'\t%c\t%s\n"
102 (get-char-attribute chr 'ideographic-structure))
104 (when (setq chr (assq 2 sal))
107 (format "M-%05d\"\t%c\t%s\n"
110 (get-char-attribute chr 'ideographic-structure)))))
114 (defun ids-dump-insert-daikanwa-hokan ()
118 (when (and (eq (car val) 'ho)
119 (null (nthcdr 2 val)))
120 (setq sal (cons (cons (nth 1 val) key) sal)))
123 (setq sal (sort sal (lambda (a b) (< (car a)(car b)))))
125 (setq chr (cdr cell))
127 (format "MH-%04d \t%c\t%s\n"
131 (get-char-attribute chr 'ideographic-structure)))))))
133 (defun ids-dump-insert-jis-x0208-1990 ()
141 (setq chr (make-char 'japanese-jisx0208-1990 h l))
143 (format "J90-%02X%02X\t%c\t%s\n"
145 (decode-builtin-char 'japanese-jisx0208-1990
146 (logior (lsh h 8) l))
148 (get-char-attribute chr 'ideographic-structure))
150 (setq cell (1+ cell)))
156 (setq chr (make-char 'japanese-jisx0208-1990 h l))
158 (format "J90-%02X%02X\t%c\t%s\n"
160 (decode-builtin-char 'japanese-jisx0208-1990
161 (logior (lsh h 8) l))
163 (get-char-attribute chr 'ideographic-structure))
165 (setq cell (1+ cell)))))
167 (defun ids-dump-insert-big5 (ccs prefix)
169 l code chr structure)
173 (setq chr (make-char ccs h l))
175 (when (setq structure
176 (get-char-attribute chr 'ideographic-structure))
178 (format "%s%02X%02X\t%c\t%s\n"
180 (decode-builtin-char ccs
181 (logior (lsh h 8) l))
183 (get-char-attribute chr 'ideographic-structure))
188 (setq chr (make-char ccs h l))
190 (when (setq structure
191 (get-char-attribute chr 'ideographic-structure))
193 (format "%s%02X%02X\t%c\t%s\n"
195 (decode-builtin-char ccs
196 (logior (lsh h 8) l))
198 (get-char-attribute chr 'ideographic-structure))
203 (defun ids-dump-range (file path func &rest args)
205 (let* ((coding-system-for-write 'utf-8-mcs-er))
206 (if (file-directory-p path)
207 (setq path (expand-file-name file path)))
208 (insert ";; -*- coding: utf-8-mcs-er -*-\n")
210 (write-region (point-min)(point-max) path))))
213 (defun ids-dump-ucs-basic (filename)
214 (interactive "Fdump IDS-UCS-Basic : ")
215 (ids-dump-range "IDS-UCS-Basic.txt" filename
216 #'ids-dump-insert-ccs-ranges 'ucs "U+%04X\t%c\t%s\n"
220 (defun ids-dump-ucs-ext-a (filename)
221 (interactive "Fdump IDS-UCS-Ext-A : ")
222 (ids-dump-range "IDS-UCS-Ext-A.txt" filename
223 #'ids-dump-insert-ccs-ranges 'ucs "U+%04X\t%c\t%s\n"
224 '(#x3400 . #x4DB5) #xFA1F #xFA23))
227 (defun ids-dump-ucs-compat (filename)
228 (interactive "Fdump IDS-UCS-Compat : ")
229 (ids-dump-range "IDS-UCS-Compat.txt" filename
230 #'ids-dump-insert-ccs-ranges 'ucs "U+%04X\t%c\t%s\n"
231 '(#xF900 . #xFA1E) '(#xFA20 . #xFA22) '(#xFA24 . #xFA2D)))
234 (defun ids-dump-ucs-ext-b-1 (filename)
235 (interactive "Fdump IDS-UCS-Ext-B-1 : ")
236 (ids-dump-range "IDS-UCS-Ext-B-1.txt" filename
237 #'ids-dump-insert-ccs-ranges 'ucs "U-%08X\t%c\t%s\n"
238 '(#x20000 . #x21FFF)))
241 (defun ids-dump-ucs-ext-b-2 (filename)
242 (interactive "Fdump IDS-UCS-Ext-B-2 : ")
243 (ids-dump-range "IDS-UCS-Ext-B-2.txt" filename
244 #'ids-dump-insert-ccs-ranges 'ucs "U-%08X\t%c\t%s\n"
245 '(#x22000 . #x23FFF)))
248 (defun ids-dump-ucs-ext-b-3 (filename)
249 (interactive "Fdump IDS-UCS-Ext-B-3 : ")
250 (ids-dump-range "IDS-UCS-Ext-B-3.txt" filename
251 #'ids-dump-insert-ccs-ranges 'ucs "U-%08X\t%c\t%s\n"
252 '(#x24000 . #x25FFF)))
255 (defun ids-dump-ucs-ext-b-4 (filename)
256 (interactive "Fdump IDS-UCS-Ext-B-4 : ")
257 (ids-dump-range "IDS-UCS-Ext-B-4.txt" filename
258 #'ids-dump-insert-ccs-ranges 'ucs "U-%08X\t%c\t%s\n"
259 '(#x26000 . #x27FFF)))
262 (defun ids-dump-ucs-ext-b-5 (filename)
263 (interactive "Fdump IDS-UCS-Ext-B-5 : ")
264 (ids-dump-range "IDS-UCS-Ext-B-5.txt" filename
265 #'ids-dump-insert-ccs-ranges 'ucs "U-%08X\t%c\t%s\n"
266 '(#x28000 . #x29FFF)))
269 (defun ids-dump-ucs-ext-b-6 (filename)
270 (interactive "Fdump IDS-UCS-Ext-B-6 : ")
271 (ids-dump-range "IDS-UCS-Ext-B-6.txt" filename
272 #'ids-dump-insert-ccs-ranges 'ucs "U-%08X\t%c\t%s\n"
273 '(#x2A000 . #x2A6D6)))
276 (defun ids-dump-ucs-compat-supplement (filename)
277 (interactive "Fdump IDS-UCS-Compat-Supplement : ")
278 (ids-dump-range "IDS-UCS-Compat-Supplement.txt" filename
279 #'ids-dump-insert-ccs-ranges 'ucs "U-%08X\t%c\t%s\n"
280 '(#x2F800 . #x2FA1D)))
283 (defun ids-dump-cns11643-1 (filename)
284 (interactive "Fdump IDS-CNS-1 : ")
285 (ids-dump-range "IDS-CNS-1.txt" filename
286 #'ids-dump-insert-94x94-ccs-ranges
287 'chinese-cns11643-1 "C1-%04X\t%c\t%s\n"
291 (defun ids-dump-cns11643-2 (filename)
292 (interactive "Fdump IDS-CNS-2 : ")
293 (ids-dump-range "IDS-CNS-2.txt" filename
294 #'ids-dump-insert-94x94-ccs-ranges
295 'chinese-cns11643-2 "C2-%04X\t%c\t%s\n"
299 (defun ids-dump-cns11643-3 (filename)
300 (interactive "Fdump IDS-CNS-3 : ")
301 (ids-dump-range "IDS-CNS-3.txt" filename
302 #'ids-dump-insert-94x94-ccs-ranges
303 'chinese-cns11643-3 "C3-%04X\t%c\t%s\n"
307 (defun ids-dump-daikanwa-01 (filename)
308 (interactive "Fdump IDS-Daikanwa-01 : ")
309 (ids-dump-range "IDS-Daikanwa-01.txt" filename
310 #'ids-dump-insert-daikanwa 00001 01449))
313 (defun ids-dump-daikanwa-02 (filename)
314 (interactive "Fdump IDS-Daikanwa-02 : ")
315 (ids-dump-range "IDS-Daikanwa-02.txt" filename
316 #'ids-dump-insert-daikanwa 01450 04674))
319 (defun ids-dump-daikanwa-03 (filename)
320 (interactive "Fdump IDS-Daikanwa-03 : ")
321 (ids-dump-range "IDS-Daikanwa-03.txt" filename
322 #'ids-dump-insert-daikanwa 04675 07410))
325 (defun ids-dump-daikanwa-04 (filename)
326 (interactive "Fdump IDS-Daikanwa-04 : ")
327 (ids-dump-range "IDS-Daikanwa-04.txt" filename
328 #'ids-dump-insert-daikanwa 07411 11529))
331 (defun ids-dump-daikanwa-05 (filename)
332 (interactive "Fdump IDS-Daikanwa-05 : ")
333 (ids-dump-range "IDS-Daikanwa-05.txt" filename
334 #'ids-dump-insert-daikanwa 11530 14414))
337 (defun ids-dump-daikanwa-06 (filename)
338 (interactive "Fdump IDS-Daikanwa-06 : ")
339 (ids-dump-range "IDS-Daikanwa-06.txt" filename
340 #'ids-dump-insert-daikanwa 14415 17574))
343 (defun ids-dump-daikanwa-07 (filename)
344 (interactive "Fdump IDS-Daikanwa-07 : ")
345 (ids-dump-range "IDS-Daikanwa-07.txt" filename
346 #'ids-dump-insert-daikanwa 17575 22677))
349 (defun ids-dump-daikanwa-08 (filename)
350 (interactive "Fdump IDS-Daikanwa-08 : ")
351 (ids-dump-range "IDS-Daikanwa-08.txt" filename
352 #'ids-dump-insert-daikanwa 22678 28107))
355 (defun ids-dump-daikanwa-09 (filename)
356 (interactive "Fdump IDS-Daikanwa-09 : ")
357 (ids-dump-range "IDS-Daikanwa-09.txt" filename
358 #'ids-dump-insert-daikanwa 28108 32803))
361 (defun ids-dump-daikanwa-10 (filename)
362 (interactive "Fdump IDS-Daikanwa-10 : ")
363 (ids-dump-range "IDS-Daikanwa-10.txt" filename
364 #'ids-dump-insert-daikanwa 32804 38699))
367 (defun ids-dump-daikanwa-11 (filename)
368 (interactive "Fdump IDS-Daikanwa-11 : ")
369 (ids-dump-range "IDS-Daikanwa-11.txt" filename
370 #'ids-dump-insert-daikanwa 38700 42209))
373 (defun ids-dump-daikanwa-12 (filename)
374 (interactive "Fdump IDS-Daikanwa-12 : ")
375 (ids-dump-range "IDS-Daikanwa-12.txt" filename
376 #'ids-dump-insert-daikanwa 42210 48902))
379 (defun ids-dump-daikanwa-index (filename)
380 (interactive "Fdump IDS-Daikanwa-dx : ")
381 (ids-dump-range "IDS-Daikanwa-dx.txt" filename
382 #'ids-dump-insert-daikanwa 48903 49964))
385 (defun ids-dump-daikanwa-hokan (filename)
386 (interactive "Fdump IDS-Daikanwa-ho : ")
387 (ids-dump-range "IDS-Daikanwa-ho.txt" filename
388 #'ids-dump-insert-daikanwa-hokan))
391 (defun ids-dump-cbeta (filename)
392 (interactive "Fdump IDS-CBETA : ")
393 (ids-dump-range "IDS-CBETA.txt" filename
394 #'ids-dump-insert-ccs-ranges
395 'ideograph-cbeta "CB%05d\t%c\t%s\n"
399 (defun ids-dump-jis-x0208-1990 (filename)
400 (interactive "Fdump IDS-JIS-X0208-1990 : ")
401 (ids-dump-range "IDS-JIS-X0208-1990.txt" filename
402 #'ids-dump-insert-jis-x0208-1990))
405 (defun ids-dump-big5-cdp (filename)
406 (interactive "Fdump IDS-CDP : ")
407 (ids-dump-range "IDS-CDP.txt" filename
408 #'ids-dump-insert-big5
417 ;;; ids-dump.el ends here