1 ;;; char-db-util.el --- Character Database utility
3 ;; Copyright (C) 1998,1999,2000,2001,2002,2003 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-feature-domains
73 '(ucs daikanwa cns gt jis jis/alt jis/a jis/b misc unknown))
75 (defvar char-db-ignored-attributes nil)
77 (defun char-attribute-name< (ka kb)
83 ((= (charset-dimension ka)
84 (charset-dimension kb))
85 (< (charset-id ka)(charset-id kb)))
87 (> (charset-dimension ka)
88 (charset-dimension kb))
98 (string< (symbol-name ka)
104 (defvar char-db-coded-charset-priority-list
119 japanese-jisx0208-1978
160 (defun char-db-make-char-spec (char)
162 (cond ((characterp char)
163 (cond ((and (setq ret (encode-char char '=ucs 'defined-only))
164 (not (and (<= #xE000 ret)(<= ret #xF8FF))))
165 (setq char-spec (list (cons '=ucs ret)))
166 (cond ((setq ret (get-char-attribute char 'name))
167 (setq char-spec (cons (cons 'name ret) char-spec))
169 ((setq ret (get-char-attribute char 'name*))
170 (setq char-spec (cons (cons 'name* ret) char-spec))
175 (let ((rest char-db-coded-charset-priority-list)
178 (setq ccs (charset-name
179 (find-charset (car rest))))
181 (encode-char char ccs
183 (throw 'tag (cons ccs ret)))
184 (setq rest (cdr rest))))))
185 (setq char-spec (list ret))
186 (dolist (ccs (delq (car ret) (charset-list)))
187 (if (and (or (charset-iso-final-char ccs)
193 (setq ret (encode-char char ccs 'defined-only)))
194 (setq char-spec (cons (cons ccs ret) char-spec))))
196 (setq char-spec (split-char char)))
197 (cond ((setq ret (get-char-attribute char 'name))
198 (setq char-spec (cons (cons 'name ret) char-spec))
200 ((setq ret (get-char-attribute char 'name*))
201 (setq char-spec (cons (cons 'name* ret) char-spec))
208 (defun char-db-insert-char-spec (char &optional readable column)
210 (setq column (current-column)))
211 (let (char-spec ret al cal key temp-char)
212 (setq char-spec (char-db-make-char-spec char))
213 (unless (or (characterp char) ; char
215 (setq char (find-char char-spec))
217 ;; define temporary character
218 ;; Current implementation is dirty.
219 (setq temp-char (define-char (cons '(ideograph-daikanwa . 0)
221 (remove-char-attribute temp-char 'ideograph-daikanwa)
222 (setq char temp-char))
226 (setq key (car (car char-spec)))
227 (unless (memq key char-db-ignored-attributes)
228 (if (find-charset key)
229 (if (encode-char char key 'defined-only)
230 (setq cal (cons key cal)))
231 (setq al (cons key al))))
232 (setq char-spec (cdr char-spec)))
234 (setq char-spec (char-db-make-char-spec char))
236 (setq key (car (car char-spec)))
237 (unless (memq key char-db-ignored-attributes)
238 (if (find-charset key)
239 (setq cal (cons key cal))
240 (setq al (cons key al))))
241 (setq char-spec (cdr char-spec)))
244 (memq 'ideographic-structure al))
245 (push 'ideographic-structure al))
246 (insert-char-attributes char
250 ;; undefine temporary character
251 ;; Current implementation is dirty.
252 (setq char-spec (char-attribute-alist temp-char))
254 (remove-char-attribute temp-char (car (car char-spec)))
255 (setq char-spec (cdr char-spec))))))
257 (defun char-db-insert-alist (alist &optional readable column)
259 (setq column (current-column)))
261 (concat "\n" (make-string (1+ column) ?\ )))
264 lbs cell rest separator)
267 (setq name (car (car alist))
268 value (cdr (car alist)))
269 (cond ((eq name 'char)
271 (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)))
282 (setq value (cdr value)))
283 (insert-char-attributes ret
286 (insert (prin1-to-string value)))
288 (insert line-breaking))
290 (insert (format "(%-18s " name))
291 (setq lbs (concat "\n" (make-string (current-column) ?\ )))
293 (setq cell (car value))
294 (if (and (consp cell)
296 (setq ret (condition-case nil
305 (setq key (car (car rest)))
306 (if (find-charset key)
307 (setq cal (cons key cal))
308 (setq al (cons key al)))
309 (setq rest (cdr rest)))
312 (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 insert-char-attributes (char &optional readable
397 attributes ccs-attributes
402 (if (consp attributes)
404 (dolist (name attributes)
405 (unless (memq name char-db-ignored-attributes)
408 (dolist (name (char-attribute-list))
409 (unless (memq name char-db-ignored-attributes)
410 (if (find-charset name)
414 #'char-attribute-name<))
416 (sort (if ccs-attributes
419 (dolist (name ccs-attributes)
420 (unless (memq name char-db-ignored-attributes)
425 (dolist (name (charset-list))
426 (unless (memq name char-db-ignored-attributes)
429 #'char-attribute-name<)))
431 (setq column (current-column)))
432 (let (name value has-long-ccs-name rest
435 (concat "\n" (make-string (1+ column) ?\ )))
436 lbs cell separator ret
440 (when (and (memq 'name attributes)
441 (setq value (get-char-attribute char 'name)))
443 (if (> (+ (current-column) (length value)) 48)
446 value line-breaking))
447 (setq attributes (delq 'name attributes))
449 (when (and (memq 'name* attributes)
450 (setq value (get-char-attribute char 'name*)))
452 (if (> (+ (current-column) (length value)) 48)
455 value line-breaking))
456 (setq attributes (delq 'name* attributes))
458 (when (and (memq 'script attributes)
459 (setq value (get-char-attribute char 'script)))
460 (insert (format "(script\t\t%s)%s"
461 (mapconcat (function prin1-to-string)
464 (setq attributes (delq 'script attributes))
466 (dolist (name '(=>ucs =>ucs*))
467 (when (and (memq name attributes)
468 (setq value (get-char-attribute char name)))
469 (insert (format "(%-18s . #x%04X)\t; %c%s"
470 name value (decode-char '=ucs value)
472 (setq attributes (delq name attributes))))
473 (dolist (name '(=>ucs@gb =>ucs@cns =>ucs@jis =>ucs@ks =>ucs@big5))
474 (when (and (memq name attributes)
475 (setq value (get-char-attribute char name)))
476 (insert (format "(%-18s . #x%04X)\t; %c%s"
481 (symbol-name name) 2)))
484 (setq attributes (delq name attributes))
486 (dolist (name '(=>ucs-gb =>ucs-cns =>ucs-jis =>ucs-ks =>ucs-big5))
487 (when (and (memq name attributes)
488 (setq value (get-char-attribute char name)))
489 (insert (format "(%-18s . #x%04X)\t; %c%s"
492 (substring (symbol-name name) 6)))
497 (symbol-name name) 6)))
500 (setq attributes (delq name attributes))))
501 (when (and (memq '->ucs attributes)
502 (setq value (get-char-attribute char '->ucs)))
503 (insert (format (if char-db-convert-obsolete-format
504 "(=>ucs\t\t. #x%04X)\t; %c%s"
505 "(->ucs\t\t. #x%04X)\t; %c%s")
506 value (decode-char '=ucs value)
508 (setq attributes (delq '->ucs attributes))
510 (when (and (memq 'general-category attributes)
511 (setq value (get-char-attribute char 'general-category)))
513 "(general-category\t%s) ; %s%s"
514 (mapconcat (lambda (cell)
517 (cond ((rassoc value unidata-normative-category-alist)
518 "Normative Category")
519 ((rassoc value unidata-informative-category-alist)
520 "Informative Category")
524 (setq attributes (delq 'general-category attributes))
526 (when (and (memq 'bidi-category attributes)
527 (setq value (get-char-attribute char 'bidi-category)))
528 (insert (format "(bidi-category\t. %S)%s"
531 (setq attributes (delq 'bidi-category attributes))
533 (unless (or (not (memq 'mirrored attributes))
534 (eq (setq value (get-char-attribute char 'mirrored 'empty))
536 (insert (format "(mirrored\t\t. %S)%s"
539 (setq attributes (delq 'mirrored attributes))
542 ((and (memq 'decimal-digit-value attributes)
543 (setq value (get-char-attribute char 'decimal-digit-value)))
544 (insert (format "(decimal-digit-value . %S)%s"
547 (setq attributes (delq 'decimal-digit-value attributes))
548 (when (and (memq 'digit-value attributes)
549 (setq value (get-char-attribute char 'digit-value)))
550 (insert (format "(digit-value\t . %S)%s"
553 (setq attributes (delq 'digit-value attributes))
555 (when (and (memq 'numeric-value attributes)
556 (setq value (get-char-attribute char 'numeric-value)))
557 (insert (format "(numeric-value\t . %S)%s"
560 (setq attributes (delq 'numeric-value attributes))
564 (when (and (memq 'digit-value attributes)
565 (setq value (get-char-attribute char 'digit-value)))
566 (insert (format "(digit-value\t. %S)%s"
569 (setq attributes (delq 'digit-value attributes))
571 (when (and (memq 'numeric-value attributes)
572 (setq value (get-char-attribute char 'numeric-value)))
573 (insert (format "(numeric-value\t. %S)%s"
576 (setq attributes (delq 'numeric-value attributes))
578 (when (and (memq 'iso-10646-comment attributes)
579 (setq value (get-char-attribute char 'iso-10646-comment)))
580 (insert (format "(iso-10646-comment\t. %S)%s"
583 (setq attributes (delq 'iso-10646-comment attributes))
585 (when (and (memq 'morohashi-daikanwa attributes)
586 (setq value (get-char-attribute char 'morohashi-daikanwa)))
587 (insert (format "(morohashi-daikanwa\t%s)%s"
588 (mapconcat (function prin1-to-string) value " ")
590 (setq attributes (delq 'morohashi-daikanwa attributes))
594 (when (and (memq 'ideographic-radical attributes)
595 (setq value (get-char-attribute char 'ideographic-radical)))
597 (insert (format "(ideographic-radical . %S)\t; %c%s"
599 (aref ideographic-radicals radical)
601 (setq attributes (delq 'ideographic-radical attributes))
604 (dolist (domain char-db-feature-domains)
605 (setq key (intern (format "%s@%s" 'ideographic-radical domain)))
606 (when (and (memq key attributes)
607 (setq value (get-char-attribute char key)))
609 (insert (format "(%s . %S)\t; %c%s"
612 (aref ideographic-radicals radical)
614 (setq attributes (delq key attributes))
616 (setq key (intern (format "%s@%s" 'ideographic-strokes domain)))
617 (when (and (memq key attributes)
618 (setq value (get-char-attribute char key)))
620 (insert (format "(%s . %S)%s"
624 (setq attributes (delq key attributes))
626 (setq key (intern (format "%s@%s" 'total-strokes domain)))
627 (when (and (memq key attributes)
628 (setq value (get-char-attribute char key)))
629 (insert (format "(%s . %S)%s"
633 (setq attributes (delq key attributes))
635 (dolist (feature '(ideographic-radical
638 (setq key (intern (format "%s@%s*sources" feature domain)))
639 (when (and (memq key attributes)
640 (setq value (get-char-attribute char key)))
641 (insert (format "(%s%s" key line-breaking))
643 (insert (format " %s" cell)))
645 (insert line-breaking)
646 (setq attributes (delq key attributes))
649 (when (and (memq 'ideographic-strokes attributes)
650 (setq value (get-char-attribute char 'ideographic-strokes)))
652 (insert (format "(ideographic-strokes . %S)%s"
655 (setq attributes (delq 'ideographic-strokes attributes))
657 (when (and (memq 'kangxi-radical attributes)
658 (setq value (get-char-attribute char 'kangxi-radical)))
659 (unless (eq value radical)
660 (insert (format "(kangxi-radical\t . %S)\t; %c%s"
662 (aref ideographic-radicals value)
665 (setq radical value)))
666 (setq attributes (delq 'kangxi-radical attributes))
668 (when (and (memq 'kangxi-strokes attributes)
669 (setq value (get-char-attribute char 'kangxi-strokes)))
670 (unless (eq value strokes)
671 (insert (format "(kangxi-strokes\t . %S)%s"
675 (setq strokes value)))
676 (setq attributes (delq 'kangxi-strokes attributes))
678 (when (and (memq 'japanese-radical attributes)
679 (setq value (get-char-attribute char 'japanese-radical)))
680 (unless (eq value radical)
681 (insert (format "(japanese-radical\t . %S)\t; %c%s"
683 (aref ideographic-radicals value)
686 (setq radical value)))
687 (setq attributes (delq 'japanese-radical attributes))
689 (when (and (memq 'japanese-strokes attributes)
690 (setq value (get-char-attribute char 'japanese-strokes)))
691 (unless (eq value strokes)
692 (insert (format "(japanese-strokes\t . %S)%s"
696 (setq strokes value)))
697 (setq attributes (delq 'japanese-strokes attributes))
699 (when (and (memq 'cns-radical attributes)
700 (setq value (get-char-attribute char 'cns-radical)))
701 (insert (format "(cns-radical\t . %S)\t; %c%s"
703 (aref ideographic-radicals value)
705 (setq attributes (delq 'cns-radical attributes))
707 (when (and (memq 'cns-strokes attributes)
708 (setq value (get-char-attribute char 'cns-strokes)))
709 (unless (eq value strokes)
710 (insert (format "(cns-strokes\t . %S)%s"
714 (setq strokes value)))
715 (setq attributes (delq 'cns-strokes attributes))
717 (when (and (memq 'shinjigen-1-radical attributes)
718 (setq value (get-char-attribute char 'shinjigen-1-radical)))
719 (unless (eq value radical)
720 (insert (format "(shinjigen-1-radical . %S)\t; %c%s"
722 (aref ideographic-radicals value)
725 (setq radical value)))
726 (setq attributes (delq 'shinjigen-1-radical attributes))
728 (when (and (memq 'ideographic- attributes)
729 (setq value (get-char-attribute char 'ideographic-)))
730 (insert "(ideographic- ")
731 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
734 (setq cell (car value))
736 (setq cell (decode-char '=ucs cell)))
737 (cond ((characterp cell)
741 (insert (format "%S" cell))
742 (char-db-insert-char-spec cell readable))
743 (setq separator lbs))
747 (if (consp (car cell))
748 (char-db-insert-char-spec cell readable)
749 (char-db-insert-char-reference cell readable))
750 (setq separator lbs))
754 (insert (prin1-to-string cell))
755 (setq separator " ")))
756 (setq value (cdr value)))
758 (insert line-breaking)
759 (setq attributes (delq 'ideographic- attributes)))
760 (when (and (memq 'total-strokes attributes)
761 (setq value (get-char-attribute char 'total-strokes)))
762 (insert (format "(total-strokes . %S)%s"
765 (setq attributes (delq 'total-strokes attributes))
767 (when (and (memq '->ideograph attributes)
768 (setq value (get-char-attribute char '->ideograph)))
769 (insert (format "(->ideograph\t%s)%s"
770 (mapconcat (lambda (code)
771 (cond ((symbolp code)
774 (format "#x%04X" code))
777 line-breaking code))))
780 (setq attributes (delq '->ideograph attributes))
782 (when (and (memq '->decomposition attributes)
783 (setq value (get-char-attribute char '->decomposition)))
784 (insert (format "(->decomposition\t%s)%s"
785 (mapconcat (lambda (code)
786 (cond ((symbolp code)
795 (format "#x%04X" code))
797 (format "%s%S" line-breaking code))))
800 (setq attributes (delq '->decomposition attributes))
802 (if (equal (get-char-attribute char '->titlecase)
803 (get-char-attribute char '->uppercase))
804 (setq attributes (delq '->titlecase attributes)))
805 (when (and (memq '->mojikyo attributes)
806 (setq value (get-char-attribute char '->mojikyo)))
807 (insert (format "(->mojikyo\t\t. %06d)\t; %c%s"
808 value (decode-char 'mojikyo value)
810 (setq attributes (delq '->mojikyo attributes))
812 (when (and (memq 'hanyu-dazidian-vol attributes)
813 (setq value (get-char-attribute char 'hanyu-dazidian-vol)))
814 (insert (format "(hanyu-dazidian-vol . %d)%s"
815 value line-breaking))
816 (setq attributes (delq 'hanyu-dazidian-vol attributes))
818 (when (and (memq 'hanyu-dazidian-page attributes)
819 (setq value (get-char-attribute char 'hanyu-dazidian-page)))
820 (insert (format "(hanyu-dazidian-page . %d)%s"
821 value line-breaking))
822 (setq attributes (delq 'hanyu-dazidian-page attributes))
824 (when (and (memq 'hanyu-dazidian-char attributes)
825 (setq value (get-char-attribute char 'hanyu-dazidian-char)))
826 (insert (format "(hanyu-dazidian-char . %d)%s"
827 value line-breaking))
828 (setq attributes (delq 'hanyu-dazidian-char attributes))
831 (when (memq '->ucs-unified attributes)
832 (setq attributes (delq '->ucs-unified attributes))
834 (when (memq 'composition attributes)
835 (setq attributes (delq 'composition attributes))
837 (setq rest ccs-attributes)
840 (setq value (get-char-attribute char (car rest)))
842 (if (>= (length (symbol-name (car rest))) 19)
844 (setq has-long-ccs-name t)
848 (setq rest (cdr rest)))
850 (setq name (car attributes))
851 (if (setq value (get-char-attribute char name))
852 (cond ((string-match "^=>ucs@" (symbol-name name))
853 (insert (format "(%-18s . #x%04X)\t; %c%s"
854 name value (decode-char '=ucs value)
857 ((eq name 'jisx0208-1978/4X)
858 (insert (format "(%-18s . #x%04X)%s"
861 ((or (eq name 'ideographic-structure)
862 (eq name 'ideographic-)
863 (string-match "^\\(->\\|<-\\)" (symbol-name name)))
864 (insert (format "(%-18s%s " name line-breaking))
865 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
868 (setq cell (car value))
870 (setq cell (decode-char '=ucs cell)))
871 (cond ((characterp cell)
875 (insert (format "%S" cell))
876 (char-db-insert-char-spec cell readable))
877 (setq separator lbs))
881 (if (consp (car cell))
882 (char-db-insert-char-spec cell readable)
883 (char-db-insert-char-reference cell readable))
884 (setq separator lbs))
888 (insert (prin1-to-string cell))
889 (setq separator " ")))
890 (setq value (cdr value)))
892 (insert line-breaking))
893 ((memq name '(ideograph=
894 original-ideograph-of
898 simplified-ideograph-of
900 ideographic-different-form-of))
901 (insert (format "(%-18s%s " name line-breaking))
902 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
905 (setq cell (car value))
906 (if (and (consp cell)
911 (char-db-insert-alist cell readable)
912 (setq separator lbs))
915 (insert (prin1-to-string cell))
916 (setq separator " "))
917 (setq value (cdr value)))
919 (insert line-breaking))
920 ;; ((string-match "^->" (symbol-name name))
922 ;; (format "(%-18s %s)%s"
924 ;; (mapconcat (lambda (code)
925 ;; (cond ((symbolp code)
926 ;; (symbol-name code))
928 ;; (format "#x%04X" code))
931 ;; line-breaking code))))
935 (insert (format "(%-18s " name))
936 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
939 (setq cell (car value))
940 (if (and (consp cell)
942 (setq ret (condition-case nil
950 (setq key (car (car rest)))
951 (if (find-charset key)
952 (setq cal (cons key cal))
953 (setq al (cons key al)))
954 (setq rest (cdr rest)))
957 (insert-char-attributes ret
960 (setq separator lbs))
963 (insert (prin1-to-string cell))
964 (setq separator " "))
965 (setq value (cdr value)))
967 (insert line-breaking))
969 (insert (format "(%-18s . %S)%s"
973 (setq attributes (cdr attributes)))
974 (while ccs-attributes
975 (setq name (charset-name (car ccs-attributes)))
976 (if (and (not (memq name dest-ccss))
978 (setq value (get-char-attribute char name))
979 (setq dest-ccss (cons name dest-ccss))))
982 (cond ((memq name '(=daikanwa
983 =daikanwa-rev1 =daikanwa-rev2
985 (if has-long-ccs-name
986 "(%-26s . %05d)\t; %c%s"
987 "(%-18s . %05d)\t; %c%s"))
989 (if has-long-ccs-name
990 "(%-26s . %06d)\t; %c%s"
991 "(%-18s . %06d)\t; %c%s"))
992 ((>= (charset-dimension name) 2)
993 (if has-long-ccs-name
994 "(%-26s . #x%04X)\t; %c%s"
995 "(%-18s . #x%04X)\t; %c%s"))
997 (if has-long-ccs-name
998 "(%-26s . #x%02X)\t; %c%s"
999 "(%-18s . #x%02X)\t; %c%s")))
1001 (if (= (charset-iso-graphic-plane name) 1)
1003 (cond ((= (charset-dimension name) 1)
1005 ((= (charset-dimension name) 2)
1007 ((= (charset-dimension name) 3)
1011 (char-db-decode-isolated-char name value)
1013 (setq ccs-attributes (cdr ccs-attributes)))
1016 (defun insert-char-data (char &optional readable
1017 attributes ccs-attributes)
1019 (narrow-to-region (point)(point))
1020 (insert "(define-char
1022 (insert-char-attributes char readable
1023 attributes ccs-attributes)
1025 (goto-char (point-min))
1026 (while (re-search-forward "[ \t]+$" nil t)
1029 (goto-char (point-min))
1030 (while (re-search-forward "[ \t][ \t][ \t]*" nil t)
1031 (let ((column (current-column))
1032 (indent-tabs-mode t))
1033 (delete-region (match-beginning 0) (point))
1034 (indent-to column)))
1035 (goto-char (point-max))
1036 ;; (tabify (point-min)(point-max))
1039 (defun insert-char-data-with-variant (char &optional printable
1041 script excluded-script)
1042 (insert-char-data char printable)
1043 (let ((variants (or (char-variants char)
1044 (let ((ucs (get-char-attribute char '->ucs)))
1046 (delete char (char-variants (int-char ucs)))))))
1048 (setq variants (sort variants #'<))
1050 (setq variant (car variants))
1051 (if (and (or (null script)
1052 (null (setq vs (get-char-attribute variant 'script)))
1054 (or (null excluded-script)
1055 (null (setq vs (get-char-attribute variant 'script)))
1056 (not (memq excluded-script vs))))
1057 (or (and no-ucs-unified (get-char-attribute variant '=ucs))
1058 (insert-char-data variant printable)))
1059 (setq variants (cdr variants))
1062 (defun insert-char-range-data (min max &optional script excluded-script)
1065 (while (<= code max)
1066 (setq char (decode-char '=ucs code))
1067 (if (encode-char char '=ucs 'defined-only)
1068 (insert-char-data-with-variant char nil 'no-ucs-unified
1069 script excluded-script))
1070 (setq code (1+ code)))))
1072 (defun write-char-range-data-to-file (min max file
1073 &optional script excluded-script)
1074 (let ((coding-system-for-write 'utf-8-mcs))
1076 (insert ";; -*- coding: utf-8-mcs -*-\n")
1077 (insert-char-range-data min max script excluded-script)
1078 (write-region (point-min)(point-max) file))))
1080 (defvar what-character-original-window-configuration)
1083 (defun what-char-definition (char)
1084 (interactive (list (char-after)))
1085 (let ((buf (get-buffer-create "*Character Description*"))
1086 (the-buf (current-buffer))
1087 (win-conf (current-window-configuration)))
1089 (make-local-variable 'what-character-original-window-configuration)
1090 (setq what-character-original-window-configuration win-conf)
1091 (setq buffer-read-only nil)
1095 (insert-char-data-with-variant char 'printable)
1096 (unless (char-attribute-alist char)
1097 (insert (format ";; = %c\n"
1098 (let* ((rest (split-char char))
1102 (setq code (logior (lsh code 8)
1104 (decode-char ccs code)))))
1105 ;; (char-db-update-comment)
1106 (set-buffer-modified-p nil)
1107 (view-mode the-buf (lambda (buf)
1108 (set-window-configuration
1109 what-character-original-window-configuration)
1111 (goto-char (point-min)))
1113 (set-window-configuration
1114 what-character-original-window-configuration)
1115 (signal (car err) (cdr err)))))))
1117 (provide 'char-db-util)
1119 ;;; char-db-util.el ends here