1 ;;; char-db-util.el --- Character Database utility
3 ;; Copyright (C) 1998,1999,2000,2001,2002 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)))
74 (defvar char-db-ignored-attributes nil)
77 (defun char-ref-p (obj)
79 (keywordp (car obj))))
82 (defun char-ref= (cr1 cr2)
83 (cond ((char-ref-p cr1)
85 (char-spec= (plist-get cr1 :char)
86 (plist-get cr2 :char))
87 (char-spec= (plist-get cr1 :char) cr2)))
95 (defun char-spec= (cs1 cs2)
99 (eq cs1 (find-char cs2)))
101 (eq (find-char cs1) cs2)
102 (eq (find-char cs1) (find-char cs2)))))
104 (defun char-attribute-name< (ka kb)
110 ((= (charset-dimension ka)
111 (charset-dimension kb))
112 (cond ((= (charset-chars ka)(charset-chars kb))
113 (if (charset-iso-final-char ka)
115 ((>= (charset-iso-final-char ka) ?@)
116 (if (and (charset-iso-final-char kb)
117 (>= (charset-iso-final-char kb) ?@))
118 (< (charset-iso-final-char ka)
119 (charset-iso-final-char kb))
122 (if (charset-iso-final-char kb)
123 (if (>= (charset-iso-final-char kb) ?@)
125 (< (charset-iso-final-char ka)
126 (charset-iso-final-char kb)))
128 (if (charset-iso-final-char kb)
130 (< (charset-id ka)(charset-id kb)))))
131 ((<= (charset-chars ka)(charset-chars kb)))))
133 (< (charset-dimension ka)
134 (charset-dimension kb))
144 (string< (symbol-name ka)
150 (defvar char-db-coded-charset-priority-list
151 (let ((rest default-coded-charset-priority-list)
154 (when (symbolp (car rest))
155 (cond ((memq (car rest)
164 ((string-match "^chinese-big5" (symbol-name (car rest))))
165 ((string-match "^ideograph-gt-pj-" (symbol-name (car rest)))
166 (unless (memq 'ideograph-gt dest)
167 (setq dest (cons 'ideograph-gt dest))))
169 (setq dest (cons (car rest) dest)))))
170 (setq rest (cdr rest)))
171 (append (sort dest #'char-attribute-name<)
172 '(chinese-big5-cdp chinese-big5-eten chinese-big5))))
174 (defun char-db-insert-char-spec (char &optional readable column)
176 (setq column (current-column)))
177 (let (char-spec ret al cal key temp-char)
178 (cond ((characterp char)
179 (cond ((and (setq ret (get-char-attribute char 'ucs))
180 (not (and (<= #xE000 ret)(<= ret #xF8FF))))
181 (setq char-spec (list (cons 'ucs ret)))
182 (if (setq ret (get-char-attribute char 'name))
183 (setq char-spec (cons (cons 'name ret) char-spec)))
186 (let ((default-coded-charset-priority-list
187 char-db-coded-charset-priority-list))
189 (setq char-spec (list ret))
190 (dolist (ccs (delq (car ret) (charset-list)))
191 (if (or (and (charset-iso-final-char ccs)
192 (setq ret (get-char-attribute char ccs)))
193 (eq ccs 'ideograph-daikanwa))
194 (setq char-spec (cons (cons ccs ret) char-spec))))
196 (setq char-spec (split-char char)))
197 (if (setq ret (get-char-attribute char 'name))
198 (setq char-spec (cons (cons 'name ret) char-spec)))
201 (setq char-spec char)
205 (setq char (find-char char-spec))
207 ;; define temporary character
208 ;; Current implementation is dirty.
209 (setq temp-char (define-char (cons '(ideograph-daikanwa . 0)
211 (remove-char-attribute temp-char 'ideograph-daikanwa)
212 (setq char temp-char))
216 (setq key (car (car char-spec)))
217 (unless (memq key char-db-ignored-attributes)
218 (if (find-charset key)
219 (setq cal (cons key cal))
220 (setq al (cons key al))))
221 (setq char-spec (cdr char-spec)))
223 (memq 'ideographic-structure al))
224 (push 'ideographic-structure al))
225 (insert-char-attributes char
229 ;; undefine temporary character
230 ;; Current implementation is dirty.
231 (setq char-spec (char-attribute-alist temp-char))
233 (remove-char-attribute temp-char (car (car char-spec)))
234 (setq char-spec (cdr char-spec))))))
236 (defun char-db-insert-alist (alist &optional readable column)
238 (setq column (current-column)))
240 (concat "\n" (make-string (1+ column) ?\ )))
243 lbs cell rest separator)
246 (setq name (car (car alist))
247 value (cdr (car alist)))
248 (cond ((eq name 'char)
250 (if (setq ret (condition-case nil
257 (setq key (car (car value)))
258 (if (find-charset key)
259 (setq cal (cons key cal))
260 (setq al (cons key al)))
261 (setq value (cdr value)))
262 (insert-char-attributes ret
265 (insert (prin1-to-string value)))
267 (insert line-breaking))
269 (insert (format "(%-18s " name))
270 (setq lbs (concat "\n" (make-string (current-column) ?\ )))
272 (setq cell (car value))
273 (if (and (consp cell)
275 (setq ret (condition-case nil
284 (setq key (car (car rest)))
285 (if (find-charset key)
286 (setq cal (cons key cal))
287 (setq al (cons key al)))
288 (setq rest (cdr rest)))
291 (insert-char-attributes ret
294 (setq separator lbs))
297 (insert (prin1-to-string cell))
298 (setq separator " "))
299 (setq value (cdr value)))
301 (insert line-breaking))
303 (insert (format "(%-18s . %S)%s"
306 (setq alist (cdr alist))))
309 (defun char-db-insert-char-reference (plist &optional readable column)
311 (setq column (current-column)))
313 (concat "\n" (make-string (1+ column) ?\ )))
317 (setq name (pop plist))
318 (setq value (pop plist))
319 (cond ((eq name :char)
321 (cond ((numberp value)
322 (setq value (decode-char 'ucs value)))
324 ;; (setq value (or (find-char value)
327 (char-db-insert-char-spec value readable)
328 (insert line-breaking))
330 (insert (format "%s\t%S%s"
336 (defun char-db-decode-isolated-char (ccs code-point)
339 (cond ((eq ccs 'arabic-iso8859-6)
340 (decode-char ccs code-point))
341 ((and (memq ccs '(ideograph-gt-pj-1
352 (setq ret (decode-char ccs code-point))
353 (setq ret (get-char-attribute ret 'ideograph-gt)))
354 (decode-builtin-char 'ideograph-gt ret))
356 (decode-builtin-char ccs code-point))))
357 (cond ((and (<= 0 (char-int ret))
358 (<= (char-int ret) #x1F))
359 (decode-char 'ucs (+ #x2400 (char-int ret))))
360 ((= (char-int ret) #x7F)
364 (defvar char-db-convert-obsolete-format t)
366 (defun insert-char-attributes (char &optional readable
367 attributes ccs-attributes
372 (if (consp attributes)
374 (dolist (name attributes)
375 (unless (memq name char-db-ignored-attributes)
378 (dolist (name (char-attribute-list))
379 (unless (memq name char-db-ignored-attributes)
380 (if (find-charset name)
384 #'char-attribute-name<))
386 (sort (if ccs-attributes
389 (dolist (name ccs-attributes)
390 (unless (memq name char-db-ignored-attributes)
395 (dolist (name (charset-list))
396 (unless (memq name char-db-ignored-attributes)
399 #'char-attribute-name<)))
401 (setq column (current-column)))
402 (let (name value has-long-ccs-name rest
405 (concat "\n" (make-string (1+ column) ?\ )))
406 lbs cell separator ret
409 (when (and (memq 'name attributes)
410 (setq value (get-char-attribute char 'name)))
412 (if (> (+ (current-column) (length value)) 48)
415 value line-breaking))
416 (setq attributes (delq 'name attributes))
418 (when (and (memq 'script attributes)
419 (setq value (get-char-attribute char 'script)))
420 (insert (format "(script\t\t%s)%s"
421 (mapconcat (function prin1-to-string)
424 (setq attributes (delq 'script attributes))
426 (when (and (memq '=>ucs attributes)
427 (setq value (get-char-attribute char '=>ucs)))
428 (insert (format "(=>ucs\t\t. #x%04X)\t; %c%s"
429 value (decode-char 'ucs value)
431 (setq attributes (delq '=>ucs attributes))
433 (when (and (memq '=>ucs* attributes)
434 (setq value (get-char-attribute char '=>ucs*)))
435 (insert (format "(=>ucs*\t\t. #x%04X)\t; %c%s"
436 value (decode-char 'ucs value)
438 (setq attributes (delq '=>ucs* attributes))
440 (when (and (memq '=>ucs-jis attributes)
441 (setq value (get-char-attribute char '=>ucs-jis)))
442 (insert (format "(=>ucs-jis\t\t. #x%04X)\t; %c%s"
443 value (decode-char 'ucs value)
445 (setq attributes (delq '=>ucs-jis attributes))
447 (when (and (memq '->ucs attributes)
448 (setq value (get-char-attribute char '->ucs)))
449 (insert (format (if char-db-convert-obsolete-format
450 "(=>ucs\t\t. #x%04X)\t; %c%s"
451 "(->ucs\t\t. #x%04X)\t; %c%s")
452 value (decode-char 'ucs value)
454 (setq attributes (delq '->ucs attributes))
456 (when (and (memq 'general-category attributes)
457 (setq value (get-char-attribute char 'general-category)))
459 "(general-category\t%s) ; %s%s"
460 (mapconcat (lambda (cell)
463 (cond ((rassoc value unidata-normative-category-alist)
464 "Normative Category")
465 ((rassoc value unidata-informative-category-alist)
466 "Informative Category")
470 (setq attributes (delq 'general-category attributes))
472 (when (and (memq 'bidi-category attributes)
473 (setq value (get-char-attribute char 'bidi-category)))
474 (insert (format "(bidi-category\t. %S)%s"
477 (setq attributes (delq 'bidi-category attributes))
479 (unless (or (not (memq 'mirrored attributes))
480 (eq (setq value (get-char-attribute char 'mirrored 'empty))
482 (insert (format "(mirrored\t\t. %S)%s"
485 (setq attributes (delq 'mirrored attributes))
488 ((and (memq 'decimal-digit-value attributes)
489 (setq value (get-char-attribute char 'decimal-digit-value)))
490 (insert (format "(decimal-digit-value . %S)%s"
493 (setq attributes (delq 'decimal-digit-value attributes))
494 (when (and (memq 'digit-value attributes)
495 (setq value (get-char-attribute char 'digit-value)))
496 (insert (format "(digit-value\t . %S)%s"
499 (setq attributes (delq 'digit-value attributes))
501 (when (and (memq 'numeric-value attributes)
502 (setq value (get-char-attribute char 'numeric-value)))
503 (insert (format "(numeric-value\t . %S)%s"
506 (setq attributes (delq 'numeric-value attributes))
510 (when (and (memq 'digit-value attributes)
511 (setq value (get-char-attribute char 'digit-value)))
512 (insert (format "(digit-value\t. %S)%s"
515 (setq attributes (delq 'digit-value attributes))
517 (when (and (memq 'numeric-value attributes)
518 (setq value (get-char-attribute char 'numeric-value)))
519 (insert (format "(numeric-value\t. %S)%s"
522 (setq attributes (delq 'numeric-value attributes))
524 (when (and (memq 'iso-10646-comment attributes)
525 (setq value (get-char-attribute char 'iso-10646-comment)))
526 (insert (format "(iso-10646-comment\t. %S)%s"
529 (setq attributes (delq 'iso-10646-comment attributes))
531 (when (and (memq 'morohashi-daikanwa attributes)
532 (setq value (get-char-attribute char 'morohashi-daikanwa)))
533 (insert (format "(morohashi-daikanwa\t%s)%s"
534 (mapconcat (function prin1-to-string) value " ")
536 (setq attributes (delq 'morohashi-daikanwa attributes))
540 (when (and (memq 'ideographic-radical attributes)
541 (setq value (get-char-attribute char 'ideographic-radical)))
543 (insert (format "(ideographic-radical . %S)\t; %c%s"
545 (aref ideographic-radicals radical)
547 (setq attributes (delq 'ideographic-radical attributes))
549 (when (and (memq 'ideographic-strokes attributes)
550 (setq value (get-char-attribute char 'ideographic-strokes)))
552 (insert (format "(ideographic-strokes . %S)%s"
555 (setq attributes (delq 'ideographic-strokes attributes))
557 (when (and (memq 'kangxi-radical attributes)
558 (setq value (get-char-attribute char 'kangxi-radical)))
559 (unless (eq value radical)
560 (insert (format "(kangxi-radical\t . %S)\t; %c%s"
562 (aref ideographic-radicals value)
565 (setq radical value)))
566 (setq attributes (delq 'kangxi-radical attributes))
568 (when (and (memq 'kangxi-strokes attributes)
569 (setq value (get-char-attribute char 'kangxi-strokes)))
570 (unless (eq value strokes)
571 (insert (format "(kangxi-strokes\t . %S)%s"
575 (setq strokes value)))
576 (setq attributes (delq 'kangxi-strokes attributes))
578 (when (and (memq 'japanese-radical attributes)
579 (setq value (get-char-attribute char 'japanese-radical)))
580 (unless (eq value radical)
581 (insert (format "(japanese-radical\t . %S)\t; %c%s"
583 (aref ideographic-radicals value)
586 (setq radical value)))
587 (setq attributes (delq 'japanese-radical attributes))
589 (when (and (memq 'japanese-strokes attributes)
590 (setq value (get-char-attribute char 'japanese-strokes)))
591 (unless (eq value strokes)
592 (insert (format "(japanese-strokes\t . %S)%s"
596 (setq strokes value)))
597 (setq attributes (delq 'japanese-strokes attributes))
599 (when (and (memq 'cns-radical attributes)
600 (setq value (get-char-attribute char 'cns-radical)))
601 (insert (format "(cns-radical\t . %S)\t; %c%s"
603 (aref ideographic-radicals value)
605 (setq attributes (delq 'cns-radical attributes))
607 (when (and (memq 'cns-strokes attributes)
608 (setq value (get-char-attribute char 'cns-strokes)))
609 (unless (eq value strokes)
610 (insert (format "(cns-strokes\t . %S)%s"
614 (setq strokes value)))
615 (setq attributes (delq 'cns-strokes attributes))
617 (when (and (memq 'shinjigen-1-radical attributes)
618 (setq value (get-char-attribute char 'shinjigen-1-radical)))
619 (unless (eq value radical)
620 (insert (format "(shinjigen-1-radical . %S)\t; %c%s"
622 (aref ideographic-radicals value)
625 (setq radical value)))
626 (setq attributes (delq 'shinjigen-1-radical attributes))
628 (when (and (memq 'total-strokes attributes)
629 (setq value (get-char-attribute char 'total-strokes)))
630 (insert (format "(total-strokes . %S)%s"
633 (setq attributes (delq 'total-strokes attributes))
635 (when (and (memq '->ideograph attributes)
636 (setq value (get-char-attribute char '->ideograph)))
637 (insert (format "(->ideograph\t%s)%s"
638 (mapconcat (lambda (code)
639 (cond ((symbolp code)
642 (format "#x%04X" code))
645 line-breaking code))))
648 (setq attributes (delq '->ideograph attributes))
650 (when (and (memq '->decomposition attributes)
651 (setq value (get-char-attribute char '->decomposition)))
652 (insert (format "(->decomposition\t%s)%s"
653 (mapconcat (lambda (code)
654 (cond ((symbolp code)
663 (format "#x%04X" code))
665 (format "%s%S" line-breaking code))))
668 (setq attributes (delq '->decomposition attributes))
670 (if (equal (get-char-attribute char '->titlecase)
671 (get-char-attribute char '->uppercase))
672 (setq attributes (delq '->titlecase attributes)))
673 (when (and (memq '->mojikyo attributes)
674 (setq value (get-char-attribute char '->mojikyo)))
675 (insert (format "(->mojikyo\t\t. %06d)\t; %c%s"
676 value (decode-char 'mojikyo value)
678 (setq attributes (delq '->mojikyo attributes))
680 (when (and (memq 'hanyu-dazidian-vol attributes)
681 (setq value (get-char-attribute char 'hanyu-dazidian-vol)))
682 (insert (format "(hanyu-dazidian-vol . %d)%s"
683 value line-breaking))
684 (setq attributes (delq 'hanyu-dazidian-vol attributes))
686 (when (and (memq 'hanyu-dazidian-page attributes)
687 (setq value (get-char-attribute char 'hanyu-dazidian-page)))
688 (insert (format "(hanyu-dazidian-page . %d)%s"
689 value line-breaking))
690 (setq attributes (delq 'hanyu-dazidian-page attributes))
692 (when (and (memq 'hanyu-dazidian-char attributes)
693 (setq value (get-char-attribute char 'hanyu-dazidian-char)))
694 (insert (format "(hanyu-dazidian-char . %d)%s"
695 value line-breaking))
696 (setq attributes (delq 'hanyu-dazidian-char attributes))
698 (when (and (not readable)
699 (memq '->ucs-variants attributes))
700 (setq attributes (delq '->ucs-variants attributes))
702 (setq rest ccs-attributes)
705 (setq value (get-char-attribute char (car rest)))
707 (if (>= (length (symbol-name (car rest))) 19)
709 (setq has-long-ccs-name t)
713 (setq rest (cdr rest)))
715 (setq name (car attributes))
716 (if (setq value (get-char-attribute char name))
717 (cond ((eq name 'jisx0208-1978/4X)
718 (insert (format "(%-18s . #x%04X)%s"
721 ((or (eq name 'ideographic-structure)
722 (string-match "^\\(->\\|<-\\)" (symbol-name name)))
723 ;; (memq name '(->lowercase
724 ;; ->uppercase ->titlecase
725 ;; ->fullwidth <-fullwidth
727 ;; ->vulgar-ideograph <-vulgar-ideograph
728 ;; ->ancient-ideograph <-ancient-ideograph
729 ;; ->original-ideograph <-original-ideograph
730 ;; ->simplified-ideograph <-simplified-ideograph
731 ;; ->wrong-ideograph <-wrong-ideograph
733 ;; ->ideographic-variants
735 ;; ->radical <-radical
736 ;; ->bopomofo <-bopomofo
737 ;; ->ideographic <-ideographic
738 ;; ideographic-structure))
739 (insert (format "(%-18s%s " name line-breaking))
740 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
743 (setq cell (car value))
745 (setq cell (decode-char 'ucs cell)))
746 (cond ((characterp cell)
750 (insert (format "%S" cell))
751 (char-db-insert-char-spec cell readable))
752 (setq separator lbs))
756 (if (consp (car cell))
757 (char-db-insert-char-spec cell readable)
758 (char-db-insert-char-reference cell readable))
759 (setq separator lbs))
763 (insert (prin1-to-string cell))
764 (setq separator " ")))
765 (setq value (cdr value)))
767 (insert line-breaking))
768 ((memq name '(ideograph=
769 original-ideograph-of
773 simplified-ideograph-of
775 ideographic-different-form-of))
776 (insert (format "(%-18s%s " name line-breaking))
777 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
780 (setq cell (car value))
781 (if (and (consp cell)
786 (char-db-insert-alist cell readable)
787 (setq separator lbs))
790 (insert (prin1-to-string cell))
791 (setq separator " "))
792 (setq value (cdr value)))
794 (insert line-breaking))
795 ;; ((string-match "^->" (symbol-name name))
797 ;; (format "(%-18s %s)%s"
799 ;; (mapconcat (lambda (code)
800 ;; (cond ((symbolp code)
801 ;; (symbol-name code))
803 ;; (format "#x%04X" code))
806 ;; line-breaking code))))
810 (insert (format "(%-18s " name))
811 (setq lbs (concat "\n" (make-string (current-column) ?\ ))
814 (setq cell (car value))
815 (if (and (consp cell)
817 (setq ret (condition-case nil
825 (setq key (car (car rest)))
826 (if (find-charset key)
827 (setq cal (cons key cal))
828 (setq al (cons key al)))
829 (setq rest (cdr rest)))
832 (insert-char-attributes ret
835 (setq separator lbs))
838 (insert (prin1-to-string cell))
839 (setq separator " "))
840 (setq value (cdr value)))
842 (insert line-breaking))
844 (insert (format "(%-18s . %S)%s"
848 (setq attributes (cdr attributes)))
849 (while ccs-attributes
850 (setq name (car ccs-attributes))
851 (if (and (eq name (charset-name name))
852 (setq value (get-char-attribute char name)))
855 (cond ((memq name '(ideograph-daikanwa-2
859 (if has-long-ccs-name
860 "(%-26s . %05d)\t; %c%s"
861 "(%-18s . %05d)\t; %c%s"))
863 (if has-long-ccs-name
864 "(%-26s . %06d)\t; %c%s"
865 "(%-18s . %06d)\t; %c%s"))
867 (if has-long-ccs-name
868 "(%-26s . #x%04X)\t; %c%s"
869 "(%-18s . #x%04X)\t; %c%s"))
871 (if has-long-ccs-name
872 "(%-26s . #x%02X)\t; %c%s"
873 "(%-18s . #x%02X)\t; %c%s")))
875 (if (= (charset-iso-graphic-plane name) 1)
877 (cond ((= (charset-dimension name) 1)
879 ((= (charset-dimension name) 2)
881 ((= (charset-dimension name) 3)
885 (char-db-decode-isolated-char name value)
887 (setq ccs-attributes (cdr ccs-attributes)))
890 (defun insert-char-data (char &optional readable
891 attributes ccs-attributes)
893 (narrow-to-region (point)(point))
894 (insert "(define-char
896 (insert-char-attributes char readable
897 attributes ccs-attributes)
899 (goto-char (point-min))
900 (while (re-search-forward "[ \t]+$" nil t)
902 (goto-char (point-max))
903 (tabify (point-min)(point-max))
907 (defun char-db-update-comment ()
910 (goto-char (point-min))
911 (let (cdef table char)
912 (while (re-search-forward "^[ \t]*\\(([^.()]+)\\)" nil t)
913 (goto-char (match-beginning 1))
914 (setq cdef (read (current-buffer)))
915 (when (find-charset (car cdef))
916 (goto-char (match-end 0))
919 (not (eq (car cdef) 'ideograph-daikanwa))
920 (or (memq (car cdef) '(ascii latin-viscii-upper
924 japanese-jisx0213-2))
925 (= (char-int (charset-iso-final-char (car cdef)))
927 (apply (function make-char) cdef)
928 (if (setq table (charset-mapping-table (car cdef)))
929 (set-charset-mapping-table (car cdef) nil))
931 (apply (function make-char) cdef)
933 (set-charset-mapping-table (car cdef) table)))))
934 (when (not (or (< (char-int char) 32)
935 (and (<= 128 (char-int char))
936 (< (char-int char) 160))))
937 (delete-region (point) (point-at-eol))
938 (insert (format "\t; %c" char)))
941 (defun insert-char-data-with-variant (char &optional printable
943 script excluded-script)
944 (insert-char-data char printable)
945 (let ((variants (or (char-variants char)
946 (let ((ucs (get-char-attribute char '->ucs)))
948 (delete char (char-variants (int-char ucs)))))))
950 (setq variants (sort variants #'<))
952 (setq variant (car variants))
953 (if (and (or (null script)
954 (null (setq vs (get-char-attribute variant 'script)))
956 (or (null excluded-script)
957 (null (setq vs (get-char-attribute variant 'script)))
958 (not (memq excluded-script vs))))
959 (or (and no-ucs-variant (get-char-attribute variant 'ucs))
960 (insert-char-data variant printable)))
961 (setq variants (cdr variants))
964 (defun insert-char-range-data (min max &optional script excluded-script)
968 (setq char (decode-char 'ucs code))
969 (if (get-char-attribute char 'ucs)
970 (insert-char-data-with-variant char nil 'no-ucs-variant
971 script excluded-script))
972 (setq code (1+ code))
975 (defun write-char-range-data-to-file (min max file
976 &optional script excluded-script)
977 (let ((coding-system-for-write 'utf-8))
979 (insert-char-range-data min max script excluded-script)
980 (write-region (point-min)(point-max) file))))
982 (defvar what-character-original-window-configuration)
985 (defun what-char-definition (char)
986 (interactive (list (char-after)))
987 (let ((buf (get-buffer-create "*Character Description*"))
988 (the-buf (current-buffer))
989 (win-conf (current-window-configuration)))
991 (make-local-variable 'what-character-original-window-configuration)
992 (setq what-character-original-window-configuration win-conf)
993 (setq buffer-read-only nil)
997 (insert-char-data-with-variant char 'printable)
998 (unless (char-attribute-alist char)
999 (insert (format ";; = %c\n"
1000 (let* ((rest (split-char char))
1004 (setq code (logior (lsh code 8)
1006 (decode-char ccs code)))))
1007 ;; (char-db-update-comment)
1008 (set-buffer-modified-p nil)
1009 (view-mode the-buf (lambda (buf)
1010 (set-window-configuration
1011 what-character-original-window-configuration)
1013 (goto-char (point-min)))
1015 (set-window-configuration
1016 what-character-original-window-configuration)
1017 (signal (car err) (cdr err)))))))
1019 (provide 'char-db-util)
1021 ;;; char-db-util.el ends here