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
363 (if (consp attributes)
364 (copy-sequence attributes))
365 (char-attribute-list))
366 #'char-attribute-name<))
368 (sort (if ccs-attributes
369 (copy-sequence ccs-attributes)
371 #'char-attribute-name<))
373 (setq column (current-column)))
374 (let (name value has-long-ccs-name rest
377 (concat "\n" (make-string (1+ column) ?\ )))
378 lbs cell separator ret
381 (when (and (memq 'name attributes)
382 (setq value (get-char-attribute char 'name)))
384 (if (> (+ (current-column) (length value)) 48)
387 value line-breaking))
388 (setq attributes (delq 'name attributes))
390 (when (and (memq 'script attributes)
391 (setq value (get-char-attribute char 'script)))
392 (insert (format "(script\t\t%s)%s"
393 (mapconcat (function prin1-to-string)
396 (setq attributes (delq 'script attributes))
398 (when (and (memq '=>ucs attributes)
399 (setq value (get-char-attribute char '=>ucs)))
400 (insert (format "(=>ucs\t\t. #x%04X)\t; %c%s"
401 value (decode-char 'ucs value)
403 (setq attributes (delq '=>ucs attributes))
405 (when (and (memq '=>ucs* attributes)
406 (setq value (get-char-attribute char '=>ucs*)))
407 (insert (format "(=>ucs*\t\t. #x%04X)\t; %c%s"
408 value (decode-char 'ucs value)
410 (setq attributes (delq '=>ucs* attributes))
412 (when (and (memq '->ucs attributes)
413 (setq value (get-char-attribute char '->ucs)))
414 (insert (format (if char-db-convert-obsolete-format
415 "(=>ucs\t\t. #x%04X)\t; %c%s"
416 "(->ucs\t\t. #x%04X)\t; %c%s")
417 value (decode-char 'ucs value)
419 (setq attributes (delq '->ucs attributes))
421 (when (and (memq 'general-category attributes)
422 (setq value (get-char-attribute char 'general-category)))
424 "(general-category\t%s) ; %s%s"
425 (mapconcat (lambda (cell)
428 (cond ((rassoc value unidata-normative-category-alist)
429 "Normative Category")
430 ((rassoc value unidata-informative-category-alist)
431 "Informative Category")
435 (setq attributes (delq 'general-category attributes))
437 (when (and (memq 'bidi-category attributes)
438 (setq value (get-char-attribute char 'bidi-category)))
439 (insert (format "(bidi-category\t. %S)%s"
442 (setq attributes (delq 'bidi-category attributes))
444 (unless (or (not (memq 'mirrored attributes))
445 (eq (setq value (get-char-attribute char 'mirrored 'empty))
447 (insert (format "(mirrored\t\t. %S)%s"
450 (setq attributes (delq 'mirrored attributes))
453 ((and (memq 'decimal-digit-value attributes)
454 (setq value (get-char-attribute char 'decimal-digit-value)))
455 (insert (format "(decimal-digit-value . %S)%s"
458 (setq attributes (delq 'decimal-digit-value attributes))
459 (when (and (memq 'digit-value attributes)
460 (setq value (get-char-attribute char 'digit-value)))
461 (insert (format "(digit-value\t . %S)%s"
464 (setq attributes (delq 'digit-value attributes))
466 (when (and (memq 'numeric-value attributes)
467 (setq value (get-char-attribute char 'numeric-value)))
468 (insert (format "(numeric-value\t . %S)%s"
471 (setq attributes (delq 'numeric-value attributes))
475 (when (and (memq 'digit-value attributes)
476 (setq value (get-char-attribute char 'digit-value)))
477 (insert (format "(digit-value\t. %S)%s"
480 (setq attributes (delq 'digit-value attributes))
482 (when (and (memq 'numeric-value attributes)
483 (setq value (get-char-attribute char 'numeric-value)))
484 (insert (format "(numeric-value\t. %S)%s"
487 (setq attributes (delq 'numeric-value attributes))
489 (when (and (memq 'iso-10646-comment attributes)
490 (setq value (get-char-attribute char 'iso-10646-comment)))
491 (insert (format "(iso-10646-comment\t. %S)%s"
494 (setq attributes (delq 'iso-10646-comment attributes))
496 (when (and (memq 'morohashi-daikanwa attributes)
497 (setq value (get-char-attribute char 'morohashi-daikanwa)))
498 (insert (format "(morohashi-daikanwa\t%s)%s"
499 (mapconcat (function prin1-to-string) value " ")
501 (setq attributes (delq 'morohashi-daikanwa attributes))
505 (when (and (memq 'ideographic-radical attributes)
506 (setq value (get-char-attribute char 'ideographic-radical)))
508 (insert (format "(ideographic-radical . %S)\t; %c%s"
510 (aref ideographic-radicals radical)
512 (setq attributes (delq 'ideographic-radical attributes))
514 (when (and (memq 'ideographic-strokes attributes)
515 (setq value (get-char-attribute char 'ideographic-strokes)))
517 (insert (format "(ideographic-strokes . %S)%s"
520 (setq attributes (delq 'ideographic-strokes attributes))
522 (when (and (memq 'kangxi-radical attributes)
523 (setq value (get-char-attribute char 'kangxi-radical)))
524 (unless (eq value radical)
525 (insert (format "(kangxi-radical\t . %S)\t; %c%s"
527 (aref ideographic-radicals value)
530 (setq radical value)))
531 (setq attributes (delq 'kangxi-radical attributes))
533 (when (and (memq 'kangxi-strokes attributes)
534 (setq value (get-char-attribute char 'kangxi-strokes)))
535 (unless (eq value strokes)
536 (insert (format "(kangxi-strokes\t . %S)%s"
540 (setq strokes value)))
541 (setq attributes (delq 'kangxi-strokes attributes))
543 (when (and (memq 'japanese-radical attributes)
544 (setq value (get-char-attribute char 'japanese-radical)))
545 (unless (eq value radical)
546 (insert (format "(japanese-radical\t . %S)\t; %c%s"
548 (aref ideographic-radicals value)
551 (setq radical value)))
552 (setq attributes (delq 'japanese-radical attributes))
554 (when (and (memq 'japanese-strokes attributes)
555 (setq value (get-char-attribute char 'japanese-strokes)))
556 (unless (eq value strokes)
557 (insert (format "(japanese-strokes\t . %S)%s"
561 (setq strokes value)))
562 (setq attributes (delq 'japanese-strokes attributes))
564 (when (and (memq 'cns-radical attributes)
565 (setq value (get-char-attribute char 'cns-radical)))
566 (insert (format "(cns-radical\t . %S)\t; %c%s"
568 (aref ideographic-radicals value)
570 (setq attributes (delq 'cns-radical attributes))
572 (when (and (memq 'cns-strokes attributes)
573 (setq value (get-char-attribute char 'cns-strokes)))
574 (unless (eq value strokes)
575 (insert (format "(cns-strokes\t . %S)%s"
579 (setq strokes value)))
580 (setq attributes (delq 'cns-strokes attributes))
582 (when (and (memq 'shinjigen-1-radical attributes)
583 (setq value (get-char-attribute char 'shinjigen-1-radical)))
584 (unless (eq value radical)
585 (insert (format "(shinjigen-1-radical . %S)\t; %c%s"
587 (aref ideographic-radicals value)
590 (setq radical value)))
591 (setq attributes (delq 'shinjigen-1-radical attributes))
593 (when (and (memq 'total-strokes attributes)
594 (setq value (get-char-attribute char 'total-strokes)))
595 (insert (format "(total-strokes . %S)%s"
598 (setq attributes (delq 'total-strokes attributes))
600 (when (and (memq '->ideograph attributes)
601 (setq value (get-char-attribute char '->ideograph)))
602 (insert (format "(->ideograph\t%s)%s"
603 (mapconcat (lambda (code)
604 (cond ((symbolp code)
607 (format "#x%04X" code))
610 line-breaking code))))
613 (setq attributes (delq '->ideograph attributes))
615 (when (and (memq '->decomposition attributes)
616 (setq value (get-char-attribute char '->decomposition)))
617 (insert (format "(->decomposition\t%s)%s"
618 (mapconcat (lambda (code)
619 (cond ((symbolp code)
628 (format "#x%04X" code))
630 (format "%s%S" line-breaking code))))
633 (setq attributes (delq '->decomposition attributes))
635 (if (equal (get-char-attribute char '->titlecase)
636 (get-char-attribute char '->uppercase))
637 (setq attributes (delq '->titlecase attributes)))
638 (when (and (memq '->mojikyo attributes)
639 (setq value (get-char-attribute char '->mojikyo)))
640 (insert (format "(->mojikyo\t\t. %06d)\t; %c%s"
641 value (decode-char 'mojikyo value)
643 (setq attributes (delq '->mojikyo attributes))
645 (when (and (memq 'hanyu-dazidian-vol attributes)
646 (setq value (get-char-attribute char 'hanyu-dazidian-vol)))
647 (insert (format "(hanyu-dazidian-vol . %d)%s"
648 value line-breaking))
649 (setq attributes (delq 'hanyu-dazidian-vol attributes))
651 (when (and (memq 'hanyu-dazidian-page attributes)
652 (setq value (get-char-attribute char 'hanyu-dazidian-page)))
653 (insert (format "(hanyu-dazidian-page . %d)%s"
654 value line-breaking))
655 (setq attributes (delq 'hanyu-dazidian-page attributes))
657 (when (and (memq 'hanyu-dazidian-char attributes)
658 (setq value (get-char-attribute char 'hanyu-dazidian-char)))
659 (insert (format "(hanyu-dazidian-char . %d)%s"
660 value line-breaking))
661 (setq attributes (delq 'hanyu-dazidian-char attributes))
663 (setq rest ccs-attributes)
666 (setq value (get-char-attribute char (car rest)))
668 (if (>= (length (symbol-name (car rest))) 19)
670 (setq has-long-ccs-name t)
674 (setq rest (cdr rest)))
676 (setq name (car attributes))
677 (if (setq value (get-char-attribute char name))
678 (cond ((eq name 'jisx0208-1978/4X)
679 (insert (format "(%-18s . #x%04X)%s"
682 ((memq name '(->lowercase
683 ->uppercase ->titlecase
684 ->fullwidth <-fullwidth
686 ->vulgar-ideograph <-vulgar-ideograph
687 ->ancient-ideograph <-ancient-ideograph
688 ->original-ideograph <-original-ideograph
689 ->simplified-ideograph <-simplified-ideograph
690 ->wrong-ideograph <-wrong-ideograph
692 ->ideographic-variants
695 ->bopomofo <-bopomofo
696 ->ideographic <-ideographic
697 ideographic-structure))
698 (insert (format "(%-18s%s " name line-breaking))
699 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
702 (setq cell (car value))
704 (setq cell (decode-char 'ucs cell)))
705 (cond ((characterp cell)
708 (char-db-insert-char-spec cell readable)
709 (setq separator lbs))
713 (if (consp (car cell))
714 (char-db-insert-char-spec cell readable)
715 (char-db-insert-char-reference cell readable))
716 (setq separator lbs))
720 (insert (prin1-to-string cell))
721 (setq separator " ")))
722 (setq value (cdr value)))
724 (insert line-breaking))
725 ((memq name '(ideograph=
726 original-ideograph-of
730 simplified-ideograph-of
732 ideographic-different-form-of))
733 (insert (format "(%-18s%s " name line-breaking))
734 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
737 (setq cell (car value))
738 (if (and (consp cell)
743 (char-db-insert-alist cell readable)
744 (setq separator lbs))
747 (insert (prin1-to-string cell))
748 (setq separator " "))
749 (setq value (cdr value)))
751 (insert line-breaking))
752 ((string-match "^->" (symbol-name name))
754 (format "(%-18s %s)%s"
756 (mapconcat (lambda (code)
757 (cond ((symbolp code)
760 (format "#x%04X" code))
763 line-breaking code))))
767 (insert (format "(%-18s " name))
768 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
771 (setq cell (car value))
772 (if (and (consp cell)
774 (setq ret (condition-case nil
782 (setq key (car (car rest)))
783 (if (find-charset key)
784 (setq cal (cons key cal))
785 (setq al (cons key al)))
786 (setq rest (cdr rest)))
789 (insert-char-attributes ret
792 (setq separator lbs))
795 (insert (prin1-to-string cell))
796 (setq separator " "))
797 (setq value (cdr value)))
799 (insert line-breaking))
801 (insert (format "(%-18s . %S)%s"
805 (setq attributes (cdr attributes)))
806 (while ccs-attributes
807 (setq name (car ccs-attributes))
808 (if (and (eq name (charset-name name))
809 (setq value (get-char-attribute char name)))
812 (cond ((memq name '(ideograph-daikanwa ideograph-gt
814 (if has-long-ccs-name
815 "(%-26s . %05d)\t; %c%s"
816 "(%-18s . %05d)\t; %c%s"))
818 (if has-long-ccs-name
819 "(%-26s . %06d)\t; %c%s"
820 "(%-18s . %06d)\t; %c%s"))
822 (if has-long-ccs-name
823 "(%-26s . #x%04X)\t; %c%s"
824 "(%-18s . #x%04X)\t; %c%s"))
826 (if has-long-ccs-name
827 "(%-26s . #x%02X)\t; %c%s"
828 "(%-18s . #x%02X)\t; %c%s")))
830 (if (= (charset-iso-graphic-plane name) 1)
832 (cond ((= (charset-dimension name) 1)
834 ((= (charset-dimension name) 2)
836 ((= (charset-dimension name) 3)
840 (char-db-decode-isolated-char name value)
842 (setq ccs-attributes (cdr ccs-attributes)))
845 (defun insert-char-data (char &optional readable
846 attributes ccs-attributes)
848 (narrow-to-region (point)(point))
849 (insert "(define-char
851 (insert-char-attributes char readable
852 attributes ccs-attributes)
854 (goto-char (point-min))
855 (while (re-search-forward "[ \t]+$" nil t)
857 (goto-char (point-max))
858 (tabify (point-min)(point-max))
862 (defun char-db-update-comment ()
865 (goto-char (point-min))
866 (let (cdef table char)
867 (while (re-search-forward "^[ \t]*\\(([^.()]+)\\)" nil t)
868 (goto-char (match-beginning 1))
869 (setq cdef (read (current-buffer)))
870 (when (find-charset (car cdef))
871 (goto-char (match-end 0))
874 (not (eq (car cdef) 'ideograph-daikanwa))
875 (or (memq (car cdef) '(ascii latin-viscii-upper
879 japanese-jisx0213-2))
880 (= (char-int (charset-iso-final-char (car cdef)))
882 (apply (function make-char) cdef)
883 (if (setq table (charset-mapping-table (car cdef)))
884 (set-charset-mapping-table (car cdef) nil))
886 (apply (function make-char) cdef)
888 (set-charset-mapping-table (car cdef) table)))))
889 (when (not (or (< (char-int char) 32)
890 (and (<= 128 (char-int char))
891 (< (char-int char) 160))))
892 (delete-region (point) (point-at-eol))
893 (insert (format "\t; %c" char)))
896 (defun insert-char-data-with-variant (char &optional printable
898 script excluded-script)
899 (insert-char-data char printable)
900 (let ((variants (or (char-variants char)
901 (let ((ucs (get-char-attribute char '->ucs)))
903 (delete char (char-variants (int-char ucs)))))))
905 (setq variants (sort variants #'<))
907 (setq variant (car variants))
908 (if (and (or (null script)
909 (null (setq vs (get-char-attribute variant 'script)))
911 (or (null excluded-script)
912 (null (setq vs (get-char-attribute variant 'script)))
913 (not (memq excluded-script vs))))
914 (or (and no-ucs-variant (get-char-attribute variant 'ucs))
915 (insert-char-data variant printable)))
916 (setq variants (cdr variants))
919 (defun insert-char-range-data (min max &optional script excluded-script)
923 (setq char (decode-char 'ucs code))
924 (if (get-char-attribute char 'ucs)
925 (insert-char-data-with-variant char nil 'no-ucs-variant
926 script excluded-script))
927 (setq code (1+ code))
930 (defun write-char-range-data-to-file (min max file
931 &optional script excluded-script)
932 (let ((coding-system-for-write 'utf-8))
934 (insert-char-range-data min max script excluded-script)
935 (write-region (point-min)(point-max) file))))
937 (defvar what-character-original-window-configuration)
940 (defun what-char-definition (char)
941 (interactive (list (char-after)))
942 (let ((buf (get-buffer-create "*Character Description*"))
943 (the-buf (current-buffer))
944 (win-conf (current-window-configuration)))
946 (make-local-variable 'what-character-original-window-configuration)
947 (setq what-character-original-window-configuration win-conf)
948 (setq buffer-read-only nil)
952 (insert-char-data-with-variant char 'printable)
953 (unless (char-attribute-alist char)
954 (insert (format ";; = %c\n"
955 (apply #'make-char (split-char char)))))
956 ;; (char-db-update-comment)
957 (set-buffer-modified-p nil)
958 (view-mode the-buf (lambda (buf)
959 (set-window-configuration
960 what-character-original-window-configuration)
962 (goto-char (point-min)))
964 (set-window-configuration
965 what-character-original-window-configuration)
966 (signal (car err) (cdr err)))))))
968 (provide 'char-db-util)
970 ;;; char-db-util.el ends here