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
174 (defun char-db-make-char-spec (char)
176 (cond ((characterp char)
177 (cond ((and (setq ret (encode-char char '=ucs 'defined-only))
178 (not (and (<= #xE000 ret)(<= ret #xF8FF))))
179 (setq char-spec (list (cons '=ucs ret)))
180 (cond ((setq ret (get-char-attribute char 'name))
181 (setq char-spec (cons (cons 'name ret) char-spec))
183 ((setq ret (get-char-attribute char 'name*))
184 (setq char-spec (cons (cons 'name* ret) char-spec))
189 (let ((rest char-db-coded-charset-priority-list)
192 (setq ccs (charset-name
193 (find-charset (car rest))))
195 (encode-char char ccs
197 (throw 'tag (cons ccs ret)))
198 (setq rest (cdr rest))))))
199 (setq char-spec (list ret))
200 (dolist (ccs (delq (car ret) (charset-list)))
201 (if (and (or (charset-iso-final-char ccs)
207 (setq ret (encode-char char ccs 'defined-only)))
208 (setq char-spec (cons (cons ccs ret) char-spec))))
210 (setq char-spec (split-char char)))
211 (cond ((setq ret (get-char-attribute char 'name))
212 (setq char-spec (cons (cons 'name ret) char-spec))
214 ((setq ret (get-char-attribute char 'name*))
215 (setq char-spec (cons (cons 'name* ret) char-spec))
222 (defun char-db-insert-char-spec (char &optional readable column
225 (setq column (current-column)))
226 (let (char-spec temp-char)
227 (setq char-spec (char-db-make-char-spec char))
228 (unless (or (characterp char) ; char
230 (setq char (find-char char-spec))
232 ;; define temporary character
233 ;; Current implementation is dirty.
234 (setq temp-char (define-char (cons '(ideograph-daikanwa . 0)
236 (remove-char-attribute temp-char 'ideograph-daikanwa)
237 (setq char temp-char))
238 (insert-char-attributes char
240 (union (mapcar #'car char-spec)
243 ;; undefine temporary character
244 ;; Current implementation is dirty.
245 (setq char-spec (char-attribute-alist temp-char))
247 (remove-char-attribute temp-char (car (car char-spec)))
248 (setq char-spec (cdr char-spec))))))
250 (defun char-db-insert-alist (alist &optional readable column)
252 (setq column (current-column)))
254 (concat "\n" (make-string (1+ column) ?\ )))
258 lbs cell rest separator)
261 (setq name (car (car alist))
262 value (cdr (car alist)))
263 (cond ((eq name 'char)
265 (if (setq ret (condition-case nil
273 (setq key (car (car value)))
274 ;; (if (find-charset key)
275 ;; (setq cal (cons key cal))
276 (setq al (cons key al))
278 (setq value (cdr value)))
279 (insert-char-attributes ret
283 (insert (prin1-to-string value)))
285 (insert line-breaking))
287 (insert (format "(%-18s " name))
288 (setq lbs (concat "\n" (make-string (current-column) ?\ )))
290 (setq cell (car value))
291 (if (and (consp cell)
293 (setq ret (condition-case nil
303 (setq key (car (car rest)))
304 ;; (if (find-charset key)
305 ;; (setq cal (cons key cal))
306 (setq al (cons key al))
308 (setq rest (cdr rest)))
311 (insert-char-attributes ret
315 (setq separator lbs))
318 (insert (prin1-to-string cell))
319 (setq separator " "))
320 (setq value (cdr value)))
322 (insert line-breaking))
324 (insert (format "(%-18s . %S)%s"
327 (setq alist (cdr alist))))
330 (defun char-db-insert-char-reference (plist &optional readable column)
332 (setq column (current-column)))
334 (concat "\n" (make-string (1+ column) ?\ )))
339 (setq name (pop plist))
340 (setq value (pop plist))
341 (cond ((eq name :char)
344 (cond ((numberp value)
345 (setq value (decode-char '=ucs value)))
347 ;; (setq value (or (find-char value)
350 (char-db-insert-char-spec value readable)
351 (insert line-breaking)
354 (insert (format "%s%s\t%d ; %c%s"
357 (aref ideographic-radicals value)
361 (insert (format "%s%s\t%S" separator name value))
362 (setq separator line-breaking)))
366 (defun char-db-decode-isolated-char (ccs code-point)
369 (cond ((eq ccs 'arabic-iso8859-6)
370 (decode-char ccs code-point))
371 ((and (memq ccs '(=gt-pj-1
382 (setq ret (decode-char ccs code-point))
383 (setq ret (encode-char ret '=gt 'defined-only)))
384 (decode-builtin-char '=gt ret))
386 (decode-builtin-char ccs code-point))))
387 (cond ((and (<= 0 (char-int ret))
388 (<= (char-int ret) #x1F))
389 (decode-char '=ucs (+ #x2400 (char-int ret))))
390 ((= (char-int ret) #x7F)
394 (defvar char-db-convert-obsolete-format t)
396 (defun char-db-insert-ccs-feature (name value line-breaking)
399 (cond ((memq name '(=daikanwa
400 =daikanwa@rev1 =daikanwa@rev2
402 "(%-18s . %05d)\t; %c")
404 "(%-18s . %06d)\t; %c")
405 ((>= (charset-dimension name) 2)
406 "(%-18s . #x%04X)\t; %c")
408 "(%-18s . #x%02X)\t; %c"))
410 (if (= (charset-iso-graphic-plane name) 1)
412 (cond ((= (charset-dimension name) 1)
414 ((= (charset-dimension name) 2)
416 ((= (charset-dimension name) 3)
420 (char-db-decode-isolated-char name value)))
421 (if (and (= (charset-chars name) 94)
422 (= (charset-dimension name) 2))
423 (insert (format " [%02d-%02d]"
424 (- (lsh value -8) 32)
425 (- (logand value 255) 32))))
426 (insert line-breaking))
428 (defun insert-char-attributes (char &optional readable attributes column)
430 (setq column (current-column)))
431 (let (name value ; has-long-ccs-name
435 (concat "\n" (make-string (1+ column) ?\ )))
436 lbs cell separator ret
439 sources required-features
444 (if (consp attributes)
446 (dolist (name attributes)
447 (unless (memq name char-db-ignored-attributes)
448 (if (find-charset name)
452 (dolist (name (char-attribute-list))
453 (unless (memq name char-db-ignored-attributes)
454 (if (find-charset name)
458 #'char-attribute-name<)))
460 (when (and (memq 'name attributes)
461 (setq value (get-char-attribute char 'name)))
463 (if (> (+ (current-column) (length value)) 48)
466 value line-breaking))
467 (setq attributes (delq 'name attributes))
469 (when (and (memq 'name* attributes)
470 (setq value (get-char-attribute char 'name*)))
472 (if (> (+ (current-column) (length value)) 48)
475 value line-breaking))
476 (setq attributes (delq 'name* attributes))
478 (when (and (memq 'script attributes)
479 (setq value (get-char-attribute char 'script)))
480 (insert (format "(script\t\t%s)%s"
481 (mapconcat (function prin1-to-string)
484 (setq attributes (delq 'script attributes))
486 ;; (when (and (memq '<-denotational attributes)
487 ;; (setq value (get-char-attribute char '<-denotational))
488 ;; (null (cdr value))
489 ;; (setq value (encode-char (car value) 'ucs 'defined-only)))
490 ;; (insert (format "(%-18s . #x%04X)\t; %c%s"
491 ;; '=>ucs value (decode-char 'ucs value)
493 ;; (setq attributes (delq '<-denotational attributes)))
494 (dolist (name '(=>ucs =>ucs*))
495 (when (and (memq name attributes)
496 (setq value (get-char-attribute char name)))
497 (insert (format "(%-18s . #x%04X)\t; %c%s"
498 name value (decode-char '=ucs value)
500 (setq attributes (delq name attributes))))
501 (dolist (name '(=>ucs@gb =>ucs@cns =>ucs@jis =>ucs@ks =>ucs@big5))
502 (when (and (memq name attributes)
503 (setq value (get-char-attribute char name)))
504 (insert (format "(%-18s . #x%04X)\t; %c%s"
509 (symbol-name name) 2)))
512 (setq attributes (delq name attributes))
514 (dolist (name '(=>daikanwa))
515 (when (and (memq name attributes)
516 (setq value (get-char-attribute char name)))
519 (format "(%-18s . %05d)\t; %c%s"
520 name value (decode-char '=daikanwa value)
522 (format "(%-18s %s)\t; %c%s"
524 (mapconcat (function prin1-to-string)
526 (char-representative-of-daikanwa char)
528 (setq attributes (delq name attributes))))
529 (when (and (memq 'general-category attributes)
530 (setq value (get-char-attribute char 'general-category)))
532 "(general-category\t%s) ; %s%s"
533 (mapconcat (lambda (cell)
536 (cond ((rassoc value unidata-normative-category-alist)
537 "Normative Category")
538 ((rassoc value unidata-informative-category-alist)
539 "Informative Category")
543 (setq attributes (delq 'general-category attributes))
545 (when (and (memq 'bidi-category attributes)
546 (setq value (get-char-attribute char 'bidi-category)))
547 (insert (format "(bidi-category\t. %S)%s"
550 (setq attributes (delq 'bidi-category attributes))
552 (unless (or (not (memq 'mirrored attributes))
553 (eq (setq value (get-char-attribute char 'mirrored 'empty))
555 (insert (format "(mirrored\t\t. %S)%s"
558 (setq attributes (delq 'mirrored attributes))
561 ((and (memq 'decimal-digit-value attributes)
562 (setq value (get-char-attribute char 'decimal-digit-value)))
563 (insert (format "(decimal-digit-value . %S)%s"
566 (setq attributes (delq 'decimal-digit-value attributes))
567 (when (and (memq 'digit-value attributes)
568 (setq value (get-char-attribute char 'digit-value)))
569 (insert (format "(digit-value\t . %S)%s"
572 (setq attributes (delq 'digit-value attributes))
574 (when (and (memq 'numeric-value attributes)
575 (setq value (get-char-attribute char 'numeric-value)))
576 (insert (format "(numeric-value\t . %S)%s"
579 (setq attributes (delq 'numeric-value attributes))
583 (when (and (memq 'digit-value attributes)
584 (setq value (get-char-attribute char 'digit-value)))
585 (insert (format "(digit-value\t. %S)%s"
588 (setq attributes (delq 'digit-value attributes))
590 (when (and (memq 'numeric-value attributes)
591 (setq value (get-char-attribute char 'numeric-value)))
592 (insert (format "(numeric-value\t. %S)%s"
595 (setq attributes (delq 'numeric-value attributes))
597 (when (and (memq 'iso-10646-comment attributes)
598 (setq value (get-char-attribute char 'iso-10646-comment)))
599 (insert (format "(iso-10646-comment\t. %S)%s"
602 (setq attributes (delq 'iso-10646-comment attributes))
604 (when (and (memq 'morohashi-daikanwa attributes)
605 (setq value (get-char-attribute char 'morohashi-daikanwa)))
606 (insert (format "(morohashi-daikanwa\t%s)%s"
607 (mapconcat (function prin1-to-string) value " ")
609 (setq attributes (delq 'morohashi-daikanwa attributes))
613 (when (and (memq 'ideographic-radical attributes)
614 (setq value (get-char-attribute char 'ideographic-radical)))
616 (insert (format "(ideographic-radical . %S)\t; %c%s"
618 (aref ideographic-radicals radical)
620 (setq attributes (delq 'ideographic-radical attributes))
625 char-db-feature-domains
627 (dolist (feature (char-attribute-list))
628 (setq feature (symbol-name feature))
630 "\\(radical\\|strokes\\)@\\([^@*]+\\)\\(\\*\\|$\\)"
632 (setq domain (intern (match-string 2 feature)))
633 (unless (memq domain dest)
634 (setq dest (cons domain dest)))))
635 (sort dest #'string<))))
636 (setq key (intern (format "%s@%s" 'ideographic-radical domain)))
637 (when (and (memq key attributes)
638 (setq value (get-char-attribute char key)))
640 (insert (format "(%s . %S)\t; %c%s"
643 (aref ideographic-radicals radical)
645 (setq attributes (delq key attributes))
647 (setq key (intern (format "%s@%s" 'ideographic-strokes domain)))
648 (when (and (memq key attributes)
649 (setq value (get-char-attribute char key)))
651 (insert (format "(%s . %S)%s"
655 (setq attributes (delq key attributes))
657 (setq key (intern (format "%s@%s" 'total-strokes domain)))
658 (when (and (memq key attributes)
659 (setq value (get-char-attribute char key)))
660 (insert (format "(%s . %S)%s"
664 (setq attributes (delq key attributes))
666 (dolist (feature '(ideographic-radical
669 (setq key (intern (format "%s@%s*sources" feature domain)))
670 (when (and (memq key attributes)
671 (setq value (get-char-attribute char key)))
672 (insert (format "(%s%s" key line-breaking))
674 (insert (format " %s" cell)))
676 (insert line-breaking)
677 (setq attributes (delq key attributes))
680 (when (and (memq 'ideographic-strokes attributes)
681 (setq value (get-char-attribute char 'ideographic-strokes)))
683 (insert (format "(ideographic-strokes . %S)%s"
686 (setq attributes (delq 'ideographic-strokes attributes))
688 (when (and (memq 'kangxi-radical attributes)
689 (setq value (get-char-attribute char 'kangxi-radical)))
690 (unless (eq value radical)
691 (insert (format "(kangxi-radical\t . %S)\t; %c%s"
693 (aref ideographic-radicals value)
696 (setq radical value)))
697 (setq attributes (delq 'kangxi-radical attributes))
699 (when (and (memq 'kangxi-strokes attributes)
700 (setq value (get-char-attribute char 'kangxi-strokes)))
701 (unless (eq value strokes)
702 (insert (format "(kangxi-strokes\t . %S)%s"
706 (setq strokes value)))
707 (setq attributes (delq 'kangxi-strokes attributes))
709 (when (and (memq 'japanese-radical attributes)
710 (setq value (get-char-attribute char 'japanese-radical)))
711 (unless (eq value radical)
712 (insert (format "(japanese-radical\t . %S)\t; %c%s"
714 (aref ideographic-radicals value)
717 (setq radical value)))
718 (setq attributes (delq 'japanese-radical attributes))
720 (when (and (memq 'japanese-strokes attributes)
721 (setq value (get-char-attribute char 'japanese-strokes)))
722 (unless (eq value strokes)
723 (insert (format "(japanese-strokes\t . %S)%s"
727 (setq strokes value)))
728 (setq attributes (delq 'japanese-strokes attributes))
730 (when (and (memq 'cns-radical attributes)
731 (setq value (get-char-attribute char 'cns-radical)))
732 (insert (format "(cns-radical\t . %S)\t; %c%s"
734 (aref ideographic-radicals value)
736 (setq attributes (delq 'cns-radical attributes))
738 (when (and (memq 'cns-strokes attributes)
739 (setq value (get-char-attribute char 'cns-strokes)))
740 (unless (eq value strokes)
741 (insert (format "(cns-strokes\t . %S)%s"
745 (setq strokes value)))
746 (setq attributes (delq 'cns-strokes attributes))
748 (when (and (memq 'shinjigen-1-radical attributes)
749 (setq value (get-char-attribute char 'shinjigen-1-radical)))
750 (unless (eq value radical)
751 (insert (format "(shinjigen-1-radical . %S)\t; %c%s"
753 (aref ideographic-radicals value)
756 (setq radical value)))
757 (setq attributes (delq 'shinjigen-1-radical attributes))
759 (when (and (memq 'ideographic- attributes)
760 (setq value (get-char-attribute char 'ideographic-)))
761 (insert "(ideographic- ")
762 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
765 (setq cell (car value))
767 (setq cell (decode-char '=ucs cell)))
768 (cond ((characterp cell)
772 (insert (format "%S" cell))
773 (char-db-insert-char-spec cell readable))
774 (setq separator lbs))
778 (if (consp (car cell))
779 (char-db-insert-char-spec cell readable)
780 (char-db-insert-char-reference cell readable))
781 (setq separator lbs))
785 (insert (prin1-to-string cell))
786 (setq separator " ")))
787 (setq value (cdr value)))
789 (insert line-breaking)
790 (setq attributes (delq 'ideographic- attributes)))
791 (when (and (memq 'total-strokes attributes)
792 (setq value (get-char-attribute char 'total-strokes)))
793 (insert (format "(total-strokes . %S)%s"
796 (setq attributes (delq 'total-strokes attributes))
798 (when (and (memq '->ideograph attributes)
799 (setq value (get-char-attribute char '->ideograph)))
800 (insert (format "(->ideograph\t%s)%s"
801 (mapconcat (lambda (code)
802 (cond ((symbolp code)
805 (format "#x%04X" code))
808 line-breaking code))))
811 (setq attributes (delq '->ideograph attributes))
813 (when (and (memq '->decomposition attributes)
814 (setq value (get-char-attribute char '->decomposition)))
815 (insert (format "(->decomposition\t%s)%s"
816 (mapconcat (lambda (code)
817 (cond ((symbolp code)
826 (format "#x%04X" code))
828 (format "%s%S" line-breaking code))))
831 (setq attributes (delq '->decomposition attributes))
833 (if (equal (get-char-attribute char '->titlecase)
834 (get-char-attribute char '->uppercase))
835 (setq attributes (delq '->titlecase attributes)))
836 (when (and (memq '->mojikyo attributes)
837 (setq value (get-char-attribute char '->mojikyo)))
838 (insert (format "(->mojikyo\t\t. %06d)\t; %c%s"
839 value (decode-char 'mojikyo value)
841 (setq attributes (delq '->mojikyo attributes))
843 (when (and (memq 'hanyu-dazidian-vol attributes)
844 (setq value (get-char-attribute char 'hanyu-dazidian-vol)))
845 (insert (format "(hanyu-dazidian-vol . %d)%s"
846 value line-breaking))
847 (setq attributes (delq 'hanyu-dazidian-vol attributes))
849 (when (and (memq 'hanyu-dazidian-page attributes)
850 (setq value (get-char-attribute char 'hanyu-dazidian-page)))
851 (insert (format "(hanyu-dazidian-page . %d)%s"
852 value line-breaking))
853 (setq attributes (delq 'hanyu-dazidian-page attributes))
855 (when (and (memq 'hanyu-dazidian-char attributes)
856 (setq value (get-char-attribute char 'hanyu-dazidian-char)))
857 (insert (format "(hanyu-dazidian-char . %d)%s"
858 value line-breaking))
859 (setq attributes (delq 'hanyu-dazidian-char attributes))
862 (dolist (ignored '(composition
863 ->denotational <-subsumptive ->ucs-unified
864 ->ideographic-component-forms))
865 (setq attributes (delq ignored attributes))))
867 (setq name (car attributes))
868 (if (setq value (get-char-attribute char name))
869 (cond ((setq ret (find-charset name))
870 (setq name (charset-name ret))
871 (if (and (not (memq name dest-ccss))
873 (setq value (get-char-attribute char name))
874 (setq dest-ccss (cons name dest-ccss))))
875 (char-db-insert-ccs-feature name value line-breaking))
877 ((string-match "^=>ucs@" (symbol-name name))
878 (insert (format "(%-18s . #x%04X)\t; %c%s"
879 name value (decode-char '=ucs value)
882 ((eq name 'jisx0208-1978/4X)
883 (insert (format "(%-18s . #x%04X)%s"
888 (null (get-char-attribute
890 (intern (format "%s*sources" name))))
891 (not (string-match "\\*sources$" (symbol-name name)))
892 (or (eq name '<-identical)
893 (string-match "^->halfwidth" (symbol-name name))
895 (string-match "^->fullwidth" (symbol-name name))
898 (characterp (car value))
900 (car value) '=ucs 'defined-only))))
901 (string-match "^->simplified" (symbol-name name))
902 (string-match "^->vulgar" (symbol-name name))
903 (string-match "^->wrong" (symbol-name name))
904 (string-match "^->same" (symbol-name name))
905 (string-match "^->original" (symbol-name name))
906 (string-match "^->ancient" (symbol-name name))
909 ((or (eq name 'ideographic-structure)
910 (eq name 'ideographic-)
911 (string-match "^\\(->\\|<-\\)" (symbol-name name)))
912 (insert (format "(%-18s%s " name line-breaking))
913 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
916 (setq cell (car value))
918 (setq cell (decode-char '=ucs cell)))
919 (cond ((eq name '->subsumptive)
922 (get-char-attribute cell atr))
923 char-db-ignored-attributes))
925 (encode-char cell ccs
930 (let ((char-db-ignored-attributes
932 char-db-ignored-attributes)))
933 (insert-char-attributes cell readable))
934 (setq separator lbs))
940 (intern (format "%s*sources" name))))
941 (setq required-features nil)
942 (dolist (source sources)
944 ((memq source '(JP JP/Jouyou
946 (setq required-features
947 (union required-features
956 (setq required-features
957 (union required-features
963 (setq ret (intern (format "=%s" source))))
964 (setq required-features
965 (cons ret required-features)))
966 (t (setq required-features
967 (cons source required-features)))))
968 (cond ((string-match "@JP" (symbol-name name))
969 (setq required-features
970 (union required-features
978 ((string-match "@CN" (symbol-name name))
979 (setq required-features
980 (union required-features
987 (insert (format "%S" cell))
988 (char-db-insert-char-spec cell readable
991 (setq separator lbs))
995 (if (consp (car cell))
996 (char-db-insert-char-spec cell readable)
997 (char-db-insert-char-reference cell readable))
998 (setq separator lbs))
1002 (insert (prin1-to-string cell))
1003 (setq separator " ")))
1004 (setq value (cdr value)))
1006 (insert line-breaking))
1007 ((memq name '(ideograph=
1008 original-ideograph-of
1009 ancient-ideograph-of
1012 ;; simplified-ideograph-of
1013 ideographic-variants
1014 ;; ideographic-different-form-of
1016 (insert (format "(%-18s%s " name line-breaking))
1017 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
1019 (while (consp value)
1020 (setq cell (car value))
1021 (if (and (consp cell)
1026 (char-db-insert-alist cell readable)
1027 (setq separator lbs))
1030 (insert (prin1-to-string cell))
1031 (setq separator " "))
1032 (setq value (cdr value)))
1034 (insert line-breaking))
1036 (insert (format "(%-18s " name))
1037 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
1039 (while (consp value)
1040 (setq cell (car value))
1041 (if (and (consp cell)
1043 (setq ret (condition-case nil
1051 (setq key (car (car rest)))
1052 (if (find-charset key)
1053 (setq cal (cons key cal))
1054 (setq al (cons key al)))
1055 (setq rest (cdr rest)))
1058 (insert-char-attributes ret
1061 (setq separator lbs))
1062 (setq ret (prin1-to-string cell))
1064 (if (< (+ (current-column)
1071 (setq separator " "))
1072 (setq value (cdr value)))
1074 (insert line-breaking))
1076 (insert (format "(%-18s . %S)%s"
1080 (setq attributes (cdr attributes)))
1083 (defun insert-char-data (char &optional readable
1086 (narrow-to-region (point)(point))
1087 (insert "(define-char
1089 (insert-char-attributes char readable attributes)
1091 (goto-char (point-min))
1092 (while (re-search-forward "[ \t]+$" nil t)
1095 (goto-char (point-min))
1096 (while (re-search-forward "[ \t][ \t][ \t]*" nil t)
1097 (let ((column (current-column))
1098 (indent-tabs-mode t))
1099 (delete-region (match-beginning 0) (point))
1100 (indent-to column)))
1101 (goto-char (point-max))
1102 ;; (tabify (point-min)(point-max))
1105 (defun insert-char-data-with-variant (char &optional printable
1107 script excluded-script)
1108 (insert-char-data char printable)
1109 (let ((variants (or (char-variants char)
1110 (let ((ucs (get-char-attribute char '->ucs)))
1112 (delete char (char-variants (int-char ucs)))))))
1114 (setq variants (sort variants #'<))
1116 (setq variant (car variants))
1117 (if (and (or (null script)
1118 (null (setq vs (get-char-attribute variant 'script)))
1120 (or (null excluded-script)
1121 (null (setq vs (get-char-attribute variant 'script)))
1122 (not (memq excluded-script vs))))
1123 (unless (and no-ucs-unified (get-char-attribute variant '=ucs))
1124 (insert-char-data variant printable)
1125 (if (setq ret (char-variants variant))
1127 (or (memq (car ret) variants)
1128 (get-char-attribute (car ret) '<-subsumptive)
1129 (setq variants (append variants (list (car ret)))))
1130 (setq ret (cdr ret))))
1132 (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