1 ;;; char-db-util.el --- Character Database utility -*- coding: utf-8-er; -*-
3 ;; Copyright (C) 1998,1999,2000,2001,2002,2003,2004,2005 MORIOKA Tomohiko.
5 ;; Author: MORIOKA Tomohiko <tomo@kanji.zinbun.kyoto-u.ac.jp>
6 ;; Keywords: CHISE, Character Database, ISO/IEC 10646, UCS, Unicode, 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 (defun ideographic-radical (number)
73 (aref ideographic-radicals number))
75 (defconst shuowen-radicals
76 [?一 ?上 ?示 ?三 ?王 ?玉 ?玨 ?气 ?士 ?丨 ?屮 ?艸 ?茻])
78 (defun shuowen-radical (number)
79 (aref shuowen-radicals (1- number)))
81 (defvar char-db-file-coding-system 'utf-8-mcs-er)
83 (defvar char-db-feature-domains
84 '(ucs daikanwa cns gt jis jis/alt jis/a jis/b
85 jis-x0212 jis-x0213 cdp shinjigen misc unknown))
87 (defvar char-db-ignored-attributes '(ideographic-products))
89 (defun char-attribute-name< (ka kb)
91 ((eq '->denotational kb)
93 ((eq '->subsumptive kb)
94 (not (eq '->denotational ka)))
95 ((eq '->denotational ka)
97 ((eq '->subsumptive ka)
100 (string-match "^->" (symbol-name ka)))
101 (cond ((and (symbolp kb)
102 (string-match "^->" (symbol-name kb)))
103 (string< (symbol-name ka)
108 (string-match "^->" (symbol-name kb)))
111 (if (find-charset kb)
112 (if (<= (charset-id ka) 1)
113 (if (<= (charset-id kb) 1)
115 ((= (charset-dimension ka)
116 (charset-dimension kb))
117 (> (charset-id ka)(charset-id kb)))
119 (> (charset-dimension ka)
120 (charset-dimension kb))
123 (if (<= (charset-id kb) 1)
125 (< (charset-id ka)(charset-id kb))))
131 (string< (symbol-name ka)
137 (defvar char-db-coded-charset-priority-list
198 (defun char-db-make-char-spec (char)
200 (cond ((characterp char)
201 (cond ((and (setq ret (encode-char char '=ucs 'defined-only))
202 (not (and (<= #xE000 ret)(<= ret #xF8FF))))
203 (setq char-spec (list (cons '=ucs ret)))
204 (cond ((setq ret (get-char-attribute char 'name))
205 (setq char-spec (cons (cons 'name ret) char-spec))
207 ((setq ret (get-char-attribute char 'name*))
208 (setq char-spec (cons (cons 'name* ret) char-spec))
213 (let ((rest char-db-coded-charset-priority-list)
216 (setq ccs (charset-name
217 (find-charset (car rest))))
219 (encode-char char ccs
221 (throw 'tag (cons ccs ret)))
222 (setq rest (cdr rest))))))
223 (setq char-spec (list ret))
224 (dolist (ccs (delq (car ret) (charset-list)))
225 (if (and (or (charset-iso-final-char ccs)
231 (setq ccs (charset-name ccs))
232 (null (assq ccs char-spec))
233 (setq ret (encode-char char ccs 'defined-only)))
234 (setq char-spec (cons (cons ccs ret) char-spec))))
236 (setq char-spec (split-char char)))
237 (cond ((setq ret (get-char-attribute char 'name))
238 (setq char-spec (cons (cons 'name ret) char-spec))
240 ((setq ret (get-char-attribute char 'name*))
241 (setq char-spec (cons (cons 'name* ret) char-spec))
248 (defun char-db-insert-char-spec (char &optional readable column
251 (setq column (current-column)))
252 (let (char-spec temp-char)
253 (setq char-spec (char-db-make-char-spec char))
254 (unless (or (characterp char) ; char
256 (setq char (find-char char-spec))
258 ;; define temporary character
259 ;; Current implementation is dirty.
260 (setq temp-char (define-char (cons '(ideograph-daikanwa . 0)
262 (remove-char-attribute temp-char 'ideograph-daikanwa)
263 (setq char temp-char))
264 (insert-char-attributes char
266 (union (mapcar #'car char-spec)
269 ;; undefine temporary character
270 ;; Current implementation is dirty.
271 (setq char-spec (char-attribute-alist temp-char))
273 (remove-char-attribute temp-char (car (car char-spec)))
274 (setq char-spec (cdr char-spec))))))
276 (defun char-db-insert-alist (alist &optional readable column)
278 (setq column (current-column)))
280 (concat "\n" (make-string (1+ column) ?\ )))
284 lbs cell rest separator)
287 (setq name (car (car alist))
288 value (cdr (car alist)))
289 (cond ((eq name 'char)
291 (if (setq ret (condition-case nil
299 (setq key (car (car value)))
300 ;; (if (find-charset key)
301 ;; (setq cal (cons key cal))
302 (setq al (cons key al))
304 (setq value (cdr value)))
305 (insert-char-attributes ret
309 (insert (prin1-to-string value)))
311 (insert line-breaking))
313 (insert (format "(%-18s " name))
314 (setq lbs (concat "\n" (make-string (current-column) ?\ )))
316 (setq cell (car value))
317 (if (and (consp cell)
319 (setq ret (condition-case nil
329 (setq key (car (car rest)))
330 ;; (if (find-charset key)
331 ;; (setq cal (cons key cal))
332 (setq al (cons key al))
334 (setq rest (cdr rest)))
337 (insert-char-attributes ret
341 (setq separator lbs))
344 (insert (prin1-to-string cell))
345 (setq separator " "))
346 (setq value (cdr value)))
348 (insert line-breaking))
350 (insert (format "(%-18s . %S)%s"
353 (setq alist (cdr alist))))
356 (defun char-db-insert-char-reference (plist &optional readable column)
358 (setq column (current-column)))
360 (concat "\n" (make-string (1+ column) ?\ )))
365 (setq name (pop plist))
366 (setq value (pop plist))
367 (cond ((eq name :char)
370 (cond ((numberp value)
371 (setq value (decode-char '=ucs value)))
373 ;; (setq value (or (find-char value)
376 (char-db-insert-char-spec value readable)
377 (insert line-breaking)
380 (insert (format "%s%s\t%d ; %c%s"
383 (ideographic-radical value)
387 (insert (format "%s%s\t%S" separator name value))
388 (setq separator line-breaking)))
392 (defun char-db-decode-isolated-char (ccs code-point)
395 (cond ((eq ccs 'arabic-iso8859-6)
396 (decode-char ccs code-point))
397 ((and (memq ccs '(=gt-pj-1
408 (setq ret (decode-char ccs code-point))
409 (setq ret (encode-char ret '=gt 'defined-only)))
410 (decode-builtin-char '=gt ret))
412 (decode-builtin-char ccs code-point))))
413 (cond ((and (<= 0 (char-int ret))
414 (<= (char-int ret) #x1F))
415 (decode-char '=ucs (+ #x2400 (char-int ret))))
416 ((= (char-int ret) #x7F)
420 (defvar char-db-convert-obsolete-format t)
422 (defun char-db-insert-ccs-feature (name value line-breaking)
425 (cond ((memq name '(=daikanwa
426 =daikanwa@rev1 =daikanwa@rev2
427 =gt =gt-k =cbeta =zinbun-oracle))
428 "(%-18s . %05d)\t; %c")
430 "(%-18s . %06d)\t; %c")
431 ((>= (charset-dimension name) 2)
432 "(%-18s . #x%04X)\t; %c")
434 "(%-18s . #x%02X)\t; %c"))
436 (if (= (charset-iso-graphic-plane name) 1)
438 (cond ((= (charset-dimension name) 1)
440 ((= (charset-dimension name) 2)
442 ((= (charset-dimension name) 3)
446 (char-db-decode-isolated-char name value)))
447 (if (and (= (charset-chars name) 94)
448 (= (charset-dimension name) 2))
449 (insert (format " [%02d-%02d]"
450 (- (lsh value -8) 32)
451 (- (logand value 255) 32))))
452 (insert line-breaking))
454 (defun char-db-insert-relation-feature (char name value line-breaking
456 (insert (format "(%-18s%s " name line-breaking))
457 (let ((lbs (concat "\n" (make-string (current-column) ?\ )))
458 separator cell sources required-features
461 (setq cell (car value))
463 (setq cell (decode-char '=ucs cell)))
465 ((eq name '->subsumptive)
466 (when (or (not (some (lambda (atr)
467 (get-char-attribute cell atr))
468 char-db-ignored-attributes))
470 (encode-char cell ccs 'defined-only))
474 (let ((char-db-ignored-attributes
476 char-db-ignored-attributes)))
477 (insert-char-attributes cell readable))
478 (setq separator lbs))
483 char (intern (format "%s*sources" name))))
484 (setq required-features nil)
485 (dolist (source sources)
487 ((memq source '(JP JP/Jouyou shinjigen-1))
488 (setq required-features
489 (union required-features
498 (setq required-features
499 (union required-features
504 ((find-charset (setq ret (intern (format "=%s" source))))
505 (setq required-features
506 (cons ret required-features)))
507 (t (setq required-features
508 (cons source required-features)))))
509 (cond ((string-match "@JP" (symbol-name name))
510 (setq required-features
511 (union required-features
519 ((string-match "@CN" (symbol-name name))
520 (setq required-features
521 (union required-features
528 (insert (format "%S" cell))
529 (char-db-insert-char-spec cell readable
532 (setq separator lbs))
536 (if (consp (car cell))
537 (char-db-insert-char-spec cell readable)
538 (char-db-insert-char-reference cell readable))
539 (setq separator lbs))
543 (insert (prin1-to-string cell))
544 (setq separator " ")))
545 (setq value (cdr value)))
547 (insert line-breaking)))
549 (defun insert-char-attributes (char &optional readable attributes column)
551 (setq column (current-column)))
552 (let (name value ; has-long-ccs-name
556 (concat "\n" (make-string (1+ column) ?\ )))
557 lbs cell separator ret
559 dest-ccss ; sources required-features
564 (if (consp attributes)
566 (dolist (name attributes)
567 (unless (memq name char-db-ignored-attributes)
568 (if (find-charset name)
572 (dolist (name (char-attribute-list))
573 (unless (memq name char-db-ignored-attributes)
574 (if (find-charset name)
578 #'char-attribute-name<)))
580 (when (memq '<-subsumptive attributes)
582 (when (setq value (get-char-attribute char '<-subsumptive))
583 (char-db-insert-relation-feature char '<-subsumptive value
586 (setq attributes (delq '<-subsumptive attributes)))
587 (when (and (memq '<-denotational attributes)
588 (setq value (get-char-attribute char '<-denotational)))
589 (char-db-insert-relation-feature char '<-denotational value
592 (setq attributes (delq '<-denotational attributes)))
593 (when (and (memq 'name attributes)
594 (setq value (get-char-attribute char 'name)))
596 (if (> (+ (current-column) (length value)) 48)
599 value line-breaking))
600 (setq attributes (delq 'name attributes))
602 (when (and (memq 'name* attributes)
603 (setq value (get-char-attribute char 'name*)))
605 (if (> (+ (current-column) (length value)) 48)
608 value line-breaking))
609 (setq attributes (delq 'name* attributes))
611 (when (and (memq 'script attributes)
612 (setq value (get-char-attribute char 'script)))
613 (insert (format "(script\t\t%s)%s"
614 (mapconcat (function prin1-to-string)
617 (setq attributes (delq 'script attributes))
619 (dolist (name '(=>ucs =>ucs*))
620 (when (and (memq name attributes)
621 (setq value (get-char-attribute char name)))
622 (insert (format "(%-18s . #x%04X)\t; %c%s"
623 name value (decode-char '=ucs value)
625 (setq attributes (delq name attributes))))
626 (dolist (name '(=>ucs@gb =>ucs@cns =>ucs@jis =>ucs@ks =>ucs@big5))
627 (when (and (memq name attributes)
628 (setq value (get-char-attribute char name)))
629 (insert (format "(%-18s . #x%04X)\t; %c%s"
634 (symbol-name name) 2)))
637 (setq attributes (delq name attributes))
639 (dolist (name '(=>daikanwa))
640 (when (and (memq name attributes)
641 (setq value (get-char-attribute char name)))
644 (format "(%-18s . %05d)\t; %c%s"
645 name value (decode-char '=daikanwa value)
647 (format "(%-18s %s)\t; %c%s"
649 (mapconcat (function prin1-to-string)
651 (char-representative-of-daikanwa char)
653 (setq attributes (delq name attributes))))
654 (when (and (memq 'general-category attributes)
655 (setq value (get-char-attribute char 'general-category)))
657 "(general-category\t%s) ; %s%s"
658 (mapconcat (lambda (cell)
661 (cond ((rassoc value unidata-normative-category-alist)
662 "Normative Category")
663 ((rassoc value unidata-informative-category-alist)
664 "Informative Category")
668 (setq attributes (delq 'general-category attributes))
670 (when (and (memq 'bidi-category attributes)
671 (setq value (get-char-attribute char 'bidi-category)))
672 (insert (format "(bidi-category\t. %S)%s"
675 (setq attributes (delq 'bidi-category attributes))
677 (unless (or (not (memq 'mirrored attributes))
678 (eq (setq value (get-char-attribute char 'mirrored 'empty))
680 (insert (format "(mirrored\t\t. %S)%s"
683 (setq attributes (delq 'mirrored attributes))
686 ((and (memq 'decimal-digit-value attributes)
687 (setq value (get-char-attribute char 'decimal-digit-value)))
688 (insert (format "(decimal-digit-value . %S)%s"
691 (setq attributes (delq 'decimal-digit-value attributes))
692 (when (and (memq 'digit-value attributes)
693 (setq value (get-char-attribute char 'digit-value)))
694 (insert (format "(digit-value\t . %S)%s"
697 (setq attributes (delq 'digit-value attributes))
699 (when (and (memq 'numeric-value attributes)
700 (setq value (get-char-attribute char 'numeric-value)))
701 (insert (format "(numeric-value\t . %S)%s"
704 (setq attributes (delq 'numeric-value attributes))
708 (when (and (memq 'digit-value attributes)
709 (setq value (get-char-attribute char 'digit-value)))
710 (insert (format "(digit-value\t. %S)%s"
713 (setq attributes (delq 'digit-value attributes))
715 (when (and (memq 'numeric-value attributes)
716 (setq value (get-char-attribute char 'numeric-value)))
717 (insert (format "(numeric-value\t. %S)%s"
720 (setq attributes (delq 'numeric-value attributes))
722 (when (and (memq 'iso-10646-comment attributes)
723 (setq value (get-char-attribute char 'iso-10646-comment)))
724 (insert (format "(iso-10646-comment\t. %S)%s"
727 (setq attributes (delq 'iso-10646-comment attributes))
729 (when (and (memq 'morohashi-daikanwa attributes)
730 (setq value (get-char-attribute char 'morohashi-daikanwa)))
731 (insert (format "(morohashi-daikanwa\t%s)%s"
732 (mapconcat (function prin1-to-string) value " ")
734 (setq attributes (delq 'morohashi-daikanwa attributes))
738 (when (and (memq 'ideographic-radical attributes)
739 (setq value (get-char-attribute char 'ideographic-radical)))
741 (insert (format "(ideographic-radical . %S)\t; %c%s"
743 (ideographic-radical radical)
745 (setq attributes (delq 'ideographic-radical attributes))
747 (when (and (memq 'shuowen-radical attributes)
748 (setq value (get-char-attribute char 'shuowen-radical)))
749 (insert (format "(shuowen-radical\t. %S)\t; %c%s"
751 (shuowen-radical value)
753 (setq attributes (delq 'shuowen-radical attributes))
758 char-db-feature-domains
760 (dolist (feature (char-attribute-list))
761 (setq feature (symbol-name feature))
763 "\\(radical\\|strokes\\)@\\([^@*]+\\)\\(\\*\\|$\\)"
765 (setq domain (intern (match-string 2 feature)))
766 (unless (memq domain dest)
767 (setq dest (cons domain dest)))))
768 (sort dest #'string<))))
769 (setq key (intern (format "%s@%s" 'ideographic-radical domain)))
770 (when (and (memq key attributes)
771 (setq value (get-char-attribute char key)))
773 (insert (format "(%s . %S)\t; %c%s"
776 (ideographic-radical radical)
778 (setq attributes (delq key attributes))
780 (setq key (intern (format "%s@%s" 'ideographic-strokes domain)))
781 (when (and (memq key attributes)
782 (setq value (get-char-attribute char key)))
784 (insert (format "(%s . %S)%s"
788 (setq attributes (delq key attributes))
790 (setq key (intern (format "%s@%s" 'total-strokes domain)))
791 (when (and (memq key attributes)
792 (setq value (get-char-attribute char key)))
793 (insert (format "(%s . %S)%s"
797 (setq attributes (delq key attributes))
799 (dolist (feature '(ideographic-radical
802 (setq key (intern (format "%s@%s*sources" feature domain)))
803 (when (and (memq key attributes)
804 (setq value (get-char-attribute char key)))
805 (insert (format "(%s%s" key line-breaking))
807 (insert (format " %s" cell)))
809 (insert line-breaking)
810 (setq attributes (delq key attributes))
813 (when (and (memq 'ideographic-strokes attributes)
814 (setq value (get-char-attribute char 'ideographic-strokes)))
816 (insert (format "(ideographic-strokes . %S)%s"
819 (setq attributes (delq 'ideographic-strokes attributes))
821 (when (and (memq 'kangxi-radical attributes)
822 (setq value (get-char-attribute char 'kangxi-radical)))
823 (unless (eq value radical)
824 (insert (format "(kangxi-radical\t . %S)\t; %c%s"
826 (ideographic-radical value)
829 (setq radical value)))
830 (setq attributes (delq 'kangxi-radical attributes))
832 (when (and (memq 'kangxi-strokes attributes)
833 (setq value (get-char-attribute char 'kangxi-strokes)))
834 (unless (eq value strokes)
835 (insert (format "(kangxi-strokes\t . %S)%s"
839 (setq strokes value)))
840 (setq attributes (delq 'kangxi-strokes attributes))
842 (when (and (memq 'japanese-radical attributes)
843 (setq value (get-char-attribute char 'japanese-radical)))
844 (unless (eq value radical)
845 (insert (format "(japanese-radical\t . %S)\t; %c%s"
847 (ideographic-radical value)
850 (setq radical value)))
851 (setq attributes (delq 'japanese-radical attributes))
853 (when (and (memq 'japanese-strokes attributes)
854 (setq value (get-char-attribute char 'japanese-strokes)))
855 (unless (eq value strokes)
856 (insert (format "(japanese-strokes\t . %S)%s"
860 (setq strokes value)))
861 (setq attributes (delq 'japanese-strokes attributes))
863 (when (and (memq 'cns-radical attributes)
864 (setq value (get-char-attribute char 'cns-radical)))
865 (insert (format "(cns-radical\t . %S)\t; %c%s"
867 (ideographic-radical value)
869 (setq attributes (delq 'cns-radical attributes))
871 (when (and (memq 'cns-strokes attributes)
872 (setq value (get-char-attribute char 'cns-strokes)))
873 (unless (eq value strokes)
874 (insert (format "(cns-strokes\t . %S)%s"
878 (setq strokes value)))
879 (setq attributes (delq 'cns-strokes attributes))
881 (when (and (memq 'shinjigen-1-radical attributes)
882 (setq value (get-char-attribute char 'shinjigen-1-radical)))
883 (unless (eq value radical)
884 (insert (format "(shinjigen-1-radical . %S)\t; %c%s"
886 (ideographic-radical value)
889 (setq radical value)))
890 (setq attributes (delq 'shinjigen-1-radical attributes))
892 (when (and (memq 'ideographic- attributes)
893 (setq value (get-char-attribute char 'ideographic-)))
894 (insert "(ideographic- ")
895 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
898 (setq cell (car value))
900 (setq cell (decode-char '=ucs cell)))
901 (cond ((characterp cell)
905 (insert (format "%S" cell))
906 (char-db-insert-char-spec cell readable))
907 (setq separator lbs))
911 (if (consp (car cell))
912 (char-db-insert-char-spec cell readable)
913 (char-db-insert-char-reference cell readable))
914 (setq separator lbs))
918 (insert (prin1-to-string cell))
919 (setq separator " ")))
920 (setq value (cdr value)))
922 (insert line-breaking)
923 (setq attributes (delq 'ideographic- attributes)))
924 (when (and (memq 'total-strokes attributes)
925 (setq value (get-char-attribute char 'total-strokes)))
926 (insert (format "(total-strokes . %S)%s"
929 (setq attributes (delq 'total-strokes attributes))
931 (when (and (memq '->ideograph attributes)
932 (setq value (get-char-attribute char '->ideograph)))
933 (insert (format "(->ideograph\t%s)%s"
934 (mapconcat (lambda (code)
935 (cond ((symbolp code)
938 (format "#x%04X" code))
941 line-breaking code))))
944 (setq attributes (delq '->ideograph attributes))
946 ;; (when (and (memq '->decomposition attributes)
947 ;; (setq value (get-char-attribute char '->decomposition)))
948 ;; (insert (format "(->decomposition\t%s)%s"
949 ;; (mapconcat (lambda (code)
950 ;; (cond ((symbolp code)
951 ;; (symbol-name code))
952 ;; ((characterp code)
954 ;; (format "%S" code)
959 ;; (format "#x%04X" code))
961 ;; (format "%s%S" line-breaking code))))
964 ;; (setq attributes (delq '->decomposition attributes))
966 (if (equal (get-char-attribute char '->titlecase)
967 (get-char-attribute char '->uppercase))
968 (setq attributes (delq '->titlecase attributes)))
969 (when (and (memq '->mojikyo attributes)
970 (setq value (get-char-attribute char '->mojikyo)))
971 (insert (format "(->mojikyo\t\t. %06d)\t; %c%s"
972 value (decode-char 'mojikyo value)
974 (setq attributes (delq '->mojikyo attributes))
976 (when (and (memq 'hanyu-dazidian-vol attributes)
977 (setq value (get-char-attribute char 'hanyu-dazidian-vol)))
978 (insert (format "(hanyu-dazidian-vol . %d)%s"
979 value line-breaking))
980 (setq attributes (delq 'hanyu-dazidian-vol attributes))
982 (when (and (memq 'hanyu-dazidian-page attributes)
983 (setq value (get-char-attribute char 'hanyu-dazidian-page)))
984 (insert (format "(hanyu-dazidian-page . %d)%s"
985 value line-breaking))
986 (setq attributes (delq 'hanyu-dazidian-page attributes))
988 (when (and (memq 'hanyu-dazidian-char attributes)
989 (setq value (get-char-attribute char 'hanyu-dazidian-char)))
990 (insert (format "(hanyu-dazidian-char . %d)%s"
991 value line-breaking))
992 (setq attributes (delq 'hanyu-dazidian-char attributes))
995 (dolist (ignored '(composition
996 ->denotational <-subsumptive ->ucs-unified
997 ->ideographic-component-forms))
998 (setq attributes (delq ignored attributes))))
1000 (setq name (car attributes))
1001 (if (setq value (get-char-attribute char name))
1002 (cond ((setq ret (find-charset name))
1003 (setq name (charset-name ret))
1004 (if (and (not (memq name dest-ccss))
1006 (setq value (get-char-attribute char name))
1007 (setq dest-ccss (cons name dest-ccss))))
1008 (char-db-insert-ccs-feature name value line-breaking))
1010 ((string-match "^=>ucs@" (symbol-name name))
1011 (insert (format "(%-18s . #x%04X)\t; %c%s"
1012 name value (decode-char '=ucs value)
1015 ((eq name 'jisx0208-1978/4X)
1016 (insert (format "(%-18s . #x%04X)%s"
1022 (not (eq name '->subsumptive))
1023 (not (eq name '->bopomofo))
1024 (not (eq name '->mistakable))
1025 (not (eq name '->ideographic-variants))
1026 (not (eq name '->canonical))
1027 (null (get-char-attribute
1028 char (intern (format "%s*sources" name))))
1029 (not (string-match "\\*sources$" (symbol-name name)))
1030 (or (eq name '<-identical)
1031 (eq name '<-canonical)
1032 (eq name '<-ideographic-variants)
1033 ;; (eq name '<-synonyms)
1034 (string-match "^<-synonyms" (symbol-name name))
1035 (eq name '<-mistakable)
1036 (when (string-match "^->" (symbol-name name))
1038 ((string-match "^->fullwidth" (symbol-name name))
1039 (not (and (consp value)
1040 (characterp (car value))
1042 (car value) '=ucs 'defined-only)))
1047 ((or (eq name 'ideographic-structure)
1048 (eq name 'ideographic-combination)
1049 (eq name 'ideographic-)
1050 (eq name '=decomposition)
1051 (string-match "^=>decomposition" (symbol-name name))
1052 (string-match "^\\(->\\|<-\\)" (symbol-name name)))
1053 (char-db-insert-relation-feature char name value
1056 ((memq name '(ideograph=
1057 original-ideograph-of
1058 ancient-ideograph-of
1061 ;; simplified-ideograph-of
1062 ideographic-variants
1063 ;; ideographic-different-form-of
1065 (insert (format "(%-18s%s " name line-breaking))
1066 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
1068 (while (consp value)
1069 (setq cell (car value))
1070 (if (and (consp cell)
1075 (char-db-insert-alist cell readable)
1076 (setq separator lbs))
1079 (insert (prin1-to-string cell))
1080 (setq separator " "))
1081 (setq value (cdr value)))
1083 (insert line-breaking))
1085 (insert (format "(%-18s " name))
1086 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
1088 (while (consp value)
1089 (setq cell (car value))
1090 (if (and (consp cell)
1092 (setq ret (condition-case nil
1100 (setq key (car (car rest)))
1101 (if (find-charset key)
1102 (setq cal (cons key cal))
1103 (setq al (cons key al)))
1104 (setq rest (cdr rest)))
1107 (insert-char-attributes ret
1110 (setq separator lbs))
1111 (setq ret (prin1-to-string cell))
1113 (if (< (+ (current-column)
1120 (setq separator " "))
1121 (setq value (cdr value)))
1123 (insert line-breaking))
1125 (insert (format "(%-18s . %S)%s"
1129 (setq attributes (cdr attributes)))
1132 (defun insert-char-data (char &optional readable
1135 (narrow-to-region (point)(point))
1136 (insert "(define-char
1138 (insert-char-attributes char readable attributes)
1140 (goto-char (point-min))
1141 (while (re-search-forward "[ \t]+$" nil t)
1144 (goto-char (point-min))
1145 (while (re-search-forward "[ \t][ \t][ \t]*" nil t)
1146 (let ((column (current-column))
1147 (indent-tabs-mode t))
1148 (delete-region (match-beginning 0) (point))
1149 (indent-to column)))
1150 (goto-char (point-max))
1151 ;; (tabify (point-min)(point-max))
1154 (defun insert-char-data-with-variant (char &optional printable
1156 script excluded-script)
1157 (insert-char-data char printable)
1158 (let ((variants (char-variants char))
1161 (setq variants (sort variants #'<))
1162 (setq rest variants)
1163 (setq variants (cons char variants))
1165 (setq variant (car rest))
1166 (unless (get-char-attribute variant '<-subsumptive)
1167 (if (and (or (null script)
1168 (null (setq vs (get-char-attribute variant 'script)))
1170 (or (null excluded-script)
1171 (null (setq vs (get-char-attribute variant 'script)))
1172 (not (memq excluded-script vs))))
1173 (unless (and no-ucs-unified (get-char-attribute variant '=ucs))
1174 (insert-char-data variant printable)
1175 (if (setq ret (char-variants variant))
1177 (or (memq (car ret) variants)
1178 ;; (get-char-attribute (car ret) '<-subsumptive)
1179 (setq rest (nconc rest (list (car ret)))))
1180 (setq ret (cdr ret)))))))
1181 (setq rest (cdr rest)))))
1183 (defun insert-char-range-data (min max &optional script excluded-script)
1186 (while (<= code max)
1187 (setq char (decode-char '=ucs code))
1188 (if (encode-char char '=ucs 'defined-only)
1189 (insert-char-data-with-variant char nil 'no-ucs-unified
1190 script excluded-script))
1191 (setq code (1+ code)))))
1193 (defun write-char-range-data-to-file (min max file
1194 &optional script excluded-script)
1195 (let ((coding-system-for-write char-db-file-coding-system))
1197 (insert (format ";; -*- coding: %s -*-\n"
1198 char-db-file-coding-system))
1199 (insert-char-range-data min max script excluded-script)
1200 (write-region (point-min)(point-max) file))))
1202 (defvar what-character-original-window-configuration)
1205 (defun what-char-definition (char)
1206 (interactive (list (char-after)))
1207 (let ((buf (get-buffer-create "*Character Description*"))
1208 (the-buf (current-buffer))
1209 (win-conf (current-window-configuration)))
1211 (make-local-variable 'what-character-original-window-configuration)
1212 (setq what-character-original-window-configuration win-conf)
1213 (setq buffer-read-only nil)
1217 (insert-char-data-with-variant char 'printable)
1218 (unless (char-attribute-alist char)
1219 (insert (format ";; = %c\n"
1220 (let* ((rest (split-char char))
1224 (setq code (logior (lsh code 8)
1226 (decode-char ccs code)))))
1227 ;; (char-db-update-comment)
1228 (set-buffer-modified-p nil)
1229 (view-mode the-buf (lambda (buf)
1230 (set-window-configuration
1231 what-character-original-window-configuration)
1233 (goto-char (point-min)))
1235 (set-window-configuration
1236 what-character-original-window-configuration)
1237 (signal (car err) (cdr err)))))))
1239 (provide 'char-db-util)
1241 ;;; char-db-util.el ends here