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 (if (< (charset-iso-final-char (car (split-char (aref v 34)))) ?0)
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))
112 ((>= (charset-iso-final-char ka) ?@)
113 (if (>= (charset-iso-final-char kb) ?@)
114 (< (charset-iso-final-char ka)
115 (charset-iso-final-char kb))
117 ((>= (charset-iso-final-char ka) ?0)
119 ((>= (charset-iso-final-char kb) ?@)
121 ((>= (charset-iso-final-char kb) ?0)
122 (< (charset-iso-final-char ka)
123 (charset-iso-final-char kb)))
125 (t (if (>= (charset-iso-final-char kb) ?0)
127 (> (charset-id ka)(charset-id kb))))))
128 ((<= (charset-chars ka)(charset-chars kb)))))
130 (< (charset-dimension ka)
131 (charset-dimension kb))
141 (string< (symbol-name ka)
147 (defvar char-db-coded-charset-priority-list
148 (let ((rest default-coded-charset-priority-list)
151 (when (symbolp (car rest))
152 (cond ((memq (car rest)
161 ((string-match "^ideograph-gt-pj-" (symbol-name (car rest)))
162 (unless (memq 'ideograph-gt dest)
163 (setq dest (cons 'ideograph-gt dest))))
165 (setq dest (cons (car rest) dest)))))
166 (setq rest (cdr rest)))
167 (sort dest #'char-attribute-name<)))
169 (defun char-db-insert-char-spec (char &optional readable column)
171 (setq column (current-column)))
172 (let (char-spec ret al cal key temp-char)
173 (cond ((characterp char)
174 (cond ((and (setq ret (get-char-attribute char 'ucs))
175 (not (and (<= #xE000 ret)(<= ret #xF8FF))))
176 (setq char-spec (list (cons 'ucs ret)))
177 (if (setq ret (get-char-attribute char 'name))
178 (setq char-spec (cons (cons 'name ret) char-spec)))
181 (let ((default-coded-charset-priority-list
182 char-db-coded-charset-priority-list))
184 (setq char-spec (list ret))
185 (dolist (ccs (delq (car ret) (charset-list)))
186 (if (or (and (>= (charset-iso-final-char ccs) ?0)
187 (setq ret (get-char-attribute char ccs)))
188 (eq ccs 'ideograph-daikanwa))
189 (setq char-spec (cons (cons ccs ret) char-spec))))
191 (setq char-spec (split-char char)))
192 (if (setq ret (get-char-attribute char 'name))
193 (setq char-spec (cons (cons 'name ret) char-spec)))
196 (setq char-spec char)
200 (setq char (find-char char-spec))
202 ;; define temporary character
203 ;; Current implementation is dirty.
204 (setq temp-char (define-char (cons '(ideograph-daikanwa . 0)
206 (remove-char-attribute temp-char 'ideograph-daikanwa)
207 (setq char temp-char))
211 (setq key (car (car char-spec)))
212 (if (find-charset key)
213 (setq cal (cons key cal))
214 (setq al (cons key al)))
215 (setq char-spec (cdr char-spec)))
216 (insert-char-attributes char
220 ;; undefine temporary character
221 ;; Current implementation is dirty.
222 (setq char-spec (char-attribute-alist temp-char))
224 (remove-char-attribute temp-char (car (car char-spec)))
225 (setq char-spec (cdr char-spec))))))
227 (defun char-db-insert-alist (alist &optional readable column)
229 (setq column (current-column)))
231 (concat "\n" (make-string (1+ column) ?\ )))
234 lbs cell rest separator)
237 (setq name (car (car alist))
238 value (cdr (car alist)))
239 (cond ((eq name 'char)
241 (if (setq ret (condition-case nil
248 (setq key (car (car value)))
249 (if (find-charset key)
250 (setq cal (cons key cal))
251 (setq al (cons key al)))
252 (setq value (cdr value)))
253 (insert-char-attributes ret
256 (insert (prin1-to-string value)))
258 (insert line-breaking))
260 (insert (format "(%-18s " name))
261 (setq lbs (concat "\n" (make-string (current-column) ?\ )))
263 (setq cell (car value))
264 (if (and (consp cell)
266 (setq ret (condition-case nil
275 (setq key (car (car rest)))
276 (if (find-charset key)
277 (setq cal (cons key cal))
278 (setq al (cons key al)))
279 (setq rest (cdr rest)))
282 (insert-char-attributes ret
285 (setq separator lbs))
288 (insert (prin1-to-string cell))
289 (setq separator " "))
290 (setq value (cdr value)))
292 (insert line-breaking))
294 (insert (format "(%-18s . %S)%s"
297 (setq alist (cdr alist))))
300 (defun char-db-insert-char-reference (plist &optional readable column)
302 (setq column (current-column)))
304 (concat "\n" (make-string (1+ column) ?\ )))
308 (setq name (pop plist))
309 (setq value (pop plist))
310 (cond ((eq name :char)
312 (cond ((numberp value)
313 (setq value (decode-char 'ucs value)))
315 ;; (setq value (or (find-char value)
318 (char-db-insert-char-spec value readable)
319 (insert line-breaking))
321 (insert (format "%s\t%S%s"
327 (defun char-db-decode-isolated-char (ccs code-point)
330 (cond ((eq ccs 'arabic-iso8859-6)
331 (decode-char ccs code-point))
332 ((and (memq ccs '(ideograph-gt-pj-1
343 (setq ret (decode-char ccs code-point))
344 (setq ret (get-char-attribute ret 'ideograph-gt)))
345 (decode-builtin-char 'ideograph-gt ret))
347 (decode-builtin-char ccs code-point))))
348 (cond ((and (<= 0 (char-int ret))
349 (<= (char-int ret) #x1F))
350 (decode-char 'ucs (+ #x2400 (char-int ret))))
351 ((= (char-int ret) #x7F)
355 (defvar char-db-convert-obsolete-format t)
357 (defun insert-char-attributes (char &optional readable
358 attributes ccs-attributes
362 (if (consp attributes)
363 (copy-sequence attributes))
364 (char-attribute-list))
365 #'char-attribute-name<))
367 (sort (if ccs-attributes
368 (copy-sequence ccs-attributes)
370 #'char-attribute-name<))
372 (setq column (current-column)))
373 (let (name value has-long-ccs-name rest
376 (concat "\n" (make-string (1+ column) ?\ )))
377 lbs cell separator ret
380 (when (and (memq 'name attributes)
381 (setq value (get-char-attribute char 'name)))
383 (if (> (+ (current-column) (length value)) 48)
386 value line-breaking))
387 (setq attributes (delq 'name attributes))
389 (when (and (memq 'script attributes)
390 (setq value (get-char-attribute char 'script)))
391 (insert (format "(script\t\t%s)%s"
392 (mapconcat (function prin1-to-string)
395 (setq attributes (delq 'script attributes))
397 (when (and (memq '=>ucs attributes)
398 (setq value (get-char-attribute char '=>ucs)))
399 (insert (format "(=>ucs\t\t. #x%04X)\t; %c%s"
400 value (decode-char 'ucs value)
402 (setq attributes (delq '=>ucs 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 (if char-db-convert-obsolete-format
414 "(=>ucs\t\t. #x%04X)\t; %c%s"
415 "(->ucs\t\t. #x%04X)\t; %c%s")
416 value (decode-char 'ucs value)
418 (setq attributes (delq '->ucs attributes))
420 (when (and (memq 'general-category attributes)
421 (setq value (get-char-attribute char 'general-category)))
423 "(general-category\t%s) ; %s%s"
424 (mapconcat (lambda (cell)
427 (cond ((rassoc value unidata-normative-category-alist)
428 "Normative Category")
429 ((rassoc value unidata-informative-category-alist)
430 "Informative Category")
434 (setq attributes (delq 'general-category attributes))
436 (when (and (memq 'bidi-category attributes)
437 (setq value (get-char-attribute char 'bidi-category)))
438 (insert (format "(bidi-category\t. %S)%s"
441 (setq attributes (delq 'bidi-category attributes))
443 (unless (or (not (memq 'mirrored attributes))
444 (eq (setq value (get-char-attribute char 'mirrored 'empty))
446 (insert (format "(mirrored\t\t. %S)%s"
449 (setq attributes (delq 'mirrored attributes))
452 ((and (memq 'decimal-digit-value attributes)
453 (setq value (get-char-attribute char 'decimal-digit-value)))
454 (insert (format "(decimal-digit-value . %S)%s"
457 (setq attributes (delq 'decimal-digit-value attributes))
458 (when (and (memq 'digit-value attributes)
459 (setq value (get-char-attribute char 'digit-value)))
460 (insert (format "(digit-value\t . %S)%s"
463 (setq attributes (delq 'digit-value attributes))
465 (when (and (memq 'numeric-value attributes)
466 (setq value (get-char-attribute char 'numeric-value)))
467 (insert (format "(numeric-value\t . %S)%s"
470 (setq attributes (delq 'numeric-value attributes))
474 (when (and (memq 'digit-value attributes)
475 (setq value (get-char-attribute char 'digit-value)))
476 (insert (format "(digit-value\t. %S)%s"
479 (setq attributes (delq 'digit-value attributes))
481 (when (and (memq 'numeric-value attributes)
482 (setq value (get-char-attribute char 'numeric-value)))
483 (insert (format "(numeric-value\t. %S)%s"
486 (setq attributes (delq 'numeric-value attributes))
488 (when (and (memq 'iso-10646-comment attributes)
489 (setq value (get-char-attribute char 'iso-10646-comment)))
490 (insert (format "(iso-10646-comment\t. %S)%s"
493 (setq attributes (delq 'iso-10646-comment attributes))
495 (when (and (memq 'morohashi-daikanwa attributes)
496 (setq value (get-char-attribute char 'morohashi-daikanwa)))
497 (insert (format "(morohashi-daikanwa\t%s)%s"
498 (mapconcat (function prin1-to-string) value " ")
500 (setq attributes (delq 'morohashi-daikanwa attributes))
504 (when (and (memq 'ideographic-radical attributes)
505 (setq value (get-char-attribute char 'ideographic-radical)))
507 (insert (format "(ideographic-radical . %S)\t; %c%s"
509 (aref ideographic-radicals radical)
511 (setq attributes (delq 'ideographic-radical attributes))
513 (when (and (memq 'ideographic-strokes attributes)
514 (setq value (get-char-attribute char 'ideographic-strokes)))
516 (insert (format "(ideographic-strokes . %S)%s"
519 (setq attributes (delq 'ideographic-strokes attributes))
521 (when (and (memq 'kangxi-radical attributes)
522 (setq value (get-char-attribute char 'kangxi-radical)))
523 (unless (eq value radical)
524 (insert (format "(kangxi-radical\t . %S)\t; %c%s"
526 (aref ideographic-radicals value)
529 (setq radical value)))
530 (setq attributes (delq 'kangxi-radical attributes))
532 (when (and (memq 'kangxi-strokes attributes)
533 (setq value (get-char-attribute char 'kangxi-strokes)))
534 (unless (eq value strokes)
535 (insert (format "(kangxi-strokes\t . %S)%s"
539 (setq strokes value)))
540 (setq attributes (delq 'kangxi-strokes attributes))
542 (when (and (memq 'japanese-radical attributes)
543 (setq value (get-char-attribute char 'japanese-radical)))
544 (unless (eq value radical)
545 (insert (format "(japanese-radical\t . %S)\t; %c%s"
547 (aref ideographic-radicals value)
550 (setq radical value)))
551 (setq attributes (delq 'japanese-radical attributes))
553 (when (and (memq 'japanese-strokes attributes)
554 (setq value (get-char-attribute char 'japanese-strokes)))
555 (unless (eq value strokes)
556 (insert (format "(japanese-strokes\t . %S)%s"
560 (setq strokes value)))
561 (setq attributes (delq 'japanese-strokes attributes))
563 (when (and (memq 'cns-radical attributes)
564 (setq value (get-char-attribute char 'cns-radical)))
565 (insert (format "(cns-radical\t . %S)\t; %c%s"
567 (aref ideographic-radicals value)
569 (setq attributes (delq 'cns-radical attributes))
571 (when (and (memq 'cns-strokes attributes)
572 (setq value (get-char-attribute char 'cns-strokes)))
573 (unless (eq value strokes)
574 (insert (format "(cns-strokes\t . %S)%s"
578 (setq strokes value)))
579 (setq attributes (delq 'cns-strokes attributes))
581 (when (and (memq 'shinjigen-1-radical attributes)
582 (setq value (get-char-attribute char 'shinjigen-1-radical)))
583 (unless (eq value radical)
584 (insert (format "(shinjigen-1-radical . %S)\t; %c%s"
586 (aref ideographic-radicals value)
589 (setq radical value)))
590 (setq attributes (delq 'shinjigen-1-radical attributes))
592 (when (and (memq 'total-strokes attributes)
593 (setq value (get-char-attribute char 'total-strokes)))
594 (insert (format "(total-strokes . %S)%s"
597 (setq attributes (delq 'total-strokes attributes))
599 (when (and (memq '->ideograph attributes)
600 (setq value (get-char-attribute char '->ideograph)))
601 (insert (format "(->ideograph\t%s)%s"
602 (mapconcat (lambda (code)
603 (cond ((symbolp code)
606 (format "#x%04X" code))
609 line-breaking code))))
612 (setq attributes (delq '->ideograph attributes))
614 (when (and (memq '->decomposition attributes)
615 (setq value (get-char-attribute char '->decomposition)))
616 (insert (format "(->decomposition\t%s)%s"
617 (mapconcat (lambda (code)
618 (cond ((symbolp code)
627 (format "#x%04X" code))
629 (format "%s%S" line-breaking code))))
632 (setq attributes (delq '->decomposition attributes))
634 (if (equal (get-char-attribute char '->titlecase)
635 (get-char-attribute char '->uppercase))
636 (setq attributes (delq '->titlecase attributes)))
637 (when (and (memq '->mojikyo attributes)
638 (setq value (get-char-attribute char '->mojikyo)))
639 (insert (format "(->mojikyo\t\t. %06d)\t; %c%s"
640 value (decode-char 'mojikyo value)
642 (setq attributes (delq '->mojikyo attributes))
644 (when (and (memq 'hanyu-dazidian-vol attributes)
645 (setq value (get-char-attribute char 'hanyu-dazidian-vol)))
646 (insert (format "(hanyu-dazidian-vol . %d)%s"
647 value line-breaking))
648 (setq attributes (delq 'hanyu-dazidian-vol attributes))
650 (when (and (memq 'hanyu-dazidian-page attributes)
651 (setq value (get-char-attribute char 'hanyu-dazidian-page)))
652 (insert (format "(hanyu-dazidian-page . %d)%s"
653 value line-breaking))
654 (setq attributes (delq 'hanyu-dazidian-page attributes))
656 (when (and (memq 'hanyu-dazidian-char attributes)
657 (setq value (get-char-attribute char 'hanyu-dazidian-char)))
658 (insert (format "(hanyu-dazidian-char . %d)%s"
659 value line-breaking))
660 (setq attributes (delq 'hanyu-dazidian-char attributes))
662 (setq rest ccs-attributes)
665 (setq value (get-char-attribute char (car rest)))
667 (if (>= (length (symbol-name (car rest))) 19)
669 (setq has-long-ccs-name t)
673 (setq rest (cdr rest)))
675 (setq name (car attributes))
676 (if (setq value (get-char-attribute char name))
677 (cond ((eq name 'jisx0208-1978/4X)
678 (insert (format "(%-18s . #x%04X)%s"
681 ((memq name '(->lowercase
682 ->uppercase ->titlecase
683 ->fullwidth <-fullwidth
685 ->vulgar-ideograph <-vulgar-ideograph
686 ->ancient-ideograph <-ancient-ideograph
687 ->original-ideograph <-original-ideograph
688 ->simplified-ideograph <-simplified-ideograph
689 ->wrong-ideograph <-wrong-ideograph
691 ->ideographic-variants
694 ->bopomofo <-bopomofo
695 ->ideographic <-ideographic
696 ideographic-structure))
697 (insert (format "(%-18s%s " name line-breaking))
698 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
701 (setq cell (car value))
703 (setq cell (decode-char 'ucs cell)))
704 (cond ((characterp cell)
707 (char-db-insert-char-spec cell readable)
708 (setq separator lbs))
712 (if (consp (car cell))
713 (char-db-insert-char-spec cell readable)
714 (char-db-insert-char-reference cell readable))
715 (setq separator lbs))
719 (insert (prin1-to-string cell))
720 (setq separator " ")))
721 (setq value (cdr value)))
723 (insert line-breaking))
724 ((memq name '(ideograph=
725 original-ideograph-of
729 simplified-ideograph-of
731 ideographic-different-form-of))
732 (insert (format "(%-18s%s " name line-breaking))
733 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
736 (setq cell (car value))
737 (if (and (consp cell)
742 (char-db-insert-alist cell readable)
743 (setq separator lbs))
746 (insert (prin1-to-string cell))
747 (setq separator " "))
748 (setq value (cdr value)))
750 (insert line-breaking))
751 ((string-match "^->" (symbol-name name))
753 (format "(%-18s %s)%s"
755 (mapconcat (lambda (code)
756 (cond ((symbolp code)
759 (format "#x%04X" code))
762 line-breaking code))))
766 (insert (format "(%-18s " name))
767 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
770 (setq cell (car value))
771 (if (and (consp cell)
773 (setq ret (condition-case nil
781 (setq key (car (car rest)))
782 (if (find-charset key)
783 (setq cal (cons key cal))
784 (setq al (cons key al)))
785 (setq rest (cdr rest)))
788 (insert-char-attributes ret
791 (setq separator lbs))
794 (insert (prin1-to-string cell))
795 (setq separator " "))
796 (setq value (cdr value)))
798 (insert line-breaking))
800 (insert (format "(%-18s . %S)%s"
804 (setq attributes (cdr attributes)))
805 (while ccs-attributes
806 (setq name (car ccs-attributes))
807 (if (and (eq name (charset-name name))
808 (setq value (get-char-attribute char name)))
811 (cond ((memq name '(ideograph-daikanwa ideograph-gt
813 (if has-long-ccs-name
814 "(%-26s . %05d)\t; %c%s"
815 "(%-18s . %05d)\t; %c%s"))
817 (if has-long-ccs-name
818 "(%-26s . %06d)\t; %c%s"
819 "(%-18s . %06d)\t; %c%s"))
821 (if has-long-ccs-name
822 "(%-26s . #x%04X)\t; %c%s"
823 "(%-18s . #x%04X)\t; %c%s"))
825 (if has-long-ccs-name
826 "(%-26s . #x%02X)\t; %c%s"
827 "(%-18s . #x%02X)\t; %c%s")))
829 (if (= (charset-iso-graphic-plane name) 1)
831 (cond ((= (charset-dimension name) 1)
833 ((= (charset-dimension name) 2)
835 ((= (charset-dimension name) 3)
839 (char-db-decode-isolated-char name value)
841 (setq ccs-attributes (cdr ccs-attributes)))
844 (defun insert-char-data (char &optional readable
845 attributes ccs-attributes)
847 (narrow-to-region (point)(point))
848 (insert "(define-char
850 (insert-char-attributes char readable
851 attributes ccs-attributes)
853 (goto-char (point-min))
854 (while (re-search-forward "[ \t]+$" nil t)
856 (goto-char (point-max))
857 (tabify (point-min)(point-max))
861 (defun char-db-update-comment ()
864 (goto-char (point-min))
865 (let (cdef table char)
866 (while (re-search-forward "^[ \t]*\\(([^.()]+)\\)" nil t)
867 (goto-char (match-beginning 1))
868 (setq cdef (read (current-buffer)))
869 (when (find-charset (car cdef))
870 (goto-char (match-end 0))
873 (not (eq (car cdef) 'ideograph-daikanwa))
874 (or (memq (car cdef) '(ascii latin-viscii-upper
878 japanese-jisx0213-2))
879 (= (char-int (charset-iso-final-char (car cdef)))
881 (apply (function make-char) cdef)
882 (if (setq table (charset-mapping-table (car cdef)))
883 (set-charset-mapping-table (car cdef) nil))
885 (apply (function make-char) cdef)
887 (set-charset-mapping-table (car cdef) table)))))
888 (when (not (or (< (char-int char) 32)
889 (and (<= 128 (char-int char))
890 (< (char-int char) 160))))
891 (delete-region (point) (point-at-eol))
892 (insert (format "\t; %c" char)))
895 (defun insert-char-data-with-variant (char &optional printable
897 script excluded-script)
898 (insert-char-data char printable)
899 (let ((variants (or (char-variants char)
900 (let ((ucs (get-char-attribute char '->ucs)))
902 (delete char (char-variants (int-char ucs)))))))
904 (setq variants (sort variants #'<))
906 (setq variant (car variants))
907 (if (and (or (null script)
908 (null (setq vs (get-char-attribute variant 'script)))
910 (or (null excluded-script)
911 (null (setq vs (get-char-attribute variant 'script)))
912 (not (memq excluded-script vs))))
913 (or (and no-ucs-variant (get-char-attribute variant 'ucs))
914 (insert-char-data variant printable)))
915 (setq variants (cdr variants))
918 (defun insert-char-range-data (min max &optional script excluded-script)
922 (setq char (decode-char 'ucs code))
923 (if (get-char-attribute char 'ucs)
924 (insert-char-data-with-variant char nil 'no-ucs-variant
925 script excluded-script))
926 (setq code (1+ code))
929 (defun write-char-range-data-to-file (min max file
930 &optional script excluded-script)
931 (let ((coding-system-for-write 'utf-8))
933 (insert-char-range-data min max script excluded-script)
934 (write-region (point-min)(point-max) file))))
936 (defvar what-character-original-window-configuration)
939 (defun what-char-definition (char)
940 (interactive (list (char-after)))
941 (let ((buf (get-buffer-create "*Character Description*"))
942 (the-buf (current-buffer))
943 (win-conf (current-window-configuration)))
945 (make-local-variable 'what-character-original-window-configuration)
946 (setq what-character-original-window-configuration win-conf)
947 (setq buffer-read-only nil)
951 (insert-char-data-with-variant char 'printable)
952 (unless (char-attribute-alist char)
953 (insert (format ";; = %c\n"
954 (apply #'make-char (split-char char)))))
955 ;; (char-db-update-comment)
956 (set-buffer-modified-p nil)
957 (view-mode the-buf (lambda (buf)
958 (set-window-configuration
959 what-character-original-window-configuration)
961 (goto-char (point-min)))
963 (set-window-configuration
964 what-character-original-window-configuration)
965 (signal (car err) (cdr err)))))))
967 (provide 'char-db-util)
969 ;;; char-db-util.el ends here