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: UTF-2000, ISO/IEC 10646, Unicode, UCS-4, MULE.
8 ;; This file is part of XEmacs UTF-2000.
10 ;; XEmacs UTF-2000 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 UTF-2000 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 UTF-2000; 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-ignored-attributes nil)
74 (defun char-attribute-name< (ka kb)
80 ((= (charset-dimension ka)
81 (charset-dimension kb))
82 (cond ((= (charset-chars ka)(charset-chars kb))
83 (if (charset-iso-final-char ka)
85 ((>= (charset-iso-final-char ka) ?@)
86 (if (and (charset-iso-final-char kb)
87 (>= (charset-iso-final-char kb) ?@))
88 (< (charset-iso-final-char ka)
89 (charset-iso-final-char kb))
92 (if (charset-iso-final-char kb)
93 (if (>= (charset-iso-final-char kb) ?@)
95 (< (charset-iso-final-char ka)
96 (charset-iso-final-char kb)))
98 (if (charset-iso-final-char kb)
100 (< (charset-id ka)(charset-id kb)))))
101 ((<= (charset-chars ka)(charset-chars kb)))))
103 (< (charset-dimension ka)
104 (charset-dimension kb))
114 (string< (symbol-name ka)
120 (defvar char-db-coded-charset-priority-list
135 japanese-jisx0208-1978
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 (get-char-attribute char (car rest)))
196 (throw 'tag (cons (car rest) ret)))
197 (setq rest (cdr rest))))))
198 (setq char-spec (list ret))
199 (dolist (ccs (delq (car ret) (charset-list)))
200 (if (and (or (charset-iso-final-char ccs)
205 (setq ret (get-char-attribute char ccs)))
206 (setq char-spec (cons (cons ccs ret) char-spec))))
208 (setq char-spec (split-char char)))
209 (cond ((setq ret (get-char-attribute char 'name))
210 (setq char-spec (cons (cons 'name ret) char-spec))
212 ((setq ret (get-char-attribute char 'name*))
213 (setq char-spec (cons (cons 'name* ret) char-spec))
220 (defun char-db-insert-char-spec (char &optional readable column)
222 (setq column (current-column)))
223 (let (char-spec ret al cal key temp-char)
224 (setq char-spec (char-db-make-char-spec char))
225 (unless (or (characterp char) ; char
227 (setq char (find-char char-spec))
229 ;; define temporary character
230 ;; Current implementation is dirty.
231 (setq temp-char (define-char (cons '(ideograph-daikanwa . 0)
233 (remove-char-attribute temp-char 'ideograph-daikanwa)
234 (setq char temp-char))
238 (setq key (car (car char-spec)))
239 (unless (memq key char-db-ignored-attributes)
240 (if (find-charset key)
241 (if (get-char-attribute char key)
242 (setq cal (cons key cal)))
243 (setq al (cons key al))))
244 (setq char-spec (cdr char-spec)))
246 (setq char-spec (char-db-make-char-spec char))
248 (setq key (car (car char-spec)))
249 (unless (memq key char-db-ignored-attributes)
250 (if (find-charset key)
251 (setq cal (cons key cal))
252 (setq al (cons key al))))
253 (setq char-spec (cdr char-spec)))
256 (memq 'ideographic-structure al))
257 (push 'ideographic-structure al))
258 (insert-char-attributes char
262 ;; undefine temporary character
263 ;; Current implementation is dirty.
264 (setq char-spec (char-attribute-alist temp-char))
266 (remove-char-attribute temp-char (car (car char-spec)))
267 (setq char-spec (cdr char-spec))))))
269 (defun char-db-insert-alist (alist &optional readable column)
271 (setq column (current-column)))
273 (concat "\n" (make-string (1+ column) ?\ )))
276 lbs cell rest separator)
279 (setq name (car (car alist))
280 value (cdr (car alist)))
281 (cond ((eq name 'char)
283 (if (setq ret (condition-case nil
290 (setq key (car (car value)))
291 (if (find-charset key)
292 (setq cal (cons key cal))
293 (setq al (cons key al)))
294 (setq value (cdr value)))
295 (insert-char-attributes ret
298 (insert (prin1-to-string value)))
300 (insert line-breaking))
302 (insert (format "(%-18s " name))
303 (setq lbs (concat "\n" (make-string (current-column) ?\ )))
305 (setq cell (car value))
306 (if (and (consp cell)
308 (setq ret (condition-case nil
317 (setq key (car (car rest)))
318 (if (find-charset key)
319 (setq cal (cons key cal))
320 (setq al (cons key al)))
321 (setq rest (cdr rest)))
324 (insert-char-attributes ret
327 (setq separator lbs))
330 (insert (prin1-to-string cell))
331 (setq separator " "))
332 (setq value (cdr value)))
334 (insert line-breaking))
336 (insert (format "(%-18s . %S)%s"
339 (setq alist (cdr alist))))
342 (defun char-db-insert-char-reference (plist &optional readable column)
344 (setq column (current-column)))
346 (concat "\n" (make-string (1+ column) ?\ )))
351 (setq name (pop plist))
352 (setq value (pop plist))
353 (cond ((eq name :char)
356 (cond ((numberp value)
357 (setq value (decode-char '=ucs value)))
359 ;; (setq value (or (find-char value)
362 (char-db-insert-char-spec value readable)
363 (insert line-breaking)
366 (insert (format "%s%s\t%d ; %c%s"
369 (aref ideographic-radicals value)
373 (insert (format "%s%s\t%S" separator name value))
374 (setq separator line-breaking)))
378 (defun char-db-decode-isolated-char (ccs code-point)
381 (cond ((eq ccs 'arabic-iso8859-6)
382 (decode-char ccs code-point))
383 ((and (memq ccs '(=gt-pj-1
394 (setq ret (decode-char ccs code-point))
395 (setq ret (get-char-attribute ret '=gt)))
396 (decode-builtin-char '=gt ret))
398 (decode-builtin-char ccs code-point))))
399 (cond ((and (<= 0 (char-int ret))
400 (<= (char-int ret) #x1F))
401 (decode-char '=ucs (+ #x2400 (char-int ret))))
402 ((= (char-int ret) #x7F)
406 (defvar char-db-convert-obsolete-format t)
408 (defun insert-char-attributes (char &optional readable
409 attributes ccs-attributes
414 (if (consp attributes)
416 (dolist (name attributes)
417 (unless (memq name char-db-ignored-attributes)
420 (dolist (name (char-attribute-list))
421 (unless (memq name char-db-ignored-attributes)
422 (if (find-charset name)
426 #'char-attribute-name<))
428 (sort (if ccs-attributes
431 (dolist (name ccs-attributes)
432 (unless (memq name char-db-ignored-attributes)
437 (dolist (name (charset-list))
438 (unless (memq name char-db-ignored-attributes)
441 #'char-attribute-name<)))
443 (setq column (current-column)))
444 (let (name value has-long-ccs-name rest
447 (concat "\n" (make-string (1+ column) ?\ )))
448 lbs cell separator ret
451 (when (and (memq 'name attributes)
452 (setq value (get-char-attribute char 'name)))
454 (if (> (+ (current-column) (length value)) 48)
457 value line-breaking))
458 (setq attributes (delq 'name attributes))
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 'script attributes)
470 (setq value (get-char-attribute char 'script)))
471 (insert (format "(script\t\t%s)%s"
472 (mapconcat (function prin1-to-string)
475 (setq attributes (delq 'script attributes))
477 (when (and (memq '=>ucs attributes)
478 (setq value (get-char-attribute char '=>ucs)))
479 (insert (format "(=>ucs\t\t. #x%04X)\t; %c%s"
480 value (decode-char '=ucs value)
482 (setq attributes (delq '=>ucs attributes))
484 (when (and (memq '=>ucs* attributes)
485 (setq value (get-char-attribute char '=>ucs*)))
486 (insert (format "(=>ucs*\t\t. #x%04X)\t; %c%s"
487 value (decode-char '=ucs value)
489 (setq attributes (delq '=>ucs* attributes))
491 (when (and (memq '=>ucs-gb attributes)
492 (setq value (get-char-attribute char '=>ucs-gb)))
493 (insert (format "(=>ucs-gb\t\t. #x%04X)\t; %c%s"
494 value (decode-char '=ucs value)
496 (setq attributes (delq '=>ucs-gb attributes))
498 (when (and (memq '=>ucs-cns attributes)
499 (setq value (get-char-attribute char '=>ucs-cns)))
500 (insert (format "(=>ucs-cns\t\t. #x%04X)\t; %c%s"
501 value (decode-char 'ucs-cns value)
503 (setq attributes (delq '=>ucs-cns attributes))
505 (when (and (memq '=>ucs-big5 attributes)
506 (setq value (get-char-attribute char '=>ucs-big5)))
507 (insert (format "(=>ucs-big5\t\t. #x%04X)\t; %c%s"
508 value (decode-char 'ucs-big5 value)
510 (setq attributes (delq '=>ucs-big5 attributes))
512 (when (and (memq '=>ucs-jis attributes)
513 (setq value (get-char-attribute char '=>ucs-jis)))
514 (insert (format "(=>ucs-jis\t\t. #x%04X)\t; %c%s"
515 value (decode-char 'ucs-jis value)
517 (setq attributes (delq '=>ucs-jis attributes))
519 (when (and (memq '=>ucs-ks attributes)
520 (setq value (get-char-attribute char '=>ucs-ks)))
521 (insert (format "(=>ucs-ks\t\t. #x%04X)\t; %c%s"
522 value (decode-char 'ucs-ks value)
524 (setq attributes (delq '=>ucs-ks attributes))
526 (when (and (memq '->ucs attributes)
527 (setq value (get-char-attribute char '->ucs)))
528 (insert (format (if char-db-convert-obsolete-format
529 "(=>ucs\t\t. #x%04X)\t; %c%s"
530 "(->ucs\t\t. #x%04X)\t; %c%s")
531 value (decode-char '=ucs value)
533 (setq attributes (delq '->ucs attributes))
535 (when (and (memq 'general-category attributes)
536 (setq value (get-char-attribute char 'general-category)))
538 "(general-category\t%s) ; %s%s"
539 (mapconcat (lambda (cell)
542 (cond ((rassoc value unidata-normative-category-alist)
543 "Normative Category")
544 ((rassoc value unidata-informative-category-alist)
545 "Informative Category")
549 (setq attributes (delq 'general-category attributes))
551 (when (and (memq 'bidi-category attributes)
552 (setq value (get-char-attribute char 'bidi-category)))
553 (insert (format "(bidi-category\t. %S)%s"
556 (setq attributes (delq 'bidi-category attributes))
558 (unless (or (not (memq 'mirrored attributes))
559 (eq (setq value (get-char-attribute char 'mirrored 'empty))
561 (insert (format "(mirrored\t\t. %S)%s"
564 (setq attributes (delq 'mirrored attributes))
567 ((and (memq 'decimal-digit-value attributes)
568 (setq value (get-char-attribute char 'decimal-digit-value)))
569 (insert (format "(decimal-digit-value . %S)%s"
572 (setq attributes (delq 'decimal-digit-value attributes))
573 (when (and (memq 'digit-value attributes)
574 (setq value (get-char-attribute char 'digit-value)))
575 (insert (format "(digit-value\t . %S)%s"
578 (setq attributes (delq 'digit-value attributes))
580 (when (and (memq 'numeric-value attributes)
581 (setq value (get-char-attribute char 'numeric-value)))
582 (insert (format "(numeric-value\t . %S)%s"
585 (setq attributes (delq 'numeric-value attributes))
589 (when (and (memq 'digit-value attributes)
590 (setq value (get-char-attribute char 'digit-value)))
591 (insert (format "(digit-value\t. %S)%s"
594 (setq attributes (delq 'digit-value attributes))
596 (when (and (memq 'numeric-value attributes)
597 (setq value (get-char-attribute char 'numeric-value)))
598 (insert (format "(numeric-value\t. %S)%s"
601 (setq attributes (delq 'numeric-value attributes))
603 (when (and (memq 'iso-10646-comment attributes)
604 (setq value (get-char-attribute char 'iso-10646-comment)))
605 (insert (format "(iso-10646-comment\t. %S)%s"
608 (setq attributes (delq 'iso-10646-comment attributes))
610 (when (and (memq 'morohashi-daikanwa attributes)
611 (setq value (get-char-attribute char 'morohashi-daikanwa)))
612 (insert (format "(morohashi-daikanwa\t%s)%s"
613 (mapconcat (function prin1-to-string) value " ")
615 (setq attributes (delq 'morohashi-daikanwa attributes))
619 (when (and (memq 'ideographic-radical attributes)
620 (setq value (get-char-attribute char 'ideographic-radical)))
622 (insert (format "(ideographic-radical . %S)\t; %c%s"
624 (aref ideographic-radicals radical)
626 (setq attributes (delq 'ideographic-radical attributes))
628 (when (and (memq 'ideographic-strokes attributes)
629 (setq value (get-char-attribute char 'ideographic-strokes)))
631 (insert (format "(ideographic-strokes . %S)%s"
634 (setq attributes (delq 'ideographic-strokes attributes))
636 (when (and (memq 'kangxi-radical attributes)
637 (setq value (get-char-attribute char 'kangxi-radical)))
638 (unless (eq value radical)
639 (insert (format "(kangxi-radical\t . %S)\t; %c%s"
641 (aref ideographic-radicals value)
644 (setq radical value)))
645 (setq attributes (delq 'kangxi-radical attributes))
647 (when (and (memq 'kangxi-strokes attributes)
648 (setq value (get-char-attribute char 'kangxi-strokes)))
649 (unless (eq value strokes)
650 (insert (format "(kangxi-strokes\t . %S)%s"
654 (setq strokes value)))
655 (setq attributes (delq 'kangxi-strokes attributes))
657 (when (and (memq 'japanese-radical attributes)
658 (setq value (get-char-attribute char 'japanese-radical)))
659 (unless (eq value radical)
660 (insert (format "(japanese-radical\t . %S)\t; %c%s"
662 (aref ideographic-radicals value)
665 (setq radical value)))
666 (setq attributes (delq 'japanese-radical attributes))
668 (when (and (memq 'japanese-strokes attributes)
669 (setq value (get-char-attribute char 'japanese-strokes)))
670 (unless (eq value strokes)
671 (insert (format "(japanese-strokes\t . %S)%s"
675 (setq strokes value)))
676 (setq attributes (delq 'japanese-strokes attributes))
678 (when (and (memq 'cns-radical attributes)
679 (setq value (get-char-attribute char 'cns-radical)))
680 (insert (format "(cns-radical\t . %S)\t; %c%s"
682 (aref ideographic-radicals value)
684 (setq attributes (delq 'cns-radical attributes))
686 (when (and (memq 'cns-strokes attributes)
687 (setq value (get-char-attribute char 'cns-strokes)))
688 (unless (eq value strokes)
689 (insert (format "(cns-strokes\t . %S)%s"
693 (setq strokes value)))
694 (setq attributes (delq 'cns-strokes attributes))
696 (when (and (memq 'shinjigen-1-radical attributes)
697 (setq value (get-char-attribute char 'shinjigen-1-radical)))
698 (unless (eq value radical)
699 (insert (format "(shinjigen-1-radical . %S)\t; %c%s"
701 (aref ideographic-radicals value)
704 (setq radical value)))
705 (setq attributes (delq 'shinjigen-1-radical attributes))
707 (when (and (memq 'ideographic- attributes)
708 (setq value (get-char-attribute char 'ideographic-)))
709 (insert "(ideographic- ")
710 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
713 (setq cell (car value))
715 (setq cell (decode-char '=ucs cell)))
716 (cond ((characterp cell)
720 (insert (format "%S" cell))
721 (char-db-insert-char-spec cell readable))
722 (setq separator lbs))
726 (if (consp (car cell))
727 (char-db-insert-char-spec cell readable)
728 (char-db-insert-char-reference cell readable))
729 (setq separator lbs))
733 (insert (prin1-to-string cell))
734 (setq separator " ")))
735 (setq value (cdr value)))
737 (insert line-breaking)
738 (setq attributes (delq 'ideographic- attributes)))
739 (when (and (memq 'total-strokes attributes)
740 (setq value (get-char-attribute char 'total-strokes)))
741 (insert (format "(total-strokes . %S)%s"
744 (setq attributes (delq 'total-strokes attributes))
746 (when (and (memq '->ideograph attributes)
747 (setq value (get-char-attribute char '->ideograph)))
748 (insert (format "(->ideograph\t%s)%s"
749 (mapconcat (lambda (code)
750 (cond ((symbolp code)
753 (format "#x%04X" code))
756 line-breaking code))))
759 (setq attributes (delq '->ideograph attributes))
761 (when (and (memq '->decomposition attributes)
762 (setq value (get-char-attribute char '->decomposition)))
763 (insert (format "(->decomposition\t%s)%s"
764 (mapconcat (lambda (code)
765 (cond ((symbolp code)
774 (format "#x%04X" code))
776 (format "%s%S" line-breaking code))))
779 (setq attributes (delq '->decomposition attributes))
781 (if (equal (get-char-attribute char '->titlecase)
782 (get-char-attribute char '->uppercase))
783 (setq attributes (delq '->titlecase attributes)))
784 (when (and (memq '->mojikyo attributes)
785 (setq value (get-char-attribute char '->mojikyo)))
786 (insert (format "(->mojikyo\t\t. %06d)\t; %c%s"
787 value (decode-char 'mojikyo value)
789 (setq attributes (delq '->mojikyo attributes))
791 (when (and (memq 'hanyu-dazidian-vol attributes)
792 (setq value (get-char-attribute char 'hanyu-dazidian-vol)))
793 (insert (format "(hanyu-dazidian-vol . %d)%s"
794 value line-breaking))
795 (setq attributes (delq 'hanyu-dazidian-vol attributes))
797 (when (and (memq 'hanyu-dazidian-page attributes)
798 (setq value (get-char-attribute char 'hanyu-dazidian-page)))
799 (insert (format "(hanyu-dazidian-page . %d)%s"
800 value line-breaking))
801 (setq attributes (delq 'hanyu-dazidian-page attributes))
803 (when (and (memq 'hanyu-dazidian-char attributes)
804 (setq value (get-char-attribute char 'hanyu-dazidian-char)))
805 (insert (format "(hanyu-dazidian-char . %d)%s"
806 value line-breaking))
807 (setq attributes (delq 'hanyu-dazidian-char attributes))
810 (when (memq '->ucs-variants attributes)
811 (setq attributes (delq '->ucs-variants attributes))
813 (when (memq 'composition attributes)
814 (setq attributes (delq 'composition attributes))
816 (setq rest ccs-attributes)
819 (setq value (get-char-attribute char (car rest)))
821 (if (>= (length (symbol-name (car rest))) 19)
823 (setq has-long-ccs-name t)
827 (setq rest (cdr rest)))
829 (setq name (car attributes))
830 (if (setq value (get-char-attribute char name))
831 (cond ((eq name 'jisx0208-1978/4X)
832 (insert (format "(%-18s . #x%04X)%s"
835 ((or (eq name 'ideographic-structure)
836 (eq name 'ideographic-)
837 (string-match "^\\(->\\|<-\\)" (symbol-name name)))
838 (insert (format "(%-18s%s " name line-breaking))
839 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
842 (setq cell (car value))
844 (setq cell (decode-char '=ucs cell)))
845 (cond ((characterp cell)
849 (insert (format "%S" cell))
850 (char-db-insert-char-spec cell readable))
851 (setq separator lbs))
855 (if (consp (car cell))
856 (char-db-insert-char-spec cell readable)
857 (char-db-insert-char-reference cell readable))
858 (setq separator lbs))
862 (insert (prin1-to-string cell))
863 (setq separator " ")))
864 (setq value (cdr value)))
866 (insert line-breaking))
867 ((memq name '(ideograph=
868 original-ideograph-of
872 simplified-ideograph-of
874 ideographic-different-form-of))
875 (insert (format "(%-18s%s " name line-breaking))
876 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
879 (setq cell (car value))
880 (if (and (consp cell)
885 (char-db-insert-alist cell readable)
886 (setq separator lbs))
889 (insert (prin1-to-string cell))
890 (setq separator " "))
891 (setq value (cdr value)))
893 (insert line-breaking))
894 ;; ((string-match "^->" (symbol-name name))
896 ;; (format "(%-18s %s)%s"
898 ;; (mapconcat (lambda (code)
899 ;; (cond ((symbolp code)
900 ;; (symbol-name code))
902 ;; (format "#x%04X" code))
905 ;; line-breaking code))))
909 (insert (format "(%-18s " name))
910 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
913 (setq cell (car value))
914 (if (and (consp cell)
916 (setq ret (condition-case nil
924 (setq key (car (car rest)))
925 (if (find-charset key)
926 (setq cal (cons key cal))
927 (setq al (cons key al)))
928 (setq rest (cdr rest)))
931 (insert-char-attributes ret
934 (setq separator lbs))
937 (insert (prin1-to-string cell))
938 (setq separator " "))
939 (setq value (cdr value)))
941 (insert line-breaking))
943 (insert (format "(%-18s . %S)%s"
947 (setq attributes (cdr attributes)))
948 (while ccs-attributes
949 (setq name (car ccs-attributes))
950 (if (and (eq name (charset-name name))
951 (setq value (get-char-attribute char name)))
954 (cond ((memq name '(ideograph-daikanwa-2
957 (if has-long-ccs-name
958 "(%-26s . %05d)\t; %c%s"
959 "(%-18s . %05d)\t; %c%s"))
961 (if has-long-ccs-name
962 "(%-26s . %06d)\t; %c%s"
963 "(%-18s . %06d)\t; %c%s"))
964 ((>= (charset-dimension name) 2)
965 (if has-long-ccs-name
966 "(%-26s . #x%04X)\t; %c%s"
967 "(%-18s . #x%04X)\t; %c%s"))
969 (if has-long-ccs-name
970 "(%-26s . #x%02X)\t; %c%s"
971 "(%-18s . #x%02X)\t; %c%s")))
973 (if (= (charset-iso-graphic-plane name) 1)
975 (cond ((= (charset-dimension name) 1)
977 ((= (charset-dimension name) 2)
979 ((= (charset-dimension name) 3)
983 (char-db-decode-isolated-char name value)
985 (setq ccs-attributes (cdr ccs-attributes)))
988 (defun insert-char-data (char &optional readable
989 attributes ccs-attributes)
991 (narrow-to-region (point)(point))
992 (insert "(define-char
994 (insert-char-attributes char readable
995 attributes ccs-attributes)
997 (goto-char (point-min))
998 (while (re-search-forward "[ \t]+$" nil t)
1001 (goto-char (point-min))
1002 (while (re-search-forward "[ \t][ \t][ \t]*" nil t)
1003 (let ((column (current-column))
1004 (indent-tabs-mode t))
1005 (delete-region (match-beginning 0) (point))
1006 (indent-to column)))
1007 (goto-char (point-max))
1008 ;; (tabify (point-min)(point-max))
1011 (defun insert-char-data-with-variant (char &optional printable
1013 script excluded-script)
1014 (insert-char-data char printable)
1015 (let ((variants (or (char-variants char)
1016 (let ((ucs (get-char-attribute char '->ucs)))
1018 (delete char (char-variants (int-char ucs)))))))
1020 (setq variants (sort variants #'<))
1022 (setq variant (car variants))
1023 (if (and (or (null script)
1024 (null (setq vs (get-char-attribute variant 'script)))
1026 (or (null excluded-script)
1027 (null (setq vs (get-char-attribute variant 'script)))
1028 (not (memq excluded-script vs))))
1029 (or (and no-ucs-variant (get-char-attribute variant '=ucs))
1030 (insert-char-data variant printable)))
1031 (setq variants (cdr variants))
1034 (defun insert-char-range-data (min max &optional script excluded-script)
1037 (while (<= code max)
1038 (setq char (decode-char '=ucs code))
1039 (if (encode-char char '=ucs 'defined-only)
1040 (insert-char-data-with-variant char nil 'no-ucs-variant
1041 script excluded-script))
1042 (setq code (1+ code)))))
1044 (defun write-char-range-data-to-file (min max file
1045 &optional script excluded-script)
1046 (let ((coding-system-for-write 'utf-8))
1048 (insert-char-range-data min max script excluded-script)
1049 (write-region (point-min)(point-max) file))))
1051 (defvar what-character-original-window-configuration)
1054 (defun what-char-definition (char)
1055 (interactive (list (char-after)))
1056 (let ((buf (get-buffer-create "*Character Description*"))
1057 (the-buf (current-buffer))
1058 (win-conf (current-window-configuration)))
1060 (make-local-variable 'what-character-original-window-configuration)
1061 (setq what-character-original-window-configuration win-conf)
1062 (setq buffer-read-only nil)
1066 (insert-char-data-with-variant char 'printable)
1067 (unless (char-attribute-alist char)
1068 (insert (format ";; = %c\n"
1069 (let* ((rest (split-char char))
1073 (setq code (logior (lsh code 8)
1075 (decode-char ccs code)))))
1076 ;; (char-db-update-comment)
1077 (set-buffer-modified-p nil)
1078 (view-mode the-buf (lambda (buf)
1079 (set-window-configuration
1080 what-character-original-window-configuration)
1082 (goto-char (point-min)))
1084 (set-window-configuration
1085 what-character-original-window-configuration)
1086 (signal (car err) (cdr err)))))))
1088 (provide 'char-db-util)
1090 ;;; char-db-util.el ends here