1 ;;; char-db-util.el --- Character Database utility
3 ;; Copyright (C) 1998,1999,2000,2001 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 (int-char (+ #x2EFF i)))
70 (unless (charset-iso-final-char (car (split-char (aref v 34))))
71 (aset v 34 (make-char 'chinese-gb2312 #x62 #x3A)))
75 (defun char-ref-p (obj)
77 (keywordp (car obj))))
80 (defun char-ref= (cr1 cr2)
81 (cond ((char-ref-p cr1)
83 (char-spec= (plist-get cr1 :char)
84 (plist-get cr2 :char))
85 (char-spec= (plist-get cr1 :char) cr2)))
93 (defun char-spec= (cs1 cs2)
97 (eq cs1 (find-char cs2)))
99 (eq (find-char cs1) cs2)
100 (eq (find-char cs1) (find-char cs2)))))
102 (defun char-attribute-name< (ka kb)
108 ((= (charset-dimension ka)
109 (charset-dimension kb))
110 (cond ((= (charset-chars ka)(charset-chars kb))
111 (if (charset-iso-final-char ka)
113 ((>= (charset-iso-final-char ka) ?@)
114 (if (and (charset-iso-final-char kb)
115 (>= (charset-iso-final-char kb) ?@))
116 (< (charset-iso-final-char ka)
117 (charset-iso-final-char kb))
120 (if (charset-iso-final-char kb)
121 (if (>= (charset-iso-final-char kb) ?@)
123 (< (charset-iso-final-char ka)
124 (charset-iso-final-char kb)))
126 (if (charset-iso-final-char kb)
128 (> (charset-id ka)(charset-id kb)))))
129 ((<= (charset-chars ka)(charset-chars kb)))))
131 (< (charset-dimension ka)
132 (charset-dimension kb))
142 (string< (symbol-name ka)
148 (defvar char-db-coded-charset-priority-list
149 (let ((rest default-coded-charset-priority-list)
152 (when (symbolp (car rest))
153 (cond ((memq (car rest)
162 ((string-match "^ideograph-gt-pj-" (symbol-name (car rest)))
163 (unless (memq 'ideograph-gt dest)
164 (setq dest (cons 'ideograph-gt dest))))
166 (setq dest (cons (car rest) dest)))))
167 (setq rest (cdr rest)))
168 (sort dest #'char-attribute-name<)))
170 (defun char-db-insert-char-spec (char &optional readable column)
172 (setq column (current-column)))
173 (let (char-spec ret al cal key temp-char)
174 (cond ((characterp char)
175 (cond ((and (setq ret (get-char-attribute char 'ucs))
176 (not (and (<= #xE000 ret)(<= ret #xF8FF))))
177 (setq char-spec (list (cons 'ucs ret)))
178 (if (setq ret (get-char-attribute char 'name))
179 (setq char-spec (cons (cons 'name ret) char-spec)))
182 (let ((default-coded-charset-priority-list
183 char-db-coded-charset-priority-list))
185 (setq char-spec (list ret))
186 (dolist (ccs (delq (car ret) (charset-list)))
187 (if (or (and (charset-iso-final-char ccs)
188 (setq ret (get-char-attribute char ccs)))
189 (eq ccs 'ideograph-daikanwa))
190 (setq char-spec (cons (cons ccs ret) char-spec))))
192 (setq char-spec (split-char char)))
193 (if (setq ret (get-char-attribute char 'name))
194 (setq char-spec (cons (cons 'name ret) char-spec)))
197 (setq char-spec char)
201 (setq char (find-char char-spec))
203 ;; define temporary character
204 ;; Current implementation is dirty.
205 (setq temp-char (define-char (cons '(ideograph-daikanwa . 0)
207 (remove-char-attribute temp-char 'ideograph-daikanwa)
208 (setq char temp-char))
212 (setq key (car (car char-spec)))
213 (if (find-charset key)
214 (setq cal (cons key cal))
215 (setq al (cons key al)))
216 (setq char-spec (cdr char-spec)))
217 (insert-char-attributes char
221 ;; undefine temporary character
222 ;; Current implementation is dirty.
223 (setq char-spec (char-attribute-alist temp-char))
225 (remove-char-attribute temp-char (car (car char-spec)))
226 (setq char-spec (cdr char-spec))))))
228 (defun char-db-insert-alist (alist &optional readable column)
230 (setq column (current-column)))
232 (concat "\n" (make-string (1+ column) ?\ )))
235 lbs cell rest separator)
238 (setq name (car (car alist))
239 value (cdr (car alist)))
240 (cond ((eq name 'char)
242 (if (setq ret (condition-case nil
249 (setq key (car (car value)))
250 (if (find-charset key)
251 (setq cal (cons key cal))
252 (setq al (cons key al)))
253 (setq value (cdr value)))
254 (insert-char-attributes ret
257 (insert (prin1-to-string value)))
259 (insert line-breaking))
261 (insert (format "(%-18s " name))
262 (setq lbs (concat "\n" (make-string (current-column) ?\ )))
264 (setq cell (car value))
265 (if (and (consp cell)
267 (setq ret (condition-case nil
276 (setq key (car (car rest)))
277 (if (find-charset key)
278 (setq cal (cons key cal))
279 (setq al (cons key al)))
280 (setq rest (cdr rest)))
283 (insert-char-attributes ret
286 (setq separator lbs))
289 (insert (prin1-to-string cell))
290 (setq separator " "))
291 (setq value (cdr value)))
293 (insert line-breaking))
295 (insert (format "(%-18s . %S)%s"
298 (setq alist (cdr alist))))
301 (defun char-db-insert-char-reference (plist &optional readable column)
303 (setq column (current-column)))
305 (concat "\n" (make-string (1+ column) ?\ )))
309 (setq name (pop plist))
310 (setq value (pop plist))
311 (cond ((eq name :char)
313 (cond ((numberp value)
314 (setq value (decode-char 'ucs value)))
316 ;; (setq value (or (find-char value)
319 (char-db-insert-char-spec value readable)
320 (insert line-breaking))
322 (insert (format "%s\t%S%s"
328 (defun char-db-decode-isolated-char (ccs code-point)
331 (cond ((eq ccs 'arabic-iso8859-6)
332 (decode-char ccs code-point))
333 ((and (memq ccs '(ideograph-gt-pj-1
344 (setq ret (decode-char ccs code-point))
345 (setq ret (get-char-attribute ret 'ideograph-gt)))
346 (decode-builtin-char 'ideograph-gt ret))
348 (decode-builtin-char ccs code-point))))
349 (cond ((and (<= 0 (char-int ret))
350 (<= (char-int ret) #x1F))
351 (decode-char 'ucs (+ #x2400 (char-int ret))))
352 ((= (char-int ret) #x7F)
356 (defvar char-db-convert-obsolete-format t)
358 (defun insert-char-attributes (char &optional readable
359 attributes ccs-attributes
364 (if (consp attributes)
365 (copy-sequence attributes))
366 (dolist (name (char-attribute-list))
367 (if (find-charset name)
371 #'char-attribute-name<))
373 (sort (if ccs-attributes
374 (copy-sequence ccs-attributes)
377 #'char-attribute-name<)))
379 (setq column (current-column)))
380 (let (name value has-long-ccs-name rest
383 (concat "\n" (make-string (1+ column) ?\ )))
384 lbs cell separator ret
387 (when (and (memq 'name attributes)
388 (setq value (get-char-attribute char 'name)))
390 (if (> (+ (current-column) (length value)) 48)
393 value line-breaking))
394 (setq attributes (delq 'name attributes))
396 (when (and (memq 'script attributes)
397 (setq value (get-char-attribute char 'script)))
398 (insert (format "(script\t\t%s)%s"
399 (mapconcat (function prin1-to-string)
402 (setq attributes (delq 'script attributes))
404 (when (and (memq '=>ucs attributes)
405 (setq value (get-char-attribute char '=>ucs)))
406 (insert (format "(=>ucs\t\t. #x%04X)\t; %c%s"
407 value (decode-char 'ucs value)
409 (setq attributes (delq '=>ucs attributes))
411 (when (and (memq '=>ucs* attributes)
412 (setq value (get-char-attribute char '=>ucs*)))
413 (insert (format "(=>ucs*\t\t. #x%04X)\t; %c%s"
414 value (decode-char 'ucs value)
416 (setq attributes (delq '=>ucs* attributes))
418 (when (and (memq '=>ucs-jis attributes)
419 (setq value (get-char-attribute char '=>ucs-jis)))
420 (insert (format "(=>ucs-jis\t\t. #x%04X)\t; %c%s"
421 value (decode-char 'ucs value)
423 (setq attributes (delq '=>ucs-jis attributes))
425 (when (and (memq '->ucs attributes)
426 (setq value (get-char-attribute char '->ucs)))
427 (insert (format (if char-db-convert-obsolete-format
428 "(=>ucs\t\t. #x%04X)\t; %c%s"
429 "(->ucs\t\t. #x%04X)\t; %c%s")
430 value (decode-char 'ucs value)
432 (setq attributes (delq '->ucs attributes))
434 (when (and (memq 'general-category attributes)
435 (setq value (get-char-attribute char 'general-category)))
437 "(general-category\t%s) ; %s%s"
438 (mapconcat (lambda (cell)
441 (cond ((rassoc value unidata-normative-category-alist)
442 "Normative Category")
443 ((rassoc value unidata-informative-category-alist)
444 "Informative Category")
448 (setq attributes (delq 'general-category attributes))
450 (when (and (memq 'bidi-category attributes)
451 (setq value (get-char-attribute char 'bidi-category)))
452 (insert (format "(bidi-category\t. %S)%s"
455 (setq attributes (delq 'bidi-category attributes))
457 (unless (or (not (memq 'mirrored attributes))
458 (eq (setq value (get-char-attribute char 'mirrored 'empty))
460 (insert (format "(mirrored\t\t. %S)%s"
463 (setq attributes (delq 'mirrored attributes))
466 ((and (memq 'decimal-digit-value attributes)
467 (setq value (get-char-attribute char 'decimal-digit-value)))
468 (insert (format "(decimal-digit-value . %S)%s"
471 (setq attributes (delq 'decimal-digit-value attributes))
472 (when (and (memq 'digit-value attributes)
473 (setq value (get-char-attribute char 'digit-value)))
474 (insert (format "(digit-value\t . %S)%s"
477 (setq attributes (delq 'digit-value attributes))
479 (when (and (memq 'numeric-value attributes)
480 (setq value (get-char-attribute char 'numeric-value)))
481 (insert (format "(numeric-value\t . %S)%s"
484 (setq attributes (delq 'numeric-value attributes))
488 (when (and (memq 'digit-value attributes)
489 (setq value (get-char-attribute char 'digit-value)))
490 (insert (format "(digit-value\t. %S)%s"
493 (setq attributes (delq 'digit-value attributes))
495 (when (and (memq 'numeric-value attributes)
496 (setq value (get-char-attribute char 'numeric-value)))
497 (insert (format "(numeric-value\t. %S)%s"
500 (setq attributes (delq 'numeric-value attributes))
502 (when (and (memq 'iso-10646-comment attributes)
503 (setq value (get-char-attribute char 'iso-10646-comment)))
504 (insert (format "(iso-10646-comment\t. %S)%s"
507 (setq attributes (delq 'iso-10646-comment attributes))
509 (when (and (memq 'morohashi-daikanwa attributes)
510 (setq value (get-char-attribute char 'morohashi-daikanwa)))
511 (insert (format "(morohashi-daikanwa\t%s)%s"
512 (mapconcat (function prin1-to-string) value " ")
514 (setq attributes (delq 'morohashi-daikanwa attributes))
518 (when (and (memq 'ideographic-radical attributes)
519 (setq value (get-char-attribute char 'ideographic-radical)))
521 (insert (format "(ideographic-radical . %S)\t; %c%s"
523 (aref ideographic-radicals radical)
525 (setq attributes (delq 'ideographic-radical attributes))
527 (when (and (memq 'ideographic-strokes attributes)
528 (setq value (get-char-attribute char 'ideographic-strokes)))
530 (insert (format "(ideographic-strokes . %S)%s"
533 (setq attributes (delq 'ideographic-strokes attributes))
535 (when (and (memq 'kangxi-radical attributes)
536 (setq value (get-char-attribute char 'kangxi-radical)))
537 (unless (eq value radical)
538 (insert (format "(kangxi-radical\t . %S)\t; %c%s"
540 (aref ideographic-radicals value)
543 (setq radical value)))
544 (setq attributes (delq 'kangxi-radical attributes))
546 (when (and (memq 'kangxi-strokes attributes)
547 (setq value (get-char-attribute char 'kangxi-strokes)))
548 (unless (eq value strokes)
549 (insert (format "(kangxi-strokes\t . %S)%s"
553 (setq strokes value)))
554 (setq attributes (delq 'kangxi-strokes attributes))
556 (when (and (memq 'japanese-radical attributes)
557 (setq value (get-char-attribute char 'japanese-radical)))
558 (unless (eq value radical)
559 (insert (format "(japanese-radical\t . %S)\t; %c%s"
561 (aref ideographic-radicals value)
564 (setq radical value)))
565 (setq attributes (delq 'japanese-radical attributes))
567 (when (and (memq 'japanese-strokes attributes)
568 (setq value (get-char-attribute char 'japanese-strokes)))
569 (unless (eq value strokes)
570 (insert (format "(japanese-strokes\t . %S)%s"
574 (setq strokes value)))
575 (setq attributes (delq 'japanese-strokes attributes))
577 (when (and (memq 'cns-radical attributes)
578 (setq value (get-char-attribute char 'cns-radical)))
579 (insert (format "(cns-radical\t . %S)\t; %c%s"
581 (aref ideographic-radicals value)
583 (setq attributes (delq 'cns-radical attributes))
585 (when (and (memq 'cns-strokes attributes)
586 (setq value (get-char-attribute char 'cns-strokes)))
587 (unless (eq value strokes)
588 (insert (format "(cns-strokes\t . %S)%s"
592 (setq strokes value)))
593 (setq attributes (delq 'cns-strokes attributes))
595 (when (and (memq 'shinjigen-1-radical attributes)
596 (setq value (get-char-attribute char 'shinjigen-1-radical)))
597 (unless (eq value radical)
598 (insert (format "(shinjigen-1-radical . %S)\t; %c%s"
600 (aref ideographic-radicals value)
603 (setq radical value)))
604 (setq attributes (delq 'shinjigen-1-radical attributes))
606 (when (and (memq 'total-strokes attributes)
607 (setq value (get-char-attribute char 'total-strokes)))
608 (insert (format "(total-strokes . %S)%s"
611 (setq attributes (delq 'total-strokes attributes))
613 (when (and (memq '->ideograph attributes)
614 (setq value (get-char-attribute char '->ideograph)))
615 (insert (format "(->ideograph\t%s)%s"
616 (mapconcat (lambda (code)
617 (cond ((symbolp code)
620 (format "#x%04X" code))
623 line-breaking code))))
626 (setq attributes (delq '->ideograph attributes))
628 (when (and (memq '->decomposition attributes)
629 (setq value (get-char-attribute char '->decomposition)))
630 (insert (format "(->decomposition\t%s)%s"
631 (mapconcat (lambda (code)
632 (cond ((symbolp code)
641 (format "#x%04X" code))
643 (format "%s%S" line-breaking code))))
646 (setq attributes (delq '->decomposition attributes))
648 (if (equal (get-char-attribute char '->titlecase)
649 (get-char-attribute char '->uppercase))
650 (setq attributes (delq '->titlecase attributes)))
651 (when (and (memq '->mojikyo attributes)
652 (setq value (get-char-attribute char '->mojikyo)))
653 (insert (format "(->mojikyo\t\t. %06d)\t; %c%s"
654 value (decode-char 'mojikyo value)
656 (setq attributes (delq '->mojikyo attributes))
658 (when (and (memq 'hanyu-dazidian-vol attributes)
659 (setq value (get-char-attribute char 'hanyu-dazidian-vol)))
660 (insert (format "(hanyu-dazidian-vol . %d)%s"
661 value line-breaking))
662 (setq attributes (delq 'hanyu-dazidian-vol attributes))
664 (when (and (memq 'hanyu-dazidian-page attributes)
665 (setq value (get-char-attribute char 'hanyu-dazidian-page)))
666 (insert (format "(hanyu-dazidian-page . %d)%s"
667 value line-breaking))
668 (setq attributes (delq 'hanyu-dazidian-page attributes))
670 (when (and (memq 'hanyu-dazidian-char attributes)
671 (setq value (get-char-attribute char 'hanyu-dazidian-char)))
672 (insert (format "(hanyu-dazidian-char . %d)%s"
673 value line-breaking))
674 (setq attributes (delq 'hanyu-dazidian-char attributes))
676 (setq rest ccs-attributes)
679 (setq value (get-char-attribute char (car rest)))
681 (if (>= (length (symbol-name (car rest))) 19)
683 (setq has-long-ccs-name t)
687 (setq rest (cdr rest)))
689 (setq name (car attributes))
690 (if (setq value (get-char-attribute char name))
691 (cond ((eq name 'jisx0208-1978/4X)
692 (insert (format "(%-18s . #x%04X)%s"
695 ((memq name '(->lowercase
696 ->uppercase ->titlecase
697 ->fullwidth <-fullwidth
699 ->vulgar-ideograph <-vulgar-ideograph
700 ->ancient-ideograph <-ancient-ideograph
701 ->original-ideograph <-original-ideograph
702 ->simplified-ideograph <-simplified-ideograph
703 ->wrong-ideograph <-wrong-ideograph
705 ->ideographic-variants
708 ->bopomofo <-bopomofo
709 ->ideographic <-ideographic
710 ideographic-structure))
711 (insert (format "(%-18s%s " name line-breaking))
712 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
715 (setq cell (car value))
717 (setq cell (decode-char 'ucs cell)))
718 (cond ((characterp 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 ((memq name '(ideograph=
739 original-ideograph-of
743 simplified-ideograph-of
745 ideographic-different-form-of))
746 (insert (format "(%-18s%s " name line-breaking))
747 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
750 (setq cell (car value))
751 (if (and (consp cell)
756 (char-db-insert-alist cell readable)
757 (setq separator lbs))
760 (insert (prin1-to-string cell))
761 (setq separator " "))
762 (setq value (cdr value)))
764 (insert line-breaking))
765 ((string-match "^->" (symbol-name name))
767 (format "(%-18s %s)%s"
769 (mapconcat (lambda (code)
770 (cond ((symbolp code)
773 (format "#x%04X" code))
776 line-breaking code))))
780 (insert (format "(%-18s " name))
781 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
784 (setq cell (car value))
785 (if (and (consp cell)
787 (setq ret (condition-case nil
795 (setq key (car (car rest)))
796 (if (find-charset key)
797 (setq cal (cons key cal))
798 (setq al (cons key al)))
799 (setq rest (cdr rest)))
802 (insert-char-attributes ret
805 (setq separator lbs))
808 (insert (prin1-to-string cell))
809 (setq separator " "))
810 (setq value (cdr value)))
812 (insert line-breaking))
814 (insert (format "(%-18s . %S)%s"
818 (setq attributes (cdr attributes)))
819 (while ccs-attributes
820 (setq name (car ccs-attributes))
821 (if (and (eq name (charset-name name))
822 (setq value (get-char-attribute char name)))
825 (cond ((memq name '(ideograph-daikanwa-2
829 (if has-long-ccs-name
830 "(%-26s . %05d)\t; %c%s"
831 "(%-18s . %05d)\t; %c%s"))
833 (if has-long-ccs-name
834 "(%-26s . %06d)\t; %c%s"
835 "(%-18s . %06d)\t; %c%s"))
837 (if has-long-ccs-name
838 "(%-26s . #x%04X)\t; %c%s"
839 "(%-18s . #x%04X)\t; %c%s"))
841 (if has-long-ccs-name
842 "(%-26s . #x%02X)\t; %c%s"
843 "(%-18s . #x%02X)\t; %c%s")))
845 (if (= (charset-iso-graphic-plane name) 1)
847 (cond ((= (charset-dimension name) 1)
849 ((= (charset-dimension name) 2)
851 ((= (charset-dimension name) 3)
855 (char-db-decode-isolated-char name value)
857 (setq ccs-attributes (cdr ccs-attributes)))
860 (defun insert-char-data (char &optional readable
861 attributes ccs-attributes)
863 (narrow-to-region (point)(point))
864 (insert "(define-char
866 (insert-char-attributes char readable
867 attributes ccs-attributes)
869 (goto-char (point-min))
870 (while (re-search-forward "[ \t]+$" nil t)
872 (goto-char (point-max))
873 (tabify (point-min)(point-max))
877 (defun char-db-update-comment ()
880 (goto-char (point-min))
881 (let (cdef table char)
882 (while (re-search-forward "^[ \t]*\\(([^.()]+)\\)" nil t)
883 (goto-char (match-beginning 1))
884 (setq cdef (read (current-buffer)))
885 (when (find-charset (car cdef))
886 (goto-char (match-end 0))
889 (not (eq (car cdef) 'ideograph-daikanwa))
890 (or (memq (car cdef) '(ascii latin-viscii-upper
894 japanese-jisx0213-2))
895 (= (char-int (charset-iso-final-char (car cdef)))
897 (apply (function make-char) cdef)
898 (if (setq table (charset-mapping-table (car cdef)))
899 (set-charset-mapping-table (car cdef) nil))
901 (apply (function make-char) cdef)
903 (set-charset-mapping-table (car cdef) table)))))
904 (when (not (or (< (char-int char) 32)
905 (and (<= 128 (char-int char))
906 (< (char-int char) 160))))
907 (delete-region (point) (point-at-eol))
908 (insert (format "\t; %c" char)))
911 (defun insert-char-data-with-variant (char &optional printable
913 script excluded-script)
914 (insert-char-data char printable)
915 (let ((variants (or (char-variants char)
916 (let ((ucs (get-char-attribute char '->ucs)))
918 (delete char (char-variants (int-char ucs)))))))
920 (setq variants (sort variants #'<))
922 (setq variant (car variants))
923 (if (and (or (null script)
924 (null (setq vs (get-char-attribute variant 'script)))
926 (or (null excluded-script)
927 (null (setq vs (get-char-attribute variant 'script)))
928 (not (memq excluded-script vs))))
929 (or (and no-ucs-variant (get-char-attribute variant 'ucs))
930 (insert-char-data variant printable)))
931 (setq variants (cdr variants))
934 (defun insert-char-range-data (min max &optional script excluded-script)
938 (setq char (decode-char 'ucs code))
939 (if (get-char-attribute char 'ucs)
940 (insert-char-data-with-variant char nil 'no-ucs-variant
941 script excluded-script))
942 (setq code (1+ code))
945 (defun write-char-range-data-to-file (min max file
946 &optional script excluded-script)
947 (let ((coding-system-for-write 'utf-8))
949 (insert-char-range-data min max script excluded-script)
950 (write-region (point-min)(point-max) file))))
952 (defvar what-character-original-window-configuration)
955 (defun what-char-definition (char)
956 (interactive (list (char-after)))
957 (let ((buf (get-buffer-create "*Character Description*"))
958 (the-buf (current-buffer))
959 (win-conf (current-window-configuration)))
961 (make-local-variable 'what-character-original-window-configuration)
962 (setq what-character-original-window-configuration win-conf)
963 (setq buffer-read-only nil)
967 (insert-char-data-with-variant char 'printable)
968 (unless (char-attribute-alist char)
969 (insert (format ";; = %c\n"
970 (let* ((rest (split-char char))
974 (setq code (logior (lsh code 8)
976 (decode-char ccs code)))))
977 ;; (char-db-update-comment)
978 (set-buffer-modified-p nil)
979 (view-mode the-buf (lambda (buf)
980 (set-window-configuration
981 what-character-original-window-configuration)
983 (goto-char (point-min)))
985 (set-window-configuration
986 what-character-original-window-configuration)
987 (signal (car err) (cdr err)))))))
989 (provide 'char-db-util)
991 ;;; char-db-util.el ends here