1 ;;; char-db-util.el --- Character Database utility
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, 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 '(ideographic-products))
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
177 (defun char-db-make-char-spec (char)
179 (cond ((characterp char)
180 (cond ((and (setq ret (encode-char char '=ucs 'defined-only))
181 (not (and (<= #xE000 ret)(<= ret #xF8FF))))
182 (setq char-spec (list (cons '=ucs ret)))
183 (cond ((setq ret (get-char-attribute char 'name))
184 (setq char-spec (cons (cons 'name ret) char-spec))
186 ((setq ret (get-char-attribute char 'name*))
187 (setq char-spec (cons (cons 'name* ret) char-spec))
192 (let ((rest char-db-coded-charset-priority-list)
195 (setq ccs (charset-name
196 (find-charset (car rest))))
198 (encode-char char ccs
200 (throw 'tag (cons ccs ret)))
201 (setq rest (cdr rest))))))
202 (setq char-spec (list ret))
203 (dolist (ccs (delq (car ret) (charset-list)))
204 (if (and (or (charset-iso-final-char ccs)
210 (setq ccs (charset-name ccs))
211 (null (assq ccs char-spec))
212 (setq ret (encode-char char ccs 'defined-only)))
213 (setq char-spec (cons (cons ccs ret) char-spec))))
215 (setq char-spec (split-char char)))
216 (cond ((setq ret (get-char-attribute char 'name))
217 (setq char-spec (cons (cons 'name ret) char-spec))
219 ((setq ret (get-char-attribute char 'name*))
220 (setq char-spec (cons (cons 'name* ret) char-spec))
227 (defun char-db-insert-char-spec (char &optional readable column
230 (setq column (current-column)))
231 (let (char-spec temp-char)
232 (setq char-spec (char-db-make-char-spec char))
233 (unless (or (characterp char) ; char
235 (setq char (find-char char-spec))
237 ;; define temporary character
238 ;; Current implementation is dirty.
239 (setq temp-char (define-char (cons '(ideograph-daikanwa . 0)
241 (remove-char-attribute temp-char 'ideograph-daikanwa)
242 (setq char temp-char))
243 (insert-char-attributes char
245 (union (mapcar #'car char-spec)
248 ;; undefine temporary character
249 ;; Current implementation is dirty.
250 (setq char-spec (char-attribute-alist temp-char))
252 (remove-char-attribute temp-char (car (car char-spec)))
253 (setq char-spec (cdr char-spec))))))
255 (defun char-db-insert-alist (alist &optional readable column)
257 (setq column (current-column)))
259 (concat "\n" (make-string (1+ column) ?\ )))
263 lbs cell rest separator)
266 (setq name (car (car alist))
267 value (cdr (car alist)))
268 (cond ((eq name 'char)
270 (if (setq ret (condition-case nil
278 (setq key (car (car value)))
279 ;; (if (find-charset key)
280 ;; (setq cal (cons key cal))
281 (setq al (cons key al))
283 (setq value (cdr value)))
284 (insert-char-attributes ret
288 (insert (prin1-to-string value)))
290 (insert line-breaking))
292 (insert (format "(%-18s " name))
293 (setq lbs (concat "\n" (make-string (current-column) ?\ )))
295 (setq cell (car value))
296 (if (and (consp cell)
298 (setq ret (condition-case nil
308 (setq key (car (car rest)))
309 ;; (if (find-charset key)
310 ;; (setq cal (cons key cal))
311 (setq al (cons key al))
313 (setq rest (cdr rest)))
316 (insert-char-attributes ret
320 (setq separator lbs))
323 (insert (prin1-to-string cell))
324 (setq separator " "))
325 (setq value (cdr value)))
327 (insert line-breaking))
329 (insert (format "(%-18s . %S)%s"
332 (setq alist (cdr alist))))
335 (defun char-db-insert-char-reference (plist &optional readable column)
337 (setq column (current-column)))
339 (concat "\n" (make-string (1+ column) ?\ )))
344 (setq name (pop plist))
345 (setq value (pop plist))
346 (cond ((eq name :char)
349 (cond ((numberp value)
350 (setq value (decode-char '=ucs value)))
352 ;; (setq value (or (find-char value)
355 (char-db-insert-char-spec value readable)
356 (insert line-breaking)
359 (insert (format "%s%s\t%d ; %c%s"
362 (aref ideographic-radicals value)
366 (insert (format "%s%s\t%S" separator name value))
367 (setq separator line-breaking)))
371 (defun char-db-decode-isolated-char (ccs code-point)
374 (cond ((eq ccs 'arabic-iso8859-6)
375 (decode-char ccs code-point))
376 ((and (memq ccs '(=gt-pj-1
387 (setq ret (decode-char ccs code-point))
388 (setq ret (encode-char ret '=gt 'defined-only)))
389 (decode-builtin-char '=gt ret))
391 (decode-builtin-char ccs code-point))))
392 (cond ((and (<= 0 (char-int ret))
393 (<= (char-int ret) #x1F))
394 (decode-char '=ucs (+ #x2400 (char-int ret))))
395 ((= (char-int ret) #x7F)
399 (defvar char-db-convert-obsolete-format t)
401 (defun char-db-insert-ccs-feature (name value line-breaking)
404 (cond ((memq name '(=daikanwa
405 =daikanwa@rev1 =daikanwa@rev2
406 =gt =gt-k =cbeta =zinbun-oracle))
407 "(%-18s . %05d)\t; %c")
409 "(%-18s . %06d)\t; %c")
410 ((>= (charset-dimension name) 2)
411 "(%-18s . #x%04X)\t; %c")
413 "(%-18s . #x%02X)\t; %c"))
415 (if (= (charset-iso-graphic-plane name) 1)
417 (cond ((= (charset-dimension name) 1)
419 ((= (charset-dimension name) 2)
421 ((= (charset-dimension name) 3)
425 (char-db-decode-isolated-char name value)))
426 (if (and (= (charset-chars name) 94)
427 (= (charset-dimension name) 2))
428 (insert (format " [%02d-%02d]"
429 (- (lsh value -8) 32)
430 (- (logand value 255) 32))))
431 (insert line-breaking))
433 (defun insert-char-attributes (char &optional readable attributes column)
435 (setq column (current-column)))
436 (let (name value ; has-long-ccs-name
440 (concat "\n" (make-string (1+ column) ?\ )))
441 lbs cell separator ret
444 sources required-features
449 (if (consp attributes)
451 (dolist (name attributes)
452 (unless (memq name char-db-ignored-attributes)
453 (if (find-charset name)
457 (dolist (name (char-attribute-list))
458 (unless (memq name char-db-ignored-attributes)
459 (if (find-charset name)
463 #'char-attribute-name<)))
465 (when (and (memq 'name attributes)
466 (setq value (get-char-attribute char 'name)))
468 (if (> (+ (current-column) (length value)) 48)
471 value line-breaking))
472 (setq attributes (delq 'name attributes))
474 (when (and (memq 'name* attributes)
475 (setq value (get-char-attribute char 'name*)))
477 (if (> (+ (current-column) (length value)) 48)
480 value line-breaking))
481 (setq attributes (delq 'name* attributes))
483 (when (and (memq 'script attributes)
484 (setq value (get-char-attribute char 'script)))
485 (insert (format "(script\t\t%s)%s"
486 (mapconcat (function prin1-to-string)
489 (setq attributes (delq 'script attributes))
491 ;; (when (and (memq '<-denotational attributes)
492 ;; (setq value (get-char-attribute char '<-denotational))
493 ;; (null (cdr value))
494 ;; (setq value (encode-char (car value) 'ucs 'defined-only)))
495 ;; (insert (format "(%-18s . #x%04X)\t; %c%s"
496 ;; '=>ucs value (decode-char 'ucs value)
498 ;; (setq attributes (delq '<-denotational attributes)))
499 (dolist (name '(=>ucs =>ucs*))
500 (when (and (memq name attributes)
501 (setq value (get-char-attribute char name)))
502 (insert (format "(%-18s . #x%04X)\t; %c%s"
503 name value (decode-char '=ucs value)
505 (setq attributes (delq name attributes))))
506 (dolist (name '(=>ucs@gb =>ucs@cns =>ucs@jis =>ucs@ks =>ucs@big5))
507 (when (and (memq name attributes)
508 (setq value (get-char-attribute char name)))
509 (insert (format "(%-18s . #x%04X)\t; %c%s"
514 (symbol-name name) 2)))
517 (setq attributes (delq name attributes))
519 (dolist (name '(=>daikanwa))
520 (when (and (memq name attributes)
521 (setq value (get-char-attribute char name)))
524 (format "(%-18s . %05d)\t; %c%s"
525 name value (decode-char '=daikanwa value)
527 (format "(%-18s %s)\t; %c%s"
529 (mapconcat (function prin1-to-string)
531 (char-representative-of-daikanwa char)
533 (setq attributes (delq name attributes))))
534 (when (and (memq 'general-category attributes)
535 (setq value (get-char-attribute char 'general-category)))
537 "(general-category\t%s) ; %s%s"
538 (mapconcat (lambda (cell)
541 (cond ((rassoc value unidata-normative-category-alist)
542 "Normative Category")
543 ((rassoc value unidata-informative-category-alist)
544 "Informative Category")
548 (setq attributes (delq 'general-category attributes))
550 (when (and (memq 'bidi-category attributes)
551 (setq value (get-char-attribute char 'bidi-category)))
552 (insert (format "(bidi-category\t. %S)%s"
555 (setq attributes (delq 'bidi-category attributes))
557 (unless (or (not (memq 'mirrored attributes))
558 (eq (setq value (get-char-attribute char 'mirrored 'empty))
560 (insert (format "(mirrored\t\t. %S)%s"
563 (setq attributes (delq 'mirrored attributes))
566 ((and (memq 'decimal-digit-value attributes)
567 (setq value (get-char-attribute char 'decimal-digit-value)))
568 (insert (format "(decimal-digit-value . %S)%s"
571 (setq attributes (delq 'decimal-digit-value attributes))
572 (when (and (memq 'digit-value attributes)
573 (setq value (get-char-attribute char 'digit-value)))
574 (insert (format "(digit-value\t . %S)%s"
577 (setq attributes (delq 'digit-value attributes))
579 (when (and (memq 'numeric-value attributes)
580 (setq value (get-char-attribute char 'numeric-value)))
581 (insert (format "(numeric-value\t . %S)%s"
584 (setq attributes (delq 'numeric-value attributes))
588 (when (and (memq 'digit-value attributes)
589 (setq value (get-char-attribute char 'digit-value)))
590 (insert (format "(digit-value\t. %S)%s"
593 (setq attributes (delq 'digit-value attributes))
595 (when (and (memq 'numeric-value attributes)
596 (setq value (get-char-attribute char 'numeric-value)))
597 (insert (format "(numeric-value\t. %S)%s"
600 (setq attributes (delq 'numeric-value attributes))
602 (when (and (memq 'iso-10646-comment attributes)
603 (setq value (get-char-attribute char 'iso-10646-comment)))
604 (insert (format "(iso-10646-comment\t. %S)%s"
607 (setq attributes (delq 'iso-10646-comment attributes))
609 (when (and (memq 'morohashi-daikanwa attributes)
610 (setq value (get-char-attribute char 'morohashi-daikanwa)))
611 (insert (format "(morohashi-daikanwa\t%s)%s"
612 (mapconcat (function prin1-to-string) value " ")
614 (setq attributes (delq 'morohashi-daikanwa attributes))
618 (when (and (memq 'ideographic-radical attributes)
619 (setq value (get-char-attribute char 'ideographic-radical)))
621 (insert (format "(ideographic-radical . %S)\t; %c%s"
623 (aref ideographic-radicals radical)
625 (setq attributes (delq 'ideographic-radical attributes))
630 char-db-feature-domains
632 (dolist (feature (char-attribute-list))
633 (setq feature (symbol-name feature))
635 "\\(radical\\|strokes\\)@\\([^@*]+\\)\\(\\*\\|$\\)"
637 (setq domain (intern (match-string 2 feature)))
638 (unless (memq domain dest)
639 (setq dest (cons domain dest)))))
640 (sort dest #'string<))))
641 (setq key (intern (format "%s@%s" 'ideographic-radical domain)))
642 (when (and (memq key attributes)
643 (setq value (get-char-attribute char key)))
645 (insert (format "(%s . %S)\t; %c%s"
648 (aref ideographic-radicals radical)
650 (setq attributes (delq key attributes))
652 (setq key (intern (format "%s@%s" 'ideographic-strokes domain)))
653 (when (and (memq key attributes)
654 (setq value (get-char-attribute char key)))
656 (insert (format "(%s . %S)%s"
660 (setq attributes (delq key attributes))
662 (setq key (intern (format "%s@%s" 'total-strokes domain)))
663 (when (and (memq key attributes)
664 (setq value (get-char-attribute char key)))
665 (insert (format "(%s . %S)%s"
669 (setq attributes (delq key attributes))
671 (dolist (feature '(ideographic-radical
674 (setq key (intern (format "%s@%s*sources" feature domain)))
675 (when (and (memq key attributes)
676 (setq value (get-char-attribute char key)))
677 (insert (format "(%s%s" key line-breaking))
679 (insert (format " %s" cell)))
681 (insert line-breaking)
682 (setq attributes (delq key attributes))
685 (when (and (memq 'ideographic-strokes attributes)
686 (setq value (get-char-attribute char 'ideographic-strokes)))
688 (insert (format "(ideographic-strokes . %S)%s"
691 (setq attributes (delq 'ideographic-strokes attributes))
693 (when (and (memq 'kangxi-radical attributes)
694 (setq value (get-char-attribute char 'kangxi-radical)))
695 (unless (eq value radical)
696 (insert (format "(kangxi-radical\t . %S)\t; %c%s"
698 (aref ideographic-radicals value)
701 (setq radical value)))
702 (setq attributes (delq 'kangxi-radical attributes))
704 (when (and (memq 'kangxi-strokes attributes)
705 (setq value (get-char-attribute char 'kangxi-strokes)))
706 (unless (eq value strokes)
707 (insert (format "(kangxi-strokes\t . %S)%s"
711 (setq strokes value)))
712 (setq attributes (delq 'kangxi-strokes attributes))
714 (when (and (memq 'japanese-radical attributes)
715 (setq value (get-char-attribute char 'japanese-radical)))
716 (unless (eq value radical)
717 (insert (format "(japanese-radical\t . %S)\t; %c%s"
719 (aref ideographic-radicals value)
722 (setq radical value)))
723 (setq attributes (delq 'japanese-radical attributes))
725 (when (and (memq 'japanese-strokes attributes)
726 (setq value (get-char-attribute char 'japanese-strokes)))
727 (unless (eq value strokes)
728 (insert (format "(japanese-strokes\t . %S)%s"
732 (setq strokes value)))
733 (setq attributes (delq 'japanese-strokes attributes))
735 (when (and (memq 'cns-radical attributes)
736 (setq value (get-char-attribute char 'cns-radical)))
737 (insert (format "(cns-radical\t . %S)\t; %c%s"
739 (aref ideographic-radicals value)
741 (setq attributes (delq 'cns-radical attributes))
743 (when (and (memq 'cns-strokes attributes)
744 (setq value (get-char-attribute char 'cns-strokes)))
745 (unless (eq value strokes)
746 (insert (format "(cns-strokes\t . %S)%s"
750 (setq strokes value)))
751 (setq attributes (delq 'cns-strokes attributes))
753 (when (and (memq 'shinjigen-1-radical attributes)
754 (setq value (get-char-attribute char 'shinjigen-1-radical)))
755 (unless (eq value radical)
756 (insert (format "(shinjigen-1-radical . %S)\t; %c%s"
758 (aref ideographic-radicals value)
761 (setq radical value)))
762 (setq attributes (delq 'shinjigen-1-radical attributes))
764 (when (and (memq 'ideographic- attributes)
765 (setq value (get-char-attribute char 'ideographic-)))
766 (insert "(ideographic- ")
767 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
770 (setq cell (car value))
772 (setq cell (decode-char '=ucs cell)))
773 (cond ((characterp cell)
777 (insert (format "%S" cell))
778 (char-db-insert-char-spec cell readable))
779 (setq separator lbs))
783 (if (consp (car cell))
784 (char-db-insert-char-spec cell readable)
785 (char-db-insert-char-reference cell readable))
786 (setq separator lbs))
790 (insert (prin1-to-string cell))
791 (setq separator " ")))
792 (setq value (cdr value)))
794 (insert line-breaking)
795 (setq attributes (delq 'ideographic- attributes)))
796 (when (and (memq 'total-strokes attributes)
797 (setq value (get-char-attribute char 'total-strokes)))
798 (insert (format "(total-strokes . %S)%s"
801 (setq attributes (delq 'total-strokes attributes))
803 (when (and (memq '->ideograph attributes)
804 (setq value (get-char-attribute char '->ideograph)))
805 (insert (format "(->ideograph\t%s)%s"
806 (mapconcat (lambda (code)
807 (cond ((symbolp code)
810 (format "#x%04X" code))
813 line-breaking code))))
816 (setq attributes (delq '->ideograph attributes))
818 (when (and (memq '->decomposition attributes)
819 (setq value (get-char-attribute char '->decomposition)))
820 (insert (format "(->decomposition\t%s)%s"
821 (mapconcat (lambda (code)
822 (cond ((symbolp code)
831 (format "#x%04X" code))
833 (format "%s%S" line-breaking code))))
836 (setq attributes (delq '->decomposition attributes))
838 (if (equal (get-char-attribute char '->titlecase)
839 (get-char-attribute char '->uppercase))
840 (setq attributes (delq '->titlecase attributes)))
841 (when (and (memq '->mojikyo attributes)
842 (setq value (get-char-attribute char '->mojikyo)))
843 (insert (format "(->mojikyo\t\t. %06d)\t; %c%s"
844 value (decode-char 'mojikyo value)
846 (setq attributes (delq '->mojikyo attributes))
848 (when (and (memq 'hanyu-dazidian-vol attributes)
849 (setq value (get-char-attribute char 'hanyu-dazidian-vol)))
850 (insert (format "(hanyu-dazidian-vol . %d)%s"
851 value line-breaking))
852 (setq attributes (delq 'hanyu-dazidian-vol attributes))
854 (when (and (memq 'hanyu-dazidian-page attributes)
855 (setq value (get-char-attribute char 'hanyu-dazidian-page)))
856 (insert (format "(hanyu-dazidian-page . %d)%s"
857 value line-breaking))
858 (setq attributes (delq 'hanyu-dazidian-page attributes))
860 (when (and (memq 'hanyu-dazidian-char attributes)
861 (setq value (get-char-attribute char 'hanyu-dazidian-char)))
862 (insert (format "(hanyu-dazidian-char . %d)%s"
863 value line-breaking))
864 (setq attributes (delq 'hanyu-dazidian-char attributes))
867 (dolist (ignored '(composition
868 ->denotational <-subsumptive ->ucs-unified
869 ->ideographic-component-forms))
870 (setq attributes (delq ignored attributes))))
872 (setq name (car attributes))
873 (if (setq value (get-char-attribute char name))
874 (cond ((setq ret (find-charset name))
875 (setq name (charset-name ret))
876 (if (and (not (memq name dest-ccss))
878 (setq value (get-char-attribute char name))
879 (setq dest-ccss (cons name dest-ccss))))
880 (char-db-insert-ccs-feature name value line-breaking))
882 ((string-match "^=>ucs@" (symbol-name name))
883 (insert (format "(%-18s . #x%04X)\t; %c%s"
884 name value (decode-char '=ucs value)
887 ((eq name 'jisx0208-1978/4X)
888 (insert (format "(%-18s . #x%04X)%s"
893 (null (get-char-attribute
895 (intern (format "%s*sources" name))))
896 (not (string-match "\\*sources$" (symbol-name name)))
897 (or (eq name '<-identical)
898 (string-match "^->halfwidth" (symbol-name name))
900 (string-match "^->fullwidth" (symbol-name name))
903 (characterp (car value))
905 (car value) '=ucs 'defined-only))))
906 (string-match "^->simplified" (symbol-name name))
907 (string-match "^->vulgar" (symbol-name name))
908 (string-match "^->wrong" (symbol-name name))
909 (string-match "^->same" (symbol-name name))
910 (string-match "^->original" (symbol-name name))
911 (string-match "^->ancient" (symbol-name name))
912 (string-match "^->Oracle-Bones" (symbol-name name))
915 ((or (eq name 'ideographic-structure)
916 (eq name 'ideographic-combination)
917 (eq name 'ideographic-)
918 (string-match "^\\(->\\|<-\\)" (symbol-name name)))
919 (insert (format "(%-18s%s " name line-breaking))
920 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
923 (setq cell (car value))
925 (setq cell (decode-char '=ucs cell)))
926 (cond ((eq name '->subsumptive)
929 (get-char-attribute cell atr))
930 char-db-ignored-attributes))
932 (encode-char cell ccs
937 (let ((char-db-ignored-attributes
939 char-db-ignored-attributes)))
940 (insert-char-attributes cell readable))
941 (setq separator lbs))
947 (intern (format "%s*sources" name))))
948 (setq required-features nil)
949 (dolist (source sources)
951 ((memq source '(JP JP/Jouyou
953 (setq required-features
954 (union required-features
963 (setq required-features
964 (union required-features
970 (setq ret (intern (format "=%s" source))))
971 (setq required-features
972 (cons ret required-features)))
973 (t (setq required-features
974 (cons source required-features)))))
975 (cond ((string-match "@JP" (symbol-name name))
976 (setq required-features
977 (union required-features
985 ((string-match "@CN" (symbol-name name))
986 (setq required-features
987 (union required-features
994 (insert (format "%S" cell))
995 (char-db-insert-char-spec cell readable
998 (setq separator lbs))
1002 (if (consp (car cell))
1003 (char-db-insert-char-spec cell readable)
1004 (char-db-insert-char-reference cell readable))
1005 (setq separator lbs))
1009 (insert (prin1-to-string cell))
1010 (setq separator " ")))
1011 (setq value (cdr value)))
1013 (insert line-breaking))
1014 ((memq name '(ideograph=
1015 original-ideograph-of
1016 ancient-ideograph-of
1019 ;; simplified-ideograph-of
1020 ideographic-variants
1021 ;; ideographic-different-form-of
1023 (insert (format "(%-18s%s " name line-breaking))
1024 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
1026 (while (consp value)
1027 (setq cell (car value))
1028 (if (and (consp cell)
1033 (char-db-insert-alist cell readable)
1034 (setq separator lbs))
1037 (insert (prin1-to-string cell))
1038 (setq separator " "))
1039 (setq value (cdr value)))
1041 (insert line-breaking))
1043 (insert (format "(%-18s " name))
1044 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
1046 (while (consp value)
1047 (setq cell (car value))
1048 (if (and (consp cell)
1050 (setq ret (condition-case nil
1058 (setq key (car (car rest)))
1059 (if (find-charset key)
1060 (setq cal (cons key cal))
1061 (setq al (cons key al)))
1062 (setq rest (cdr rest)))
1065 (insert-char-attributes ret
1068 (setq separator lbs))
1069 (setq ret (prin1-to-string cell))
1071 (if (< (+ (current-column)
1078 (setq separator " "))
1079 (setq value (cdr value)))
1081 (insert line-breaking))
1083 (insert (format "(%-18s . %S)%s"
1087 (setq attributes (cdr attributes)))
1090 (defun insert-char-data (char &optional readable
1093 (narrow-to-region (point)(point))
1094 (insert "(define-char
1096 (insert-char-attributes char readable attributes)
1098 (goto-char (point-min))
1099 (while (re-search-forward "[ \t]+$" nil t)
1102 (goto-char (point-min))
1103 (while (re-search-forward "[ \t][ \t][ \t]*" nil t)
1104 (let ((column (current-column))
1105 (indent-tabs-mode t))
1106 (delete-region (match-beginning 0) (point))
1107 (indent-to column)))
1108 (goto-char (point-max))
1109 ;; (tabify (point-min)(point-max))
1112 (defun insert-char-data-with-variant (char &optional printable
1114 script excluded-script)
1115 (insert-char-data char printable)
1116 (let ((variants (char-variants char))
1119 (setq variants (sort variants #'<))
1120 (setq rest variants)
1121 (setq variants (cons char variants))
1123 (setq variant (car rest))
1124 (unless (get-char-attribute variant '<-subsumptive)
1125 (if (and (or (null script)
1126 (null (setq vs (get-char-attribute variant 'script)))
1128 (or (null excluded-script)
1129 (null (setq vs (get-char-attribute variant 'script)))
1130 (not (memq excluded-script vs))))
1131 (unless (and no-ucs-unified (get-char-attribute variant '=ucs))
1132 (insert-char-data variant printable)
1133 (if (setq ret (char-variants variant))
1135 (or (memq (car ret) variants)
1136 ;; (get-char-attribute (car ret) '<-subsumptive)
1137 (setq rest (nconc rest (list (car ret)))))
1138 (setq ret (cdr ret)))))))
1139 (setq rest (cdr rest)))))
1141 (defun insert-char-range-data (min max &optional script excluded-script)
1144 (while (<= code max)
1145 (setq char (decode-char '=ucs code))
1146 (if (encode-char char '=ucs 'defined-only)
1147 (insert-char-data-with-variant char nil 'no-ucs-unified
1148 script excluded-script))
1149 (setq code (1+ code)))))
1151 (defun write-char-range-data-to-file (min max file
1152 &optional script excluded-script)
1153 (let ((coding-system-for-write char-db-file-coding-system))
1155 (insert (format ";; -*- coding: %s -*-\n"
1156 char-db-file-coding-system))
1157 (insert-char-range-data min max script excluded-script)
1158 (write-region (point-min)(point-max) file))))
1160 (defvar what-character-original-window-configuration)
1163 (defun what-char-definition (char)
1164 (interactive (list (char-after)))
1165 (let ((buf (get-buffer-create "*Character Description*"))
1166 (the-buf (current-buffer))
1167 (win-conf (current-window-configuration)))
1169 (make-local-variable 'what-character-original-window-configuration)
1170 (setq what-character-original-window-configuration win-conf)
1171 (setq buffer-read-only nil)
1175 (insert-char-data-with-variant char 'printable)
1176 (unless (char-attribute-alist char)
1177 (insert (format ";; = %c\n"
1178 (let* ((rest (split-char char))
1182 (setq code (logior (lsh code 8)
1184 (decode-char ccs code)))))
1185 ;; (char-db-update-comment)
1186 (set-buffer-modified-p nil)
1187 (view-mode the-buf (lambda (buf)
1188 (set-window-configuration
1189 what-character-original-window-configuration)
1191 (goto-char (point-min)))
1193 (set-window-configuration
1194 what-character-original-window-configuration)
1195 (signal (car err) (cdr err)))))))
1197 (provide 'char-db-util)
1199 ;;; char-db-util.el ends here