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-x0212 jis-x0213 cdp shinjigen 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) 1)
93 (if (<= (charset-id kb) 1)
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) 1)
105 (< (charset-id ka)(charset-id kb))))
111 (string< (symbol-name ka)
117 (defvar char-db-coded-charset-priority-list
132 japanese-jisx0208-1978
175 (defun char-db-make-char-spec (char)
177 (cond ((characterp char)
178 (cond ((and (setq ret (encode-char char '=ucs 'defined-only))
179 (not (and (<= #xE000 ret)(<= ret #xF8FF))))
180 (setq char-spec (list (cons '=ucs ret)))
181 (cond ((setq ret (get-char-attribute char 'name))
182 (setq char-spec (cons (cons 'name ret) char-spec))
184 ((setq ret (get-char-attribute char 'name*))
185 (setq char-spec (cons (cons 'name* ret) char-spec))
190 (let ((rest char-db-coded-charset-priority-list)
193 (setq ccs (charset-name
194 (find-charset (car rest))))
196 (encode-char char ccs
198 (throw 'tag (cons ccs ret)))
199 (setq rest (cdr rest))))))
200 (setq char-spec (list ret))
201 (dolist (ccs (delq (car ret) (charset-list)))
202 (if (and (or (charset-iso-final-char ccs)
208 (setq ret (encode-char char ccs 'defined-only)))
209 (setq char-spec (cons (cons ccs ret) char-spec))))
211 (setq char-spec (split-char char)))
212 (cond ((setq ret (get-char-attribute char 'name))
213 (setq char-spec (cons (cons 'name ret) char-spec))
215 ((setq ret (get-char-attribute char 'name*))
216 (setq char-spec (cons (cons 'name* ret) char-spec))
223 (defun char-db-insert-char-spec (char &optional readable column
226 (setq column (current-column)))
227 (let (char-spec temp-char)
228 (setq char-spec (char-db-make-char-spec char))
229 (unless (or (characterp char) ; char
231 (setq char (find-char char-spec))
233 ;; define temporary character
234 ;; Current implementation is dirty.
235 (setq temp-char (define-char (cons '(ideograph-daikanwa . 0)
237 (remove-char-attribute temp-char 'ideograph-daikanwa)
238 (setq char temp-char))
239 (insert-char-attributes char
241 (union (mapcar #'car char-spec)
244 ;; undefine temporary character
245 ;; Current implementation is dirty.
246 (setq char-spec (char-attribute-alist temp-char))
248 (remove-char-attribute temp-char (car (car char-spec)))
249 (setq char-spec (cdr char-spec))))))
251 (defun char-db-insert-alist (alist &optional readable column)
253 (setq column (current-column)))
255 (concat "\n" (make-string (1+ column) ?\ )))
259 lbs cell rest separator)
262 (setq name (car (car alist))
263 value (cdr (car alist)))
264 (cond ((eq name 'char)
266 (if (setq ret (condition-case nil
274 (setq key (car (car value)))
275 ;; (if (find-charset key)
276 ;; (setq cal (cons key cal))
277 (setq al (cons key al))
279 (setq value (cdr value)))
280 (insert-char-attributes ret
284 (insert (prin1-to-string value)))
286 (insert line-breaking))
288 (insert (format "(%-18s " name))
289 (setq lbs (concat "\n" (make-string (current-column) ?\ )))
291 (setq cell (car value))
292 (if (and (consp cell)
294 (setq ret (condition-case nil
304 (setq key (car (car rest)))
305 ;; (if (find-charset key)
306 ;; (setq cal (cons key cal))
307 (setq al (cons key al))
309 (setq rest (cdr rest)))
312 (insert-char-attributes ret
316 (setq separator lbs))
319 (insert (prin1-to-string cell))
320 (setq separator " "))
321 (setq value (cdr value)))
323 (insert line-breaking))
325 (insert (format "(%-18s . %S)%s"
328 (setq alist (cdr alist))))
331 (defun char-db-insert-char-reference (plist &optional readable column)
333 (setq column (current-column)))
335 (concat "\n" (make-string (1+ column) ?\ )))
340 (setq name (pop plist))
341 (setq value (pop plist))
342 (cond ((eq name :char)
345 (cond ((numberp value)
346 (setq value (decode-char '=ucs value)))
348 ;; (setq value (or (find-char value)
351 (char-db-insert-char-spec value readable)
352 (insert line-breaking)
355 (insert (format "%s%s\t%d ; %c%s"
358 (aref ideographic-radicals value)
362 (insert (format "%s%s\t%S" separator name value))
363 (setq separator line-breaking)))
367 (defun char-db-decode-isolated-char (ccs code-point)
370 (cond ((eq ccs 'arabic-iso8859-6)
371 (decode-char ccs code-point))
372 ((and (memq ccs '(=gt-pj-1
383 (setq ret (decode-char ccs code-point))
384 (setq ret (encode-char ret '=gt 'defined-only)))
385 (decode-builtin-char '=gt ret))
387 (decode-builtin-char ccs code-point))))
388 (cond ((and (<= 0 (char-int ret))
389 (<= (char-int ret) #x1F))
390 (decode-char '=ucs (+ #x2400 (char-int ret))))
391 ((= (char-int ret) #x7F)
395 (defvar char-db-convert-obsolete-format t)
397 (defun char-db-insert-ccs-feature (name value line-breaking)
400 (cond ((memq name '(=daikanwa
401 =daikanwa@rev1 =daikanwa@rev2
403 "(%-18s . %05d)\t; %c")
405 "(%-18s . %06d)\t; %c")
406 ((>= (charset-dimension name) 2)
407 "(%-18s . #x%04X)\t; %c")
409 "(%-18s . #x%02X)\t; %c"))
411 (if (= (charset-iso-graphic-plane name) 1)
413 (cond ((= (charset-dimension name) 1)
415 ((= (charset-dimension name) 2)
417 ((= (charset-dimension name) 3)
421 (char-db-decode-isolated-char name value)))
422 (if (and (= (charset-chars name) 94)
423 (= (charset-dimension name) 2))
424 (insert (format " [%02d-%02d]"
425 (- (lsh value -8) 32)
426 (- (logand value 255) 32))))
427 (insert line-breaking))
429 (defun insert-char-attributes (char &optional readable attributes column)
431 (setq column (current-column)))
432 (let (name value ; has-long-ccs-name
436 (concat "\n" (make-string (1+ column) ?\ )))
437 lbs cell separator ret
440 sources required-features
445 (if (consp attributes)
447 (dolist (name attributes)
448 (unless (memq name char-db-ignored-attributes)
449 (if (find-charset name)
453 (dolist (name (char-attribute-list))
454 (unless (memq name char-db-ignored-attributes)
455 (if (find-charset name)
459 #'char-attribute-name<)))
461 (when (and (memq 'name attributes)
462 (setq value (get-char-attribute char 'name)))
464 (if (> (+ (current-column) (length value)) 48)
467 value line-breaking))
468 (setq attributes (delq 'name attributes))
470 (when (and (memq 'name* attributes)
471 (setq value (get-char-attribute char 'name*)))
473 (if (> (+ (current-column) (length value)) 48)
476 value line-breaking))
477 (setq attributes (delq 'name* attributes))
479 (when (and (memq 'script attributes)
480 (setq value (get-char-attribute char 'script)))
481 (insert (format "(script\t\t%s)%s"
482 (mapconcat (function prin1-to-string)
485 (setq attributes (delq 'script attributes))
487 ;; (when (and (memq '<-denotational attributes)
488 ;; (setq value (get-char-attribute char '<-denotational))
489 ;; (null (cdr value))
490 ;; (setq value (encode-char (car value) 'ucs 'defined-only)))
491 ;; (insert (format "(%-18s . #x%04X)\t; %c%s"
492 ;; '=>ucs value (decode-char 'ucs value)
494 ;; (setq attributes (delq '<-denotational attributes)))
495 (dolist (name '(=>ucs =>ucs*))
496 (when (and (memq name attributes)
497 (setq value (get-char-attribute char name)))
498 (insert (format "(%-18s . #x%04X)\t; %c%s"
499 name value (decode-char '=ucs value)
501 (setq attributes (delq name attributes))))
502 (dolist (name '(=>ucs@gb =>ucs@cns =>ucs@jis =>ucs@ks =>ucs@big5))
503 (when (and (memq name attributes)
504 (setq value (get-char-attribute char name)))
505 (insert (format "(%-18s . #x%04X)\t; %c%s"
510 (symbol-name name) 2)))
513 (setq attributes (delq name attributes))
515 (dolist (name '(=>daikanwa))
516 (when (and (memq name attributes)
517 (setq value (get-char-attribute char name)))
520 (format "(%-18s . %05d)\t; %c%s"
521 name value (decode-char '=daikanwa value)
523 (format "(%-18s %s)\t; %c%s"
525 (mapconcat (function prin1-to-string)
527 (char-representative-of-daikanwa char)
529 (setq attributes (delq name attributes))))
530 (when (and (memq 'general-category attributes)
531 (setq value (get-char-attribute char 'general-category)))
533 "(general-category\t%s) ; %s%s"
534 (mapconcat (lambda (cell)
537 (cond ((rassoc value unidata-normative-category-alist)
538 "Normative Category")
539 ((rassoc value unidata-informative-category-alist)
540 "Informative Category")
544 (setq attributes (delq 'general-category attributes))
546 (when (and (memq 'bidi-category attributes)
547 (setq value (get-char-attribute char 'bidi-category)))
548 (insert (format "(bidi-category\t. %S)%s"
551 (setq attributes (delq 'bidi-category attributes))
553 (unless (or (not (memq 'mirrored attributes))
554 (eq (setq value (get-char-attribute char 'mirrored 'empty))
556 (insert (format "(mirrored\t\t. %S)%s"
559 (setq attributes (delq 'mirrored attributes))
562 ((and (memq 'decimal-digit-value attributes)
563 (setq value (get-char-attribute char 'decimal-digit-value)))
564 (insert (format "(decimal-digit-value . %S)%s"
567 (setq attributes (delq 'decimal-digit-value attributes))
568 (when (and (memq 'digit-value attributes)
569 (setq value (get-char-attribute char 'digit-value)))
570 (insert (format "(digit-value\t . %S)%s"
573 (setq attributes (delq 'digit-value attributes))
575 (when (and (memq 'numeric-value attributes)
576 (setq value (get-char-attribute char 'numeric-value)))
577 (insert (format "(numeric-value\t . %S)%s"
580 (setq attributes (delq 'numeric-value attributes))
584 (when (and (memq 'digit-value attributes)
585 (setq value (get-char-attribute char 'digit-value)))
586 (insert (format "(digit-value\t. %S)%s"
589 (setq attributes (delq 'digit-value attributes))
591 (when (and (memq 'numeric-value attributes)
592 (setq value (get-char-attribute char 'numeric-value)))
593 (insert (format "(numeric-value\t. %S)%s"
596 (setq attributes (delq 'numeric-value attributes))
598 (when (and (memq 'iso-10646-comment attributes)
599 (setq value (get-char-attribute char 'iso-10646-comment)))
600 (insert (format "(iso-10646-comment\t. %S)%s"
603 (setq attributes (delq 'iso-10646-comment attributes))
605 (when (and (memq 'morohashi-daikanwa attributes)
606 (setq value (get-char-attribute char 'morohashi-daikanwa)))
607 (insert (format "(morohashi-daikanwa\t%s)%s"
608 (mapconcat (function prin1-to-string) value " ")
610 (setq attributes (delq 'morohashi-daikanwa attributes))
614 (when (and (memq 'ideographic-radical attributes)
615 (setq value (get-char-attribute char 'ideographic-radical)))
617 (insert (format "(ideographic-radical . %S)\t; %c%s"
619 (aref ideographic-radicals radical)
621 (setq attributes (delq 'ideographic-radical attributes))
626 char-db-feature-domains
628 (dolist (feature (char-attribute-list))
629 (setq feature (symbol-name feature))
631 "\\(radical\\|strokes\\)@\\([^@*]+\\)\\(\\*\\|$\\)"
633 (setq domain (intern (match-string 2 feature)))
634 (unless (memq domain dest)
635 (setq dest (cons domain dest)))))
636 (sort dest #'string<))))
637 (setq key (intern (format "%s@%s" 'ideographic-radical domain)))
638 (when (and (memq key attributes)
639 (setq value (get-char-attribute char key)))
641 (insert (format "(%s . %S)\t; %c%s"
644 (aref ideographic-radicals radical)
646 (setq attributes (delq key attributes))
648 (setq key (intern (format "%s@%s" 'ideographic-strokes domain)))
649 (when (and (memq key attributes)
650 (setq value (get-char-attribute char key)))
652 (insert (format "(%s . %S)%s"
656 (setq attributes (delq key attributes))
658 (setq key (intern (format "%s@%s" 'total-strokes domain)))
659 (when (and (memq key attributes)
660 (setq value (get-char-attribute char key)))
661 (insert (format "(%s . %S)%s"
665 (setq attributes (delq key attributes))
667 (dolist (feature '(ideographic-radical
670 (setq key (intern (format "%s@%s*sources" feature domain)))
671 (when (and (memq key attributes)
672 (setq value (get-char-attribute char key)))
673 (insert (format "(%s%s" key line-breaking))
675 (insert (format " %s" cell)))
677 (insert line-breaking)
678 (setq attributes (delq key attributes))
681 (when (and (memq 'ideographic-strokes attributes)
682 (setq value (get-char-attribute char 'ideographic-strokes)))
684 (insert (format "(ideographic-strokes . %S)%s"
687 (setq attributes (delq 'ideographic-strokes attributes))
689 (when (and (memq 'kangxi-radical attributes)
690 (setq value (get-char-attribute char 'kangxi-radical)))
691 (unless (eq value radical)
692 (insert (format "(kangxi-radical\t . %S)\t; %c%s"
694 (aref ideographic-radicals value)
697 (setq radical value)))
698 (setq attributes (delq 'kangxi-radical attributes))
700 (when (and (memq 'kangxi-strokes attributes)
701 (setq value (get-char-attribute char 'kangxi-strokes)))
702 (unless (eq value strokes)
703 (insert (format "(kangxi-strokes\t . %S)%s"
707 (setq strokes value)))
708 (setq attributes (delq 'kangxi-strokes attributes))
710 (when (and (memq 'japanese-radical attributes)
711 (setq value (get-char-attribute char 'japanese-radical)))
712 (unless (eq value radical)
713 (insert (format "(japanese-radical\t . %S)\t; %c%s"
715 (aref ideographic-radicals value)
718 (setq radical value)))
719 (setq attributes (delq 'japanese-radical attributes))
721 (when (and (memq 'japanese-strokes attributes)
722 (setq value (get-char-attribute char 'japanese-strokes)))
723 (unless (eq value strokes)
724 (insert (format "(japanese-strokes\t . %S)%s"
728 (setq strokes value)))
729 (setq attributes (delq 'japanese-strokes attributes))
731 (when (and (memq 'cns-radical attributes)
732 (setq value (get-char-attribute char 'cns-radical)))
733 (insert (format "(cns-radical\t . %S)\t; %c%s"
735 (aref ideographic-radicals value)
737 (setq attributes (delq 'cns-radical attributes))
739 (when (and (memq 'cns-strokes attributes)
740 (setq value (get-char-attribute char 'cns-strokes)))
741 (unless (eq value strokes)
742 (insert (format "(cns-strokes\t . %S)%s"
746 (setq strokes value)))
747 (setq attributes (delq 'cns-strokes attributes))
749 (when (and (memq 'shinjigen-1-radical attributes)
750 (setq value (get-char-attribute char 'shinjigen-1-radical)))
751 (unless (eq value radical)
752 (insert (format "(shinjigen-1-radical . %S)\t; %c%s"
754 (aref ideographic-radicals value)
757 (setq radical value)))
758 (setq attributes (delq 'shinjigen-1-radical attributes))
760 (when (and (memq 'ideographic- attributes)
761 (setq value (get-char-attribute char 'ideographic-)))
762 (insert "(ideographic- ")
763 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
766 (setq cell (car value))
768 (setq cell (decode-char '=ucs cell)))
769 (cond ((characterp cell)
773 (insert (format "%S" cell))
774 (char-db-insert-char-spec cell readable))
775 (setq separator lbs))
779 (if (consp (car cell))
780 (char-db-insert-char-spec cell readable)
781 (char-db-insert-char-reference cell readable))
782 (setq separator lbs))
786 (insert (prin1-to-string cell))
787 (setq separator " ")))
788 (setq value (cdr value)))
790 (insert line-breaking)
791 (setq attributes (delq 'ideographic- attributes)))
792 (when (and (memq 'total-strokes attributes)
793 (setq value (get-char-attribute char 'total-strokes)))
794 (insert (format "(total-strokes . %S)%s"
797 (setq attributes (delq 'total-strokes attributes))
799 (when (and (memq '->ideograph attributes)
800 (setq value (get-char-attribute char '->ideograph)))
801 (insert (format "(->ideograph\t%s)%s"
802 (mapconcat (lambda (code)
803 (cond ((symbolp code)
806 (format "#x%04X" code))
809 line-breaking code))))
812 (setq attributes (delq '->ideograph attributes))
814 (when (and (memq '->decomposition attributes)
815 (setq value (get-char-attribute char '->decomposition)))
816 (insert (format "(->decomposition\t%s)%s"
817 (mapconcat (lambda (code)
818 (cond ((symbolp code)
827 (format "#x%04X" code))
829 (format "%s%S" line-breaking code))))
832 (setq attributes (delq '->decomposition attributes))
834 (if (equal (get-char-attribute char '->titlecase)
835 (get-char-attribute char '->uppercase))
836 (setq attributes (delq '->titlecase attributes)))
837 (when (and (memq '->mojikyo attributes)
838 (setq value (get-char-attribute char '->mojikyo)))
839 (insert (format "(->mojikyo\t\t. %06d)\t; %c%s"
840 value (decode-char 'mojikyo value)
842 (setq attributes (delq '->mojikyo attributes))
844 (when (and (memq 'hanyu-dazidian-vol attributes)
845 (setq value (get-char-attribute char 'hanyu-dazidian-vol)))
846 (insert (format "(hanyu-dazidian-vol . %d)%s"
847 value line-breaking))
848 (setq attributes (delq 'hanyu-dazidian-vol attributes))
850 (when (and (memq 'hanyu-dazidian-page attributes)
851 (setq value (get-char-attribute char 'hanyu-dazidian-page)))
852 (insert (format "(hanyu-dazidian-page . %d)%s"
853 value line-breaking))
854 (setq attributes (delq 'hanyu-dazidian-page attributes))
856 (when (and (memq 'hanyu-dazidian-char attributes)
857 (setq value (get-char-attribute char 'hanyu-dazidian-char)))
858 (insert (format "(hanyu-dazidian-char . %d)%s"
859 value line-breaking))
860 (setq attributes (delq 'hanyu-dazidian-char attributes))
863 (dolist (ignored '(composition
864 ->denotational <-subsumptive ->ucs-unified
865 ->ideographic-component-forms))
866 (setq attributes (delq ignored attributes))))
868 (setq name (car attributes))
869 (if (setq value (get-char-attribute char name))
870 (cond ((setq ret (find-charset name))
871 (setq name (charset-name ret))
872 (if (and (not (memq name dest-ccss))
874 (setq value (get-char-attribute char name))
875 (setq dest-ccss (cons name dest-ccss))))
876 (char-db-insert-ccs-feature name value line-breaking))
878 ((string-match "^=>ucs@" (symbol-name name))
879 (insert (format "(%-18s . #x%04X)\t; %c%s"
880 name value (decode-char '=ucs value)
883 ((eq name 'jisx0208-1978/4X)
884 (insert (format "(%-18s . #x%04X)%s"
889 (null (get-char-attribute
891 (intern (format "%s*sources" name))))
892 (not (string-match "\\*sources$" (symbol-name name)))
893 (or (eq name '<-identical)
894 (string-match "^->halfwidth" (symbol-name name))
896 (string-match "^->fullwidth" (symbol-name name))
899 (characterp (car value))
901 (car value) '=ucs 'defined-only))))
902 (string-match "^->simplified" (symbol-name name))
903 (string-match "^->vulgar" (symbol-name name))
904 (string-match "^->wrong" (symbol-name name))
905 (string-match "^->same" (symbol-name name))
906 (string-match "^->original" (symbol-name name))
907 (string-match "^->ancient" (symbol-name name))
910 ((or (eq name 'ideographic-structure)
911 (eq name 'ideographic-)
912 (string-match "^\\(->\\|<-\\)" (symbol-name name)))
913 (insert (format "(%-18s%s " name line-breaking))
914 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
917 (setq cell (car value))
919 (setq cell (decode-char '=ucs cell)))
920 (cond ((eq name '->subsumptive)
923 (get-char-attribute cell atr))
924 char-db-ignored-attributes))
926 (encode-char cell ccs
931 (let ((char-db-ignored-attributes
933 char-db-ignored-attributes)))
934 (insert-char-attributes cell readable))
935 (setq separator lbs))
941 (intern (format "%s*sources" name))))
942 (setq required-features nil)
943 (dolist (source sources)
945 ((memq source '(JP JP/Jouyou
947 (setq required-features
948 (union required-features
957 (setq required-features
958 (union required-features
964 (setq ret (intern (format "=%s" source))))
965 (setq required-features
966 (cons ret required-features)))
967 (t (setq required-features
968 (cons source required-features)))))
969 (cond ((string-match "@JP" (symbol-name name))
970 (setq required-features
971 (union required-features
979 ((string-match "@CN" (symbol-name name))
980 (setq required-features
981 (union required-features
988 (insert (format "%S" cell))
989 (char-db-insert-char-spec cell readable
992 (setq separator lbs))
996 (if (consp (car cell))
997 (char-db-insert-char-spec cell readable)
998 (char-db-insert-char-reference cell readable))
999 (setq separator lbs))
1003 (insert (prin1-to-string cell))
1004 (setq separator " ")))
1005 (setq value (cdr value)))
1007 (insert line-breaking))
1008 ((memq name '(ideograph=
1009 original-ideograph-of
1010 ancient-ideograph-of
1013 ;; simplified-ideograph-of
1014 ideographic-variants
1015 ;; ideographic-different-form-of
1017 (insert (format "(%-18s%s " name line-breaking))
1018 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
1020 (while (consp value)
1021 (setq cell (car value))
1022 (if (and (consp cell)
1027 (char-db-insert-alist cell readable)
1028 (setq separator lbs))
1031 (insert (prin1-to-string cell))
1032 (setq separator " "))
1033 (setq value (cdr value)))
1035 (insert line-breaking))
1037 (insert (format "(%-18s " name))
1038 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
1040 (while (consp value)
1041 (setq cell (car value))
1042 (if (and (consp cell)
1044 (setq ret (condition-case nil
1052 (setq key (car (car rest)))
1053 (if (find-charset key)
1054 (setq cal (cons key cal))
1055 (setq al (cons key al)))
1056 (setq rest (cdr rest)))
1059 (insert-char-attributes ret
1062 (setq separator lbs))
1063 (setq ret (prin1-to-string cell))
1065 (if (< (+ (current-column)
1072 (setq separator " "))
1073 (setq value (cdr value)))
1075 (insert line-breaking))
1077 (insert (format "(%-18s . %S)%s"
1081 (setq attributes (cdr attributes)))
1084 (defun insert-char-data (char &optional readable
1087 (narrow-to-region (point)(point))
1088 (insert "(define-char
1090 (insert-char-attributes char readable attributes)
1092 (goto-char (point-min))
1093 (while (re-search-forward "[ \t]+$" nil t)
1096 (goto-char (point-min))
1097 (while (re-search-forward "[ \t][ \t][ \t]*" nil t)
1098 (let ((column (current-column))
1099 (indent-tabs-mode t))
1100 (delete-region (match-beginning 0) (point))
1101 (indent-to column)))
1102 (goto-char (point-max))
1103 ;; (tabify (point-min)(point-max))
1106 (defun insert-char-data-with-variant (char &optional printable
1108 script excluded-script)
1109 (insert-char-data char printable)
1110 (let ((variants (or (char-variants char)
1111 (let ((ucs (get-char-attribute char '->ucs)))
1113 (delete char (char-variants (int-char ucs)))))))
1115 (setq variants (sort variants #'<))
1117 (setq variant (car variants))
1118 (unless (get-char-attribute variant '<-subsumptive)
1119 (if (and (or (null script)
1120 (null (setq vs (get-char-attribute variant 'script)))
1122 (or (null excluded-script)
1123 (null (setq vs (get-char-attribute variant 'script)))
1124 (not (memq excluded-script vs))))
1125 (unless (and no-ucs-unified (get-char-attribute variant '=ucs))
1126 (insert-char-data variant printable)
1127 (if (setq ret (char-variants variant))
1129 (or (memq (car ret) variants)
1130 ;; (get-char-attribute (car ret) '<-subsumptive)
1131 (setq variants (append variants (list (car ret)))))
1132 (setq ret (cdr ret)))))))
1133 (setq variants (cdr variants)))))
1135 (defun insert-char-range-data (min max &optional script excluded-script)
1138 (while (<= code max)
1139 (setq char (decode-char '=ucs code))
1140 (if (encode-char char '=ucs 'defined-only)
1141 (insert-char-data-with-variant char nil 'no-ucs-unified
1142 script excluded-script))
1143 (setq code (1+ code)))))
1145 (defun write-char-range-data-to-file (min max file
1146 &optional script excluded-script)
1147 (let ((coding-system-for-write char-db-file-coding-system))
1149 (insert (format ";; -*- coding: %s -*-\n"
1150 char-db-file-coding-system))
1151 (insert-char-range-data min max script excluded-script)
1152 (write-region (point-min)(point-max) file))))
1154 (defvar what-character-original-window-configuration)
1157 (defun what-char-definition (char)
1158 (interactive (list (char-after)))
1159 (let ((buf (get-buffer-create "*Character Description*"))
1160 (the-buf (current-buffer))
1161 (win-conf (current-window-configuration)))
1163 (make-local-variable 'what-character-original-window-configuration)
1164 (setq what-character-original-window-configuration win-conf)
1165 (setq buffer-read-only nil)
1169 (insert-char-data-with-variant char 'printable)
1170 (unless (char-attribute-alist char)
1171 (insert (format ";; = %c\n"
1172 (let* ((rest (split-char char))
1176 (setq code (logior (lsh code 8)
1178 (decode-char ccs code)))))
1179 ;; (char-db-update-comment)
1180 (set-buffer-modified-p nil)
1181 (view-mode the-buf (lambda (buf)
1182 (set-window-configuration
1183 what-character-original-window-configuration)
1185 (goto-char (point-min)))
1187 (set-window-configuration
1188 what-character-original-window-configuration)
1189 (signal (car err) (cdr err)))))))
1191 (provide 'char-db-util)
1193 ;;; char-db-util.el ends here