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
197 (defun char-db-make-char-spec (char)
199 (cond ((characterp char)
200 (cond ((and (setq ret (encode-char char '=ucs 'defined-only))
201 (not (and (<= #xE000 ret)(<= ret #xF8FF))))
202 (setq char-spec (list (cons '=ucs ret)))
203 (cond ((setq ret (get-char-attribute char 'name))
204 (setq char-spec (cons (cons 'name ret) char-spec))
206 ((setq ret (get-char-attribute char 'name*))
207 (setq char-spec (cons (cons 'name* ret) char-spec))
212 (let ((rest char-db-coded-charset-priority-list)
215 (setq ccs (charset-name
216 (find-charset (car rest))))
218 (encode-char char ccs
220 (throw 'tag (cons ccs ret)))
221 (setq rest (cdr rest))))))
222 (setq char-spec (list ret))
223 (dolist (ccs (delq (car ret) (charset-list)))
224 (if (and (or (charset-iso-final-char ccs)
230 (setq ccs (charset-name ccs))
231 (null (assq ccs char-spec))
232 (setq ret (encode-char char ccs 'defined-only)))
233 (setq char-spec (cons (cons ccs ret) char-spec))))
235 (setq char-spec (split-char char)))
236 (cond ((setq ret (get-char-attribute char 'name))
237 (setq char-spec (cons (cons 'name ret) char-spec))
239 ((setq ret (get-char-attribute char 'name*))
240 (setq char-spec (cons (cons 'name* ret) char-spec))
247 (defun char-db-insert-char-spec (char &optional readable column
250 (setq column (current-column)))
251 (let (char-spec temp-char)
252 (setq char-spec (char-db-make-char-spec char))
253 (unless (or (characterp char) ; char
255 (setq char (find-char char-spec))
257 ;; define temporary character
258 ;; Current implementation is dirty.
259 (setq temp-char (define-char (cons '(ideograph-daikanwa . 0)
261 (remove-char-attribute temp-char 'ideograph-daikanwa)
262 (setq char temp-char))
263 (insert-char-attributes char
265 (union (mapcar #'car char-spec)
268 ;; undefine temporary character
269 ;; Current implementation is dirty.
270 (setq char-spec (char-attribute-alist temp-char))
272 (remove-char-attribute temp-char (car (car char-spec)))
273 (setq char-spec (cdr char-spec))))))
275 (defun char-db-insert-alist (alist &optional readable column)
277 (setq column (current-column)))
279 (concat "\n" (make-string (1+ column) ?\ )))
283 lbs cell rest separator)
286 (setq name (car (car alist))
287 value (cdr (car alist)))
288 (cond ((eq name 'char)
290 (if (setq ret (condition-case nil
298 (setq key (car (car value)))
299 ;; (if (find-charset key)
300 ;; (setq cal (cons key cal))
301 (setq al (cons key al))
303 (setq value (cdr value)))
304 (insert-char-attributes ret
308 (insert (prin1-to-string value)))
310 (insert line-breaking))
312 (insert (format "(%-18s " name))
313 (setq lbs (concat "\n" (make-string (current-column) ?\ )))
315 (setq cell (car value))
316 (if (and (consp cell)
318 (setq ret (condition-case nil
328 (setq key (car (car rest)))
329 ;; (if (find-charset key)
330 ;; (setq cal (cons key cal))
331 (setq al (cons key al))
333 (setq rest (cdr rest)))
336 (insert-char-attributes ret
340 (setq separator lbs))
343 (insert (prin1-to-string cell))
344 (setq separator " "))
345 (setq value (cdr value)))
347 (insert line-breaking))
349 (insert (format "(%-18s . %S)%s"
352 (setq alist (cdr alist))))
355 (defun char-db-insert-char-reference (plist &optional readable column)
357 (setq column (current-column)))
359 (concat "\n" (make-string (1+ column) ?\ )))
364 (setq name (pop plist))
365 (setq value (pop plist))
366 (cond ((eq name :char)
369 (cond ((numberp value)
370 (setq value (decode-char '=ucs value)))
372 ;; (setq value (or (find-char value)
375 (char-db-insert-char-spec value readable)
376 (insert line-breaking)
379 (insert (format "%s%s\t%d ; %c%s"
382 (ideographic-radical value)
386 (insert (format "%s%s\t%S" separator name value))
387 (setq separator line-breaking)))
391 (defun char-db-decode-isolated-char (ccs code-point)
394 (cond ((eq ccs 'arabic-iso8859-6)
395 (decode-char ccs code-point))
396 ((and (memq ccs '(=gt-pj-1
407 (setq ret (decode-char ccs code-point))
408 (setq ret (encode-char ret '=gt 'defined-only)))
409 (decode-builtin-char '=gt ret))
411 (decode-builtin-char ccs code-point))))
412 (cond ((and (<= 0 (char-int ret))
413 (<= (char-int ret) #x1F))
414 (decode-char '=ucs (+ #x2400 (char-int ret))))
415 ((= (char-int ret) #x7F)
419 (defvar char-db-convert-obsolete-format t)
421 (defun char-db-insert-ccs-feature (name value line-breaking)
424 (cond ((memq name '(=daikanwa
425 =daikanwa@rev1 =daikanwa@rev2
426 =gt =gt-k =cbeta =zinbun-oracle))
427 "(%-18s . %05d)\t; %c")
429 "(%-18s . %06d)\t; %c")
430 ((>= (charset-dimension name) 2)
431 "(%-18s . #x%04X)\t; %c")
433 "(%-18s . #x%02X)\t; %c"))
435 (if (= (charset-iso-graphic-plane name) 1)
437 (cond ((= (charset-dimension name) 1)
439 ((= (charset-dimension name) 2)
441 ((= (charset-dimension name) 3)
445 (char-db-decode-isolated-char name value)))
446 (if (and (= (charset-chars name) 94)
447 (= (charset-dimension name) 2))
448 (insert (format " [%02d-%02d]"
449 (- (lsh value -8) 32)
450 (- (logand value 255) 32))))
451 (insert line-breaking))
453 (defun char-db-insert-relation-feature (char name value line-breaking
455 (insert (format "(%-18s%s " name line-breaking))
456 (let ((lbs (concat "\n" (make-string (current-column) ?\ )))
457 separator cell sources required-features
460 (setq cell (car value))
462 (setq cell (decode-char '=ucs cell)))
464 ((eq name '->subsumptive)
465 (when (or (not (some (lambda (atr)
466 (get-char-attribute cell atr))
467 char-db-ignored-attributes))
469 (encode-char cell ccs 'defined-only))
473 (let ((char-db-ignored-attributes
475 char-db-ignored-attributes)))
476 (insert-char-attributes cell readable))
477 (setq separator lbs))
482 char (intern (format "%s*sources" name))))
483 (setq required-features nil)
484 (dolist (source sources)
486 ((memq source '(JP JP/Jouyou shinjigen-1))
487 (setq required-features
488 (union required-features
497 (setq required-features
498 (union required-features
503 ((find-charset (setq ret (intern (format "=%s" source))))
504 (setq required-features
505 (cons ret required-features)))
506 (t (setq required-features
507 (cons source required-features)))))
508 (cond ((string-match "@JP" (symbol-name name))
509 (setq required-features
510 (union required-features
518 ((string-match "@CN" (symbol-name name))
519 (setq required-features
520 (union required-features
527 (insert (format "%S" cell))
528 (char-db-insert-char-spec cell readable
531 (setq separator lbs))
535 (if (consp (car cell))
536 (char-db-insert-char-spec cell readable)
537 (char-db-insert-char-reference cell readable))
538 (setq separator lbs))
542 (insert (prin1-to-string cell))
543 (setq separator " ")))
544 (setq value (cdr value)))
546 (insert line-breaking)))
548 (defun insert-char-attributes (char &optional readable attributes column)
550 (setq column (current-column)))
551 (let (name value ; has-long-ccs-name
555 (concat "\n" (make-string (1+ column) ?\ )))
556 lbs cell separator ret
558 dest-ccss ; sources required-features
563 (if (consp attributes)
565 (dolist (name attributes)
566 (unless (memq name char-db-ignored-attributes)
567 (if (find-charset name)
571 (dolist (name (char-attribute-list))
572 (unless (memq name char-db-ignored-attributes)
573 (if (find-charset name)
577 #'char-attribute-name<)))
579 (when (memq '<-subsumptive attributes)
581 (when (setq value (get-char-attribute char '<-subsumptive))
582 (char-db-insert-relation-feature char '<-subsumptive value
585 (setq attributes (delq '<-subsumptive attributes)))
586 (when (and (memq '<-denotational attributes)
587 (setq value (get-char-attribute char '<-denotational)))
588 (char-db-insert-relation-feature char '<-denotational value
591 (setq attributes (delq '<-denotational attributes)))
592 (when (and (memq 'name attributes)
593 (setq value (get-char-attribute char 'name)))
595 (if (> (+ (current-column) (length value)) 48)
598 value line-breaking))
599 (setq attributes (delq 'name attributes))
601 (when (and (memq 'name* attributes)
602 (setq value (get-char-attribute char 'name*)))
604 (if (> (+ (current-column) (length value)) 48)
607 value line-breaking))
608 (setq attributes (delq 'name* attributes))
610 (when (and (memq 'script attributes)
611 (setq value (get-char-attribute char 'script)))
612 (insert (format "(script\t\t%s)%s"
613 (mapconcat (function prin1-to-string)
616 (setq attributes (delq 'script attributes))
618 (dolist (name '(=>ucs =>ucs*))
619 (when (and (memq name attributes)
620 (setq value (get-char-attribute char name)))
621 (insert (format "(%-18s . #x%04X)\t; %c%s"
622 name value (decode-char '=ucs value)
624 (setq attributes (delq name attributes))))
625 (dolist (name '(=>ucs@gb =>ucs@cns =>ucs@jis =>ucs@ks =>ucs@big5))
626 (when (and (memq name attributes)
627 (setq value (get-char-attribute char name)))
628 (insert (format "(%-18s . #x%04X)\t; %c%s"
633 (symbol-name name) 2)))
636 (setq attributes (delq name attributes))
638 (dolist (name '(=>daikanwa))
639 (when (and (memq name attributes)
640 (setq value (get-char-attribute char name)))
643 (format "(%-18s . %05d)\t; %c%s"
644 name value (decode-char '=daikanwa value)
646 (format "(%-18s %s)\t; %c%s"
648 (mapconcat (function prin1-to-string)
650 (char-representative-of-daikanwa char)
652 (setq attributes (delq name attributes))))
653 (when (and (memq 'general-category attributes)
654 (setq value (get-char-attribute char 'general-category)))
656 "(general-category\t%s) ; %s%s"
657 (mapconcat (lambda (cell)
660 (cond ((rassoc value unidata-normative-category-alist)
661 "Normative Category")
662 ((rassoc value unidata-informative-category-alist)
663 "Informative Category")
667 (setq attributes (delq 'general-category attributes))
669 (when (and (memq 'bidi-category attributes)
670 (setq value (get-char-attribute char 'bidi-category)))
671 (insert (format "(bidi-category\t. %S)%s"
674 (setq attributes (delq 'bidi-category attributes))
676 (unless (or (not (memq 'mirrored attributes))
677 (eq (setq value (get-char-attribute char 'mirrored 'empty))
679 (insert (format "(mirrored\t\t. %S)%s"
682 (setq attributes (delq 'mirrored attributes))
685 ((and (memq 'decimal-digit-value attributes)
686 (setq value (get-char-attribute char 'decimal-digit-value)))
687 (insert (format "(decimal-digit-value . %S)%s"
690 (setq attributes (delq 'decimal-digit-value attributes))
691 (when (and (memq 'digit-value attributes)
692 (setq value (get-char-attribute char 'digit-value)))
693 (insert (format "(digit-value\t . %S)%s"
696 (setq attributes (delq 'digit-value attributes))
698 (when (and (memq 'numeric-value attributes)
699 (setq value (get-char-attribute char 'numeric-value)))
700 (insert (format "(numeric-value\t . %S)%s"
703 (setq attributes (delq 'numeric-value attributes))
707 (when (and (memq 'digit-value attributes)
708 (setq value (get-char-attribute char 'digit-value)))
709 (insert (format "(digit-value\t. %S)%s"
712 (setq attributes (delq 'digit-value attributes))
714 (when (and (memq 'numeric-value attributes)
715 (setq value (get-char-attribute char 'numeric-value)))
716 (insert (format "(numeric-value\t. %S)%s"
719 (setq attributes (delq 'numeric-value attributes))
721 (when (and (memq 'iso-10646-comment attributes)
722 (setq value (get-char-attribute char 'iso-10646-comment)))
723 (insert (format "(iso-10646-comment\t. %S)%s"
726 (setq attributes (delq 'iso-10646-comment attributes))
728 (when (and (memq 'morohashi-daikanwa attributes)
729 (setq value (get-char-attribute char 'morohashi-daikanwa)))
730 (insert (format "(morohashi-daikanwa\t%s)%s"
731 (mapconcat (function prin1-to-string) value " ")
733 (setq attributes (delq 'morohashi-daikanwa attributes))
737 (when (and (memq 'ideographic-radical attributes)
738 (setq value (get-char-attribute char 'ideographic-radical)))
740 (insert (format "(ideographic-radical . %S)\t; %c%s"
742 (ideographic-radical radical)
744 (setq attributes (delq 'ideographic-radical attributes))
746 (when (and (memq 'shuowen-radical attributes)
747 (setq value (get-char-attribute char 'shuowen-radical)))
748 (insert (format "(shuowen-radical\t. %S)\t; %c%s"
750 (shuowen-radical value)
752 (setq attributes (delq 'shuowen-radical attributes))
757 char-db-feature-domains
759 (dolist (feature (char-attribute-list))
760 (setq feature (symbol-name feature))
762 "\\(radical\\|strokes\\)@\\([^@*]+\\)\\(\\*\\|$\\)"
764 (setq domain (intern (match-string 2 feature)))
765 (unless (memq domain dest)
766 (setq dest (cons domain dest)))))
767 (sort dest #'string<))))
768 (setq key (intern (format "%s@%s" 'ideographic-radical domain)))
769 (when (and (memq key attributes)
770 (setq value (get-char-attribute char key)))
772 (insert (format "(%s . %S)\t; %c%s"
775 (ideographic-radical radical)
777 (setq attributes (delq key attributes))
779 (setq key (intern (format "%s@%s" 'ideographic-strokes domain)))
780 (when (and (memq key attributes)
781 (setq value (get-char-attribute char key)))
783 (insert (format "(%s . %S)%s"
787 (setq attributes (delq key attributes))
789 (setq key (intern (format "%s@%s" 'total-strokes domain)))
790 (when (and (memq key attributes)
791 (setq value (get-char-attribute char key)))
792 (insert (format "(%s . %S)%s"
796 (setq attributes (delq key attributes))
798 (dolist (feature '(ideographic-radical
801 (setq key (intern (format "%s@%s*sources" feature domain)))
802 (when (and (memq key attributes)
803 (setq value (get-char-attribute char key)))
804 (insert (format "(%s%s" key line-breaking))
806 (insert (format " %s" cell)))
808 (insert line-breaking)
809 (setq attributes (delq key attributes))
812 (when (and (memq 'ideographic-strokes attributes)
813 (setq value (get-char-attribute char 'ideographic-strokes)))
815 (insert (format "(ideographic-strokes . %S)%s"
818 (setq attributes (delq 'ideographic-strokes attributes))
820 (when (and (memq 'kangxi-radical attributes)
821 (setq value (get-char-attribute char 'kangxi-radical)))
822 (unless (eq value radical)
823 (insert (format "(kangxi-radical\t . %S)\t; %c%s"
825 (ideographic-radical value)
828 (setq radical value)))
829 (setq attributes (delq 'kangxi-radical attributes))
831 (when (and (memq 'kangxi-strokes attributes)
832 (setq value (get-char-attribute char 'kangxi-strokes)))
833 (unless (eq value strokes)
834 (insert (format "(kangxi-strokes\t . %S)%s"
838 (setq strokes value)))
839 (setq attributes (delq 'kangxi-strokes attributes))
841 (when (and (memq 'japanese-radical attributes)
842 (setq value (get-char-attribute char 'japanese-radical)))
843 (unless (eq value radical)
844 (insert (format "(japanese-radical\t . %S)\t; %c%s"
846 (ideographic-radical value)
849 (setq radical value)))
850 (setq attributes (delq 'japanese-radical attributes))
852 (when (and (memq 'japanese-strokes attributes)
853 (setq value (get-char-attribute char 'japanese-strokes)))
854 (unless (eq value strokes)
855 (insert (format "(japanese-strokes\t . %S)%s"
859 (setq strokes value)))
860 (setq attributes (delq 'japanese-strokes attributes))
862 (when (and (memq 'cns-radical attributes)
863 (setq value (get-char-attribute char 'cns-radical)))
864 (insert (format "(cns-radical\t . %S)\t; %c%s"
866 (ideographic-radical value)
868 (setq attributes (delq 'cns-radical attributes))
870 (when (and (memq 'cns-strokes attributes)
871 (setq value (get-char-attribute char 'cns-strokes)))
872 (unless (eq value strokes)
873 (insert (format "(cns-strokes\t . %S)%s"
877 (setq strokes value)))
878 (setq attributes (delq 'cns-strokes attributes))
880 (when (and (memq 'shinjigen-1-radical attributes)
881 (setq value (get-char-attribute char 'shinjigen-1-radical)))
882 (unless (eq value radical)
883 (insert (format "(shinjigen-1-radical . %S)\t; %c%s"
885 (ideographic-radical value)
888 (setq radical value)))
889 (setq attributes (delq 'shinjigen-1-radical attributes))
891 (when (and (memq 'ideographic- attributes)
892 (setq value (get-char-attribute char 'ideographic-)))
893 (insert "(ideographic- ")
894 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
897 (setq cell (car value))
899 (setq cell (decode-char '=ucs cell)))
900 (cond ((characterp cell)
904 (insert (format "%S" cell))
905 (char-db-insert-char-spec cell readable))
906 (setq separator lbs))
910 (if (consp (car cell))
911 (char-db-insert-char-spec cell readable)
912 (char-db-insert-char-reference cell readable))
913 (setq separator lbs))
917 (insert (prin1-to-string cell))
918 (setq separator " ")))
919 (setq value (cdr value)))
921 (insert line-breaking)
922 (setq attributes (delq 'ideographic- attributes)))
923 (when (and (memq 'total-strokes attributes)
924 (setq value (get-char-attribute char 'total-strokes)))
925 (insert (format "(total-strokes . %S)%s"
928 (setq attributes (delq 'total-strokes attributes))
930 (when (and (memq '->ideograph attributes)
931 (setq value (get-char-attribute char '->ideograph)))
932 (insert (format "(->ideograph\t%s)%s"
933 (mapconcat (lambda (code)
934 (cond ((symbolp code)
937 (format "#x%04X" code))
940 line-breaking code))))
943 (setq attributes (delq '->ideograph attributes))
945 ;; (when (and (memq '->decomposition attributes)
946 ;; (setq value (get-char-attribute char '->decomposition)))
947 ;; (insert (format "(->decomposition\t%s)%s"
948 ;; (mapconcat (lambda (code)
949 ;; (cond ((symbolp code)
950 ;; (symbol-name code))
951 ;; ((characterp code)
953 ;; (format "%S" code)
958 ;; (format "#x%04X" code))
960 ;; (format "%s%S" line-breaking code))))
963 ;; (setq attributes (delq '->decomposition attributes))
965 (if (equal (get-char-attribute char '->titlecase)
966 (get-char-attribute char '->uppercase))
967 (setq attributes (delq '->titlecase attributes)))
968 (when (and (memq '->mojikyo attributes)
969 (setq value (get-char-attribute char '->mojikyo)))
970 (insert (format "(->mojikyo\t\t. %06d)\t; %c%s"
971 value (decode-char 'mojikyo value)
973 (setq attributes (delq '->mojikyo attributes))
975 (when (and (memq 'hanyu-dazidian-vol attributes)
976 (setq value (get-char-attribute char 'hanyu-dazidian-vol)))
977 (insert (format "(hanyu-dazidian-vol . %d)%s"
978 value line-breaking))
979 (setq attributes (delq 'hanyu-dazidian-vol attributes))
981 (when (and (memq 'hanyu-dazidian-page attributes)
982 (setq value (get-char-attribute char 'hanyu-dazidian-page)))
983 (insert (format "(hanyu-dazidian-page . %d)%s"
984 value line-breaking))
985 (setq attributes (delq 'hanyu-dazidian-page attributes))
987 (when (and (memq 'hanyu-dazidian-char attributes)
988 (setq value (get-char-attribute char 'hanyu-dazidian-char)))
989 (insert (format "(hanyu-dazidian-char . %d)%s"
990 value line-breaking))
991 (setq attributes (delq 'hanyu-dazidian-char attributes))
994 (dolist (ignored '(composition
995 ->denotational <-subsumptive ->ucs-unified
996 ->ideographic-component-forms))
997 (setq attributes (delq ignored attributes))))
999 (setq name (car attributes))
1000 (if (setq value (get-char-attribute char name))
1001 (cond ((setq ret (find-charset name))
1002 (setq name (charset-name ret))
1003 (if (and (not (memq name dest-ccss))
1005 (setq value (get-char-attribute char name))
1006 (setq dest-ccss (cons name dest-ccss))))
1007 (char-db-insert-ccs-feature name value line-breaking))
1009 ((string-match "^=>ucs@" (symbol-name name))
1010 (insert (format "(%-18s . #x%04X)\t; %c%s"
1011 name value (decode-char '=ucs value)
1014 ((eq name 'jisx0208-1978/4X)
1015 (insert (format "(%-18s . #x%04X)%s"
1019 ((and (not readable)
1020 (null (get-char-attribute
1022 (intern (format "%s*sources" name))))
1023 (not (string-match "\\*sources$" (symbol-name name)))
1024 (or (eq name '<-identical)
1025 (eq name '<-canonical)
1026 (eq name '->superscript)
1027 (eq name '->subscript)
1028 (eq name '->circled)
1029 (string-match "^->font" (symbol-name name))
1030 (string-match "^->compat" (symbol-name name))
1031 (string-match "^->halfwidth" (symbol-name name))
1033 (string-match "^->fullwidth" (symbol-name name))
1036 (characterp (car value))
1038 (car value) '=ucs 'defined-only))))
1039 (string-match "^->simplified" (symbol-name name))
1040 (string-match "^->vulgar" (symbol-name name))
1041 (string-match "^->wrong" (symbol-name name))
1042 (string-match "^->same" (symbol-name name))
1043 (string-match "^->formed" (symbol-name name))
1044 (string-match "^->original" (symbol-name name))
1045 (string-match "^->ancient" (symbol-name name))
1046 (string-match "^->Oracle-Bones" (symbol-name name))
1049 ((or (eq name 'ideographic-structure)
1050 (eq name 'ideographic-combination)
1051 (eq name 'ideographic-)
1052 (eq name '=decomposition)
1053 (string-match "^=>decomposition" (symbol-name name))
1054 (string-match "^\\(->\\|<-\\)" (symbol-name name)))
1055 (char-db-insert-relation-feature char name value
1058 ((memq name '(ideograph=
1059 original-ideograph-of
1060 ancient-ideograph-of
1063 ;; simplified-ideograph-of
1064 ideographic-variants
1065 ;; ideographic-different-form-of
1067 (insert (format "(%-18s%s " name line-breaking))
1068 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
1070 (while (consp value)
1071 (setq cell (car value))
1072 (if (and (consp cell)
1077 (char-db-insert-alist cell readable)
1078 (setq separator lbs))
1081 (insert (prin1-to-string cell))
1082 (setq separator " "))
1083 (setq value (cdr value)))
1085 (insert line-breaking))
1087 (insert (format "(%-18s " name))
1088 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
1090 (while (consp value)
1091 (setq cell (car value))
1092 (if (and (consp cell)
1094 (setq ret (condition-case nil
1102 (setq key (car (car rest)))
1103 (if (find-charset key)
1104 (setq cal (cons key cal))
1105 (setq al (cons key al)))
1106 (setq rest (cdr rest)))
1109 (insert-char-attributes ret
1112 (setq separator lbs))
1113 (setq ret (prin1-to-string cell))
1115 (if (< (+ (current-column)
1122 (setq separator " "))
1123 (setq value (cdr value)))
1125 (insert line-breaking))
1127 (insert (format "(%-18s . %S)%s"
1131 (setq attributes (cdr attributes)))
1134 (defun insert-char-data (char &optional readable
1137 (narrow-to-region (point)(point))
1138 (insert "(define-char
1140 (insert-char-attributes char readable attributes)
1142 (goto-char (point-min))
1143 (while (re-search-forward "[ \t]+$" nil t)
1146 (goto-char (point-min))
1147 (while (re-search-forward "[ \t][ \t][ \t]*" nil t)
1148 (let ((column (current-column))
1149 (indent-tabs-mode t))
1150 (delete-region (match-beginning 0) (point))
1151 (indent-to column)))
1152 (goto-char (point-max))
1153 ;; (tabify (point-min)(point-max))
1156 (defun insert-char-data-with-variant (char &optional printable
1158 script excluded-script)
1159 (insert-char-data char printable)
1160 (let ((variants (char-variants char))
1163 (setq variants (sort variants #'<))
1164 (setq rest variants)
1165 (setq variants (cons char variants))
1167 (setq variant (car rest))
1168 (unless (get-char-attribute variant '<-subsumptive)
1169 (if (and (or (null script)
1170 (null (setq vs (get-char-attribute variant 'script)))
1172 (or (null excluded-script)
1173 (null (setq vs (get-char-attribute variant 'script)))
1174 (not (memq excluded-script vs))))
1175 (unless (and no-ucs-unified (get-char-attribute variant '=ucs))
1176 (insert-char-data variant printable)
1177 (if (setq ret (char-variants variant))
1179 (or (memq (car ret) variants)
1180 ;; (get-char-attribute (car ret) '<-subsumptive)
1181 (setq rest (nconc rest (list (car ret)))))
1182 (setq ret (cdr ret)))))))
1183 (setq rest (cdr rest)))))
1185 (defun insert-char-range-data (min max &optional script excluded-script)
1188 (while (<= code max)
1189 (setq char (decode-char '=ucs code))
1190 (if (encode-char char '=ucs 'defined-only)
1191 (insert-char-data-with-variant char nil 'no-ucs-unified
1192 script excluded-script))
1193 (setq code (1+ code)))))
1195 (defun write-char-range-data-to-file (min max file
1196 &optional script excluded-script)
1197 (let ((coding-system-for-write char-db-file-coding-system))
1199 (insert (format ";; -*- coding: %s -*-\n"
1200 char-db-file-coding-system))
1201 (insert-char-range-data min max script excluded-script)
1202 (write-region (point-min)(point-max) file))))
1204 (defvar what-character-original-window-configuration)
1207 (defun what-char-definition (char)
1208 (interactive (list (char-after)))
1209 (let ((buf (get-buffer-create "*Character Description*"))
1210 (the-buf (current-buffer))
1211 (win-conf (current-window-configuration)))
1213 (make-local-variable 'what-character-original-window-configuration)
1214 (setq what-character-original-window-configuration win-conf)
1215 (setq buffer-read-only nil)
1219 (insert-char-data-with-variant char 'printable)
1220 (unless (char-attribute-alist char)
1221 (insert (format ";; = %c\n"
1222 (let* ((rest (split-char char))
1226 (setq code (logior (lsh code 8)
1228 (decode-char ccs code)))))
1229 ;; (char-db-update-comment)
1230 (set-buffer-modified-p nil)
1231 (view-mode the-buf (lambda (buf)
1232 (set-window-configuration
1233 what-character-original-window-configuration)
1235 (goto-char (point-min)))
1237 (set-window-configuration
1238 what-character-original-window-configuration)
1239 (signal (car err) (cdr err)))))))
1241 (provide 'char-db-util)
1243 ;;; char-db-util.el ends here