1 ;;; char-db-util.el --- Character Database utility
3 ;; Copyright (C) 1998,1999,2000,2001,2002,2003,2004 MORIOKA Tomohiko.
5 ;; Author: MORIOKA Tomohiko <tomo@kanji.zinbun.kyoto-u.ac.jp>
6 ;; Keywords: CHISE, Character Database, ISO/IEC 10646, Unicode, UCS-4, MULE.
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.
29 (defconst unidata-normative-category-alist
30 '(("Lu" letter uppercase)
31 ("Ll" letter lowercase)
32 ("Lt" letter titlecase)
33 ("Mn" mark non-spacing)
34 ("Mc" mark spacing-combining)
36 ("Nd" number decimal-digit)
39 ("Zs" separator space)
41 ("Zp" separator paragraph)
44 ("Cs" other surrogate)
45 ("Co" other private-use)
46 ("Cn" other not-assigned)))
48 (defconst unidata-informative-category-alist
49 '(("Lm" letter modifier)
51 ("Pc" punctuation connector)
52 ("Pd" punctuation dash)
53 ("Ps" punctuation open)
54 ("Pe" punctuation close)
55 ("Pi" punctuation initial-quote)
56 ("Pf" punctuation final-quote)
57 ("Po" punctuation other)
59 ("Sc" symbol currency)
60 ("Sk" symbol modifier)
64 (defconst ideographic-radicals
65 (let ((v (make-vector 215 nil))
68 (aset v i (decode-char '=ucs (+ #x2EFF i)))
72 (defvar char-db-file-coding-system 'utf-8-mcs-er)
74 (defvar char-db-feature-domains
75 '(ucs daikanwa cns gt jis jis/alt jis/a jis/b
76 jis-x0213 misc unknown))
78 (defvar char-db-ignored-attributes nil)
80 (defun char-attribute-name< (ka kb)
82 ((eq '->denotational kb)
84 ((eq '->subsumptive kb)
85 (not (eq '->denotational ka)))
86 ((eq '->denotational ka)
88 ((eq '->subsumptive ka)
92 (if (<= (charset-id ka) 0)
93 (if (<= (charset-id kb) 0)
95 ((= (charset-dimension ka)
96 (charset-dimension kb))
97 (> (charset-id ka)(charset-id kb)))
99 (> (charset-dimension ka)
100 (charset-dimension kb))
103 (if (<= (charset-id kb) 0)
105 (< (charset-id ka)(charset-id kb))))
111 (string< (symbol-name ka)
117 (defvar char-db-coded-charset-priority-list
132 japanese-jisx0208-1978
173 (defun char-db-make-char-spec (char)
175 (cond ((characterp char)
176 (cond ((and (setq ret (encode-char char '=ucs 'defined-only))
177 (not (and (<= #xE000 ret)(<= ret #xF8FF))))
178 (setq char-spec (list (cons '=ucs ret)))
179 (cond ((setq ret (get-char-attribute char 'name))
180 (setq char-spec (cons (cons 'name ret) char-spec))
182 ((setq ret (get-char-attribute char 'name*))
183 (setq char-spec (cons (cons 'name* ret) char-spec))
188 (let ((rest char-db-coded-charset-priority-list)
191 (setq ccs (charset-name
192 (find-charset (car rest))))
194 (encode-char char ccs
196 (throw 'tag (cons ccs ret)))
197 (setq rest (cdr rest))))))
198 (setq char-spec (list ret))
199 (dolist (ccs (delq (car ret) (charset-list)))
200 (if (and (or (charset-iso-final-char ccs)
206 (setq ret (encode-char char ccs 'defined-only)))
207 (setq char-spec (cons (cons ccs ret) char-spec))))
209 (setq char-spec (split-char char)))
210 (cond ((setq ret (get-char-attribute char 'name))
211 (setq char-spec (cons (cons 'name ret) char-spec))
213 ((setq ret (get-char-attribute char 'name*))
214 (setq char-spec (cons (cons 'name* ret) char-spec))
221 (defun char-db-insert-char-spec (char &optional readable column
224 (setq column (current-column)))
225 (let (char-spec temp-char)
226 (setq char-spec (char-db-make-char-spec char))
227 (unless (or (characterp char) ; char
229 (setq char (find-char char-spec))
231 ;; define temporary character
232 ;; Current implementation is dirty.
233 (setq temp-char (define-char (cons '(ideograph-daikanwa . 0)
235 (remove-char-attribute temp-char 'ideograph-daikanwa)
236 (setq char temp-char))
237 (insert-char-attributes char
239 (union (mapcar #'car char-spec)
242 ;; undefine temporary character
243 ;; Current implementation is dirty.
244 (setq char-spec (char-attribute-alist temp-char))
246 (remove-char-attribute temp-char (car (car char-spec)))
247 (setq char-spec (cdr char-spec))))))
249 (defun char-db-insert-alist (alist &optional readable column)
251 (setq column (current-column)))
253 (concat "\n" (make-string (1+ column) ?\ )))
257 lbs cell rest separator)
260 (setq name (car (car alist))
261 value (cdr (car alist)))
262 (cond ((eq name 'char)
264 (if (setq ret (condition-case nil
272 (setq key (car (car value)))
273 ;; (if (find-charset key)
274 ;; (setq cal (cons key cal))
275 (setq al (cons key al))
277 (setq value (cdr value)))
278 (insert-char-attributes ret
282 (insert (prin1-to-string value)))
284 (insert line-breaking))
286 (insert (format "(%-18s " name))
287 (setq lbs (concat "\n" (make-string (current-column) ?\ )))
289 (setq cell (car value))
290 (if (and (consp cell)
292 (setq ret (condition-case nil
302 (setq key (car (car rest)))
303 ;; (if (find-charset key)
304 ;; (setq cal (cons key cal))
305 (setq al (cons key al))
307 (setq rest (cdr rest)))
310 (insert-char-attributes ret
314 (setq separator lbs))
317 (insert (prin1-to-string cell))
318 (setq separator " "))
319 (setq value (cdr value)))
321 (insert line-breaking))
323 (insert (format "(%-18s . %S)%s"
326 (setq alist (cdr alist))))
329 (defun char-db-insert-char-reference (plist &optional readable column)
331 (setq column (current-column)))
333 (concat "\n" (make-string (1+ column) ?\ )))
338 (setq name (pop plist))
339 (setq value (pop plist))
340 (cond ((eq name :char)
343 (cond ((numberp value)
344 (setq value (decode-char '=ucs value)))
346 ;; (setq value (or (find-char value)
349 (char-db-insert-char-spec value readable)
350 (insert line-breaking)
353 (insert (format "%s%s\t%d ; %c%s"
356 (aref ideographic-radicals value)
360 (insert (format "%s%s\t%S" separator name value))
361 (setq separator line-breaking)))
365 (defun char-db-decode-isolated-char (ccs code-point)
368 (cond ((eq ccs 'arabic-iso8859-6)
369 (decode-char ccs code-point))
370 ((and (memq ccs '(=gt-pj-1
381 (setq ret (decode-char ccs code-point))
382 (setq ret (encode-char ret '=gt 'defined-only)))
383 (decode-builtin-char '=gt ret))
385 (decode-builtin-char ccs code-point))))
386 (cond ((and (<= 0 (char-int ret))
387 (<= (char-int ret) #x1F))
388 (decode-char '=ucs (+ #x2400 (char-int ret))))
389 ((= (char-int ret) #x7F)
393 (defvar char-db-convert-obsolete-format t)
395 (defun insert-char-attributes (char &optional readable attributes column)
397 (setq column (current-column)))
398 (let (name value has-long-ccs-name rest
401 (concat "\n" (make-string (1+ column) ?\ )))
402 lbs cell separator ret
405 sources required-features
410 (if (consp attributes)
412 (dolist (name attributes)
413 (unless (memq name char-db-ignored-attributes)
414 (if (find-charset name)
418 (dolist (name (char-attribute-list))
419 (unless (memq name char-db-ignored-attributes)
420 (if (find-charset name)
424 #'char-attribute-name<)))
426 (when (and (memq 'name attributes)
427 (setq value (get-char-attribute char 'name)))
429 (if (> (+ (current-column) (length value)) 48)
432 value line-breaking))
433 (setq attributes (delq 'name attributes))
435 (when (and (memq 'name* attributes)
436 (setq value (get-char-attribute char 'name*)))
438 (if (> (+ (current-column) (length value)) 48)
441 value line-breaking))
442 (setq attributes (delq 'name* attributes))
444 (when (and (memq 'script attributes)
445 (setq value (get-char-attribute char 'script)))
446 (insert (format "(script\t\t%s)%s"
447 (mapconcat (function prin1-to-string)
450 (setq attributes (delq 'script attributes))
452 ;; (when (and (memq '<-denotational attributes)
453 ;; (setq value (get-char-attribute char '<-denotational))
454 ;; (null (cdr value))
455 ;; (setq value (encode-char (car value) 'ucs 'defined-only)))
456 ;; (insert (format "(%-18s . #x%04X)\t; %c%s"
457 ;; '=>ucs value (decode-char 'ucs value)
459 ;; (setq attributes (delq '<-denotational attributes)))
460 (dolist (name '(=>ucs =>ucs*))
461 (when (and (memq name attributes)
462 (setq value (get-char-attribute char name)))
463 (insert (format "(%-18s . #x%04X)\t; %c%s"
464 name value (decode-char '=ucs value)
466 (setq attributes (delq name attributes))))
467 (dolist (name '(=>ucs@gb =>ucs@cns =>ucs@jis =>ucs@ks =>ucs@big5))
468 (when (and (memq name attributes)
469 (setq value (get-char-attribute char name)))
470 (insert (format "(%-18s . #x%04X)\t; %c%s"
475 (symbol-name name) 2)))
478 (setq attributes (delq name attributes))
480 ;; (dolist (name '(=>ucs-gb =>ucs-cns =>ucs-jis =>ucs-ks =>ucs-big5))
481 ;; (when (and (memq name attributes)
482 ;; (setq value (get-char-attribute char name)))
483 ;; (insert (format "(%-18s . #x%04X)\t; %c%s"
486 ;; (substring (symbol-name name) 6)))
488 ;; (decode-char (intern
491 ;; (symbol-name name) 6)))
494 ;; (setq attributes (delq name attributes))))
495 ;; (when (and (memq '->ucs attributes)
496 ;; (setq value (get-char-attribute char '->ucs)))
497 ;; (insert (format (if char-db-convert-obsolete-format
498 ;; "(=>ucs\t\t. #x%04X)\t; %c%s"
499 ;; "(->ucs\t\t. #x%04X)\t; %c%s")
500 ;; value (decode-char '=ucs value)
502 ;; (setq attributes (delq '->ucs attributes))
504 (dolist (name '(=>daikanwa))
505 (when (and (memq name attributes)
506 (setq value (get-char-attribute char name)))
509 (format "(%-18s . %05d)\t; %c%s"
510 name value (decode-char '=daikanwa value)
512 (format "(%-18s %s)\t; %c%s"
514 (mapconcat (function prin1-to-string)
516 (char-representative-of-daikanwa char)
518 (setq attributes (delq name attributes))))
519 (when (and (memq 'general-category attributes)
520 (setq value (get-char-attribute char 'general-category)))
522 "(general-category\t%s) ; %s%s"
523 (mapconcat (lambda (cell)
526 (cond ((rassoc value unidata-normative-category-alist)
527 "Normative Category")
528 ((rassoc value unidata-informative-category-alist)
529 "Informative Category")
533 (setq attributes (delq 'general-category attributes))
535 (when (and (memq 'bidi-category attributes)
536 (setq value (get-char-attribute char 'bidi-category)))
537 (insert (format "(bidi-category\t. %S)%s"
540 (setq attributes (delq 'bidi-category attributes))
542 (unless (or (not (memq 'mirrored attributes))
543 (eq (setq value (get-char-attribute char 'mirrored 'empty))
545 (insert (format "(mirrored\t\t. %S)%s"
548 (setq attributes (delq 'mirrored attributes))
551 ((and (memq 'decimal-digit-value attributes)
552 (setq value (get-char-attribute char 'decimal-digit-value)))
553 (insert (format "(decimal-digit-value . %S)%s"
556 (setq attributes (delq 'decimal-digit-value attributes))
557 (when (and (memq 'digit-value attributes)
558 (setq value (get-char-attribute char 'digit-value)))
559 (insert (format "(digit-value\t . %S)%s"
562 (setq attributes (delq 'digit-value attributes))
564 (when (and (memq 'numeric-value attributes)
565 (setq value (get-char-attribute char 'numeric-value)))
566 (insert (format "(numeric-value\t . %S)%s"
569 (setq attributes (delq 'numeric-value attributes))
573 (when (and (memq 'digit-value attributes)
574 (setq value (get-char-attribute char 'digit-value)))
575 (insert (format "(digit-value\t. %S)%s"
578 (setq attributes (delq 'digit-value attributes))
580 (when (and (memq 'numeric-value attributes)
581 (setq value (get-char-attribute char 'numeric-value)))
582 (insert (format "(numeric-value\t. %S)%s"
585 (setq attributes (delq 'numeric-value attributes))
587 (when (and (memq 'iso-10646-comment attributes)
588 (setq value (get-char-attribute char 'iso-10646-comment)))
589 (insert (format "(iso-10646-comment\t. %S)%s"
592 (setq attributes (delq 'iso-10646-comment attributes))
594 (when (and (memq 'morohashi-daikanwa attributes)
595 (setq value (get-char-attribute char 'morohashi-daikanwa)))
596 (insert (format "(morohashi-daikanwa\t%s)%s"
597 (mapconcat (function prin1-to-string) value " ")
599 (setq attributes (delq 'morohashi-daikanwa attributes))
603 (when (and (memq 'ideographic-radical attributes)
604 (setq value (get-char-attribute char 'ideographic-radical)))
606 (insert (format "(ideographic-radical . %S)\t; %c%s"
608 (aref ideographic-radicals radical)
610 (setq attributes (delq 'ideographic-radical attributes))
613 (dolist (domain char-db-feature-domains)
614 (setq key (intern (format "%s@%s" 'ideographic-radical domain)))
615 (when (and (memq key attributes)
616 (setq value (get-char-attribute char key)))
618 (insert (format "(%s . %S)\t; %c%s"
621 (aref ideographic-radicals radical)
623 (setq attributes (delq key attributes))
625 (setq key (intern (format "%s@%s" 'ideographic-strokes domain)))
626 (when (and (memq key attributes)
627 (setq value (get-char-attribute char key)))
629 (insert (format "(%s . %S)%s"
633 (setq attributes (delq key attributes))
635 (setq key (intern (format "%s@%s" 'total-strokes domain)))
636 (when (and (memq key attributes)
637 (setq value (get-char-attribute char key)))
638 (insert (format "(%s . %S)%s"
642 (setq attributes (delq key attributes))
644 (dolist (feature '(ideographic-radical
647 (setq key (intern (format "%s@%s*sources" feature domain)))
648 (when (and (memq key attributes)
649 (setq value (get-char-attribute char key)))
650 (insert (format "(%s%s" key line-breaking))
652 (insert (format " %s" cell)))
654 (insert line-breaking)
655 (setq attributes (delq key attributes))
658 (when (and (memq 'ideographic-strokes attributes)
659 (setq value (get-char-attribute char 'ideographic-strokes)))
661 (insert (format "(ideographic-strokes . %S)%s"
664 (setq attributes (delq 'ideographic-strokes attributes))
666 (when (and (memq 'kangxi-radical attributes)
667 (setq value (get-char-attribute char 'kangxi-radical)))
668 (unless (eq value radical)
669 (insert (format "(kangxi-radical\t . %S)\t; %c%s"
671 (aref ideographic-radicals value)
674 (setq radical value)))
675 (setq attributes (delq 'kangxi-radical attributes))
677 (when (and (memq 'kangxi-strokes attributes)
678 (setq value (get-char-attribute char 'kangxi-strokes)))
679 (unless (eq value strokes)
680 (insert (format "(kangxi-strokes\t . %S)%s"
684 (setq strokes value)))
685 (setq attributes (delq 'kangxi-strokes attributes))
687 (when (and (memq 'japanese-radical attributes)
688 (setq value (get-char-attribute char 'japanese-radical)))
689 (unless (eq value radical)
690 (insert (format "(japanese-radical\t . %S)\t; %c%s"
692 (aref ideographic-radicals value)
695 (setq radical value)))
696 (setq attributes (delq 'japanese-radical attributes))
698 (when (and (memq 'japanese-strokes attributes)
699 (setq value (get-char-attribute char 'japanese-strokes)))
700 (unless (eq value strokes)
701 (insert (format "(japanese-strokes\t . %S)%s"
705 (setq strokes value)))
706 (setq attributes (delq 'japanese-strokes attributes))
708 (when (and (memq 'cns-radical attributes)
709 (setq value (get-char-attribute char 'cns-radical)))
710 (insert (format "(cns-radical\t . %S)\t; %c%s"
712 (aref ideographic-radicals value)
714 (setq attributes (delq 'cns-radical attributes))
716 (when (and (memq 'cns-strokes attributes)
717 (setq value (get-char-attribute char 'cns-strokes)))
718 (unless (eq value strokes)
719 (insert (format "(cns-strokes\t . %S)%s"
723 (setq strokes value)))
724 (setq attributes (delq 'cns-strokes attributes))
726 (when (and (memq 'shinjigen-1-radical attributes)
727 (setq value (get-char-attribute char 'shinjigen-1-radical)))
728 (unless (eq value radical)
729 (insert (format "(shinjigen-1-radical . %S)\t; %c%s"
731 (aref ideographic-radicals value)
734 (setq radical value)))
735 (setq attributes (delq 'shinjigen-1-radical attributes))
737 (when (and (memq 'ideographic- attributes)
738 (setq value (get-char-attribute char 'ideographic-)))
739 (insert "(ideographic- ")
740 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
743 (setq cell (car value))
745 (setq cell (decode-char '=ucs cell)))
746 (cond ((characterp cell)
750 (insert (format "%S" cell))
751 (char-db-insert-char-spec cell readable))
752 (setq separator lbs))
756 (if (consp (car cell))
757 (char-db-insert-char-spec cell readable)
758 (char-db-insert-char-reference cell readable))
759 (setq separator lbs))
763 (insert (prin1-to-string cell))
764 (setq separator " ")))
765 (setq value (cdr value)))
767 (insert line-breaking)
768 (setq attributes (delq 'ideographic- attributes)))
769 (when (and (memq 'total-strokes attributes)
770 (setq value (get-char-attribute char 'total-strokes)))
771 (insert (format "(total-strokes . %S)%s"
774 (setq attributes (delq 'total-strokes attributes))
776 (when (and (memq '->ideograph attributes)
777 (setq value (get-char-attribute char '->ideograph)))
778 (insert (format "(->ideograph\t%s)%s"
779 (mapconcat (lambda (code)
780 (cond ((symbolp code)
783 (format "#x%04X" code))
786 line-breaking code))))
789 (setq attributes (delq '->ideograph attributes))
791 (when (and (memq '->decomposition attributes)
792 (setq value (get-char-attribute char '->decomposition)))
793 (insert (format "(->decomposition\t%s)%s"
794 (mapconcat (lambda (code)
795 (cond ((symbolp code)
804 (format "#x%04X" code))
806 (format "%s%S" line-breaking code))))
809 (setq attributes (delq '->decomposition attributes))
811 (if (equal (get-char-attribute char '->titlecase)
812 (get-char-attribute char '->uppercase))
813 (setq attributes (delq '->titlecase attributes)))
814 (when (and (memq '->mojikyo attributes)
815 (setq value (get-char-attribute char '->mojikyo)))
816 (insert (format "(->mojikyo\t\t. %06d)\t; %c%s"
817 value (decode-char 'mojikyo value)
819 (setq attributes (delq '->mojikyo attributes))
821 (when (and (memq 'hanyu-dazidian-vol attributes)
822 (setq value (get-char-attribute char 'hanyu-dazidian-vol)))
823 (insert (format "(hanyu-dazidian-vol . %d)%s"
824 value line-breaking))
825 (setq attributes (delq 'hanyu-dazidian-vol attributes))
827 (when (and (memq 'hanyu-dazidian-page attributes)
828 (setq value (get-char-attribute char 'hanyu-dazidian-page)))
829 (insert (format "(hanyu-dazidian-page . %d)%s"
830 value line-breaking))
831 (setq attributes (delq 'hanyu-dazidian-page attributes))
833 (when (and (memq 'hanyu-dazidian-char attributes)
834 (setq value (get-char-attribute char 'hanyu-dazidian-char)))
835 (insert (format "(hanyu-dazidian-char . %d)%s"
836 value line-breaking))
837 (setq attributes (delq 'hanyu-dazidian-char attributes))
840 (dolist (ignored '(composition
841 ->denotational <-subsumptive ->ucs-unified
842 ->ideographic-component-forms
844 (setq attributes (delq ignored attributes))))
845 ;; (setq rest ccs-attributes)
848 ;; (setq value (get-char-attribute char (car rest)))
850 ;; (if (>= (length (symbol-name (car rest))) 19)
852 ;; (setq has-long-ccs-name t)
856 ;; (setq rest (cdr rest)))
858 (setq name (car attributes))
859 (if (setq value (get-char-attribute char name))
860 (cond ((setq ret (find-charset name))
861 (setq name (charset-name ret))
862 (if (and (not (memq name dest-ccss))
864 (setq value (get-char-attribute char name))
865 (setq dest-ccss (cons name dest-ccss))))
868 (cond ((memq name '(=daikanwa
869 =daikanwa-rev1 =daikanwa-rev2
871 (if has-long-ccs-name
872 "(%-26s . %05d)\t; %c%s"
873 "(%-18s . %05d)\t; %c%s"))
875 (if has-long-ccs-name
876 "(%-26s . %06d)\t; %c%s"
877 "(%-18s . %06d)\t; %c%s"))
878 ((>= (charset-dimension name) 2)
879 (if has-long-ccs-name
880 "(%-26s . #x%04X)\t; %c%s"
881 "(%-18s . #x%04X)\t; %c%s"))
883 (if has-long-ccs-name
884 "(%-26s . #x%02X)\t; %c%s"
885 "(%-18s . #x%02X)\t; %c%s")))
887 (if (= (charset-iso-graphic-plane name) 1)
889 (cond ((= (charset-dimension name) 1)
891 ((= (charset-dimension name) 2)
893 ((= (charset-dimension name) 3)
897 (char-db-decode-isolated-char name value)
900 ((string-match "^=>ucs@" (symbol-name name))
901 (insert (format "(%-18s . #x%04X)\t; %c%s"
902 name value (decode-char '=ucs value)
905 ((eq name 'jisx0208-1978/4X)
906 (insert (format "(%-18s . #x%04X)%s"
911 (or (eq name '<-identical)
912 (string-match "^->simplified" (symbol-name name))))
914 ((or (eq name 'ideographic-structure)
915 (eq name 'ideographic-)
916 (string-match "^\\(->\\|<-\\)" (symbol-name name)))
917 (insert (format "(%-18s%s " name line-breaking))
918 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
921 (setq cell (car value))
923 (setq cell (decode-char '=ucs cell)))
924 (cond ((eq name '->subsumptive)
927 (get-char-attribute cell atr))
928 char-db-ignored-attributes))
930 (encode-char cell ccs
935 (let ((char-db-ignored-attributes
937 char-db-ignored-attributes)))
938 (insert-char-attributes cell readable))
939 (setq separator lbs))
945 (intern (format "%s*sources" name))))
946 (setq required-features nil)
947 (dolist (source sources)
948 (setq required-features
952 (format "=%s" source))))
956 (when (string-match "@JP" (symbol-name name))
957 (setq required-features
958 (union required-features
969 (insert (format "%S" cell))
970 (char-db-insert-char-spec cell readable
973 (setq separator lbs))
977 (if (consp (car cell))
978 (char-db-insert-char-spec cell readable)
979 (char-db-insert-char-reference cell readable))
980 (setq separator lbs))
984 (insert (prin1-to-string cell))
985 (setq separator " ")))
986 (setq value (cdr value)))
988 (insert line-breaking))
989 ((memq name '(ideograph=
990 original-ideograph-of
994 ;; simplified-ideograph-of
996 ;; ideographic-different-form-of
998 (insert (format "(%-18s%s " name line-breaking))
999 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
1001 (while (consp value)
1002 (setq cell (car value))
1003 (if (and (consp cell)
1008 (char-db-insert-alist cell readable)
1009 (setq separator lbs))
1012 (insert (prin1-to-string cell))
1013 (setq separator " "))
1014 (setq value (cdr value)))
1016 (insert line-breaking))
1018 (insert (format "(%-18s " name))
1019 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
1021 (while (consp value)
1022 (setq cell (car value))
1023 (if (and (consp cell)
1025 (setq ret (condition-case nil
1033 (setq key (car (car rest)))
1034 (if (find-charset key)
1035 (setq cal (cons key cal))
1036 (setq al (cons key al)))
1037 (setq rest (cdr rest)))
1040 (insert-char-attributes ret
1043 (setq separator lbs))
1044 (setq ret (prin1-to-string cell))
1046 (if (< (+ (current-column)
1053 (setq separator " "))
1054 (setq value (cdr value)))
1056 (insert line-breaking))
1058 (insert (format "(%-18s . %S)%s"
1062 (setq attributes (cdr attributes)))
1063 ;; (while ccs-attributes
1064 ;; (setq name (charset-name (car ccs-attributes)))
1065 ;; (if (and (not (memq name dest-ccss))
1067 ;; (setq value (get-char-attribute char name))
1068 ;; (setq dest-ccss (cons name dest-ccss))))
1071 ;; (cond ((memq name '(=daikanwa
1072 ;; =daikanwa-rev1 =daikanwa-rev2
1073 ;; =gt =gt-k =cbeta))
1074 ;; (if has-long-ccs-name
1075 ;; "(%-26s . %05d)\t; %c%s"
1076 ;; "(%-18s . %05d)\t; %c%s"))
1077 ;; ((eq name 'mojikyo)
1078 ;; (if has-long-ccs-name
1079 ;; "(%-26s . %06d)\t; %c%s"
1080 ;; "(%-18s . %06d)\t; %c%s"))
1081 ;; ((>= (charset-dimension name) 2)
1082 ;; (if has-long-ccs-name
1083 ;; "(%-26s . #x%04X)\t; %c%s"
1084 ;; "(%-18s . #x%04X)\t; %c%s"))
1086 ;; (if has-long-ccs-name
1087 ;; "(%-26s . #x%02X)\t; %c%s"
1088 ;; "(%-18s . #x%02X)\t; %c%s")))
1090 ;; (if (= (charset-iso-graphic-plane name) 1)
1092 ;; (cond ((= (charset-dimension name) 1)
1094 ;; ((= (charset-dimension name) 2)
1096 ;; ((= (charset-dimension name) 3)
1100 ;; (char-db-decode-isolated-char name value)
1102 ;; (setq ccs-attributes (cdr ccs-attributes)))
1105 (defun insert-char-data (char &optional readable
1108 (narrow-to-region (point)(point))
1109 (insert "(define-char
1111 (insert-char-attributes char readable attributes)
1113 (goto-char (point-min))
1114 (while (re-search-forward "[ \t]+$" nil t)
1117 (goto-char (point-min))
1118 (while (re-search-forward "[ \t][ \t][ \t]*" nil t)
1119 (let ((column (current-column))
1120 (indent-tabs-mode t))
1121 (delete-region (match-beginning 0) (point))
1122 (indent-to column)))
1123 (goto-char (point-max))
1124 ;; (tabify (point-min)(point-max))
1127 (defun insert-char-data-with-variant (char &optional printable
1129 script excluded-script)
1130 (insert-char-data char printable)
1131 (let ((variants (or (char-variants char)
1132 (let ((ucs (get-char-attribute char '->ucs)))
1134 (delete char (char-variants (int-char ucs)))))))
1136 (setq variants (sort variants #'<))
1138 (setq variant (car variants))
1139 (if (and (or (null script)
1140 (null (setq vs (get-char-attribute variant 'script)))
1142 (or (null excluded-script)
1143 (null (setq vs (get-char-attribute variant 'script)))
1144 (not (memq excluded-script vs))))
1145 (or (and no-ucs-unified (get-char-attribute variant '=ucs))
1146 (insert-char-data variant printable)))
1147 (setq variants (cdr variants))
1150 (defun insert-char-range-data (min max &optional script excluded-script)
1153 (while (<= code max)
1154 (setq char (decode-char '=ucs code))
1155 (if (encode-char char '=ucs 'defined-only)
1156 (insert-char-data-with-variant char nil 'no-ucs-unified
1157 script excluded-script))
1158 (setq code (1+ code)))))
1160 (defun write-char-range-data-to-file (min max file
1161 &optional script excluded-script)
1162 (let ((coding-system-for-write char-db-file-coding-system))
1164 (insert (format ";; -*- coding: %s -*-\n"
1165 char-db-file-coding-system))
1166 (insert-char-range-data min max script excluded-script)
1167 (write-region (point-min)(point-max) file))))
1169 (defvar what-character-original-window-configuration)
1172 (defun what-char-definition (char)
1173 (interactive (list (char-after)))
1174 (let ((buf (get-buffer-create "*Character Description*"))
1175 (the-buf (current-buffer))
1176 (win-conf (current-window-configuration)))
1178 (make-local-variable 'what-character-original-window-configuration)
1179 (setq what-character-original-window-configuration win-conf)
1180 (setq buffer-read-only nil)
1184 (insert-char-data-with-variant char 'printable)
1185 (unless (char-attribute-alist char)
1186 (insert (format ";; = %c\n"
1187 (let* ((rest (split-char char))
1191 (setq code (logior (lsh code 8)
1193 (decode-char ccs code)))))
1194 ;; (char-db-update-comment)
1195 (set-buffer-modified-p nil)
1196 (view-mode the-buf (lambda (buf)
1197 (set-window-configuration
1198 what-character-original-window-configuration)
1200 (goto-char (point-min)))
1202 (set-window-configuration
1203 what-character-original-window-configuration)
1204 (signal (car err) (cdr err)))))))
1206 (provide 'char-db-util)
1208 ;;; char-db-util.el ends here