(shuowen-radicals): Add ?夕, ?多, ?毌, ?㔾, ?𣎺, ?𠧪, ?齊, ?朿, ?片
[chise/xemacs-chise.git-] / lisp / utf-2000 / char-db-util.el
1 ;;; char-db-util.el --- Character Database utility -*- coding: utf-8-er; -*-
2
3 ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
4 ;;   2007 MORIOKA Tomohiko.
5
6 ;; Author: MORIOKA Tomohiko <tomo@kanji.zinbun.kyoto-u.ac.jp>
7 ;; Keywords: CHISE, Character Database, ISO/IEC 10646, UCS, Unicode, MULE.
8
9 ;; This file is part of XEmacs CHISE.
10
11 ;; XEmacs CHISE is free software; you can redistribute it and/or
12 ;; modify it under the terms of the GNU General Public License as
13 ;; published by the Free Software Foundation; either version 2, or (at
14 ;; your option) any later version.
15
16 ;; XEmacs CHISE is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19 ;; General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with XEmacs CHISE; see the file COPYING.  If not, write to
23 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
25
26 ;;; Code:
27
28 (require 'alist)
29
30 (defconst unidata-normative-category-alist
31   '(("Lu" letter        uppercase)
32     ("Ll" letter        lowercase)
33     ("Lt" letter        titlecase)
34     ("Mn" mark          non-spacing)
35     ("Mc" mark          spacing-combining)
36     ("Me" mark          enclosing)
37     ("Nd" number        decimal-digit)
38     ("Nl" number        letter)
39     ("No" number        other)
40     ("Zs" separator     space)
41     ("Zl" separator     line)
42     ("Zp" separator     paragraph)
43     ("Cc" other         control)
44     ("Cf" other         format)
45     ("Cs" other         surrogate)
46     ("Co" other         private-use)
47     ("Cn" other         not-assigned)))
48
49 (defconst unidata-informative-category-alist
50   '(("Lm" letter        modifier)
51     ("Lo" letter        other)
52     ("Pc" punctuation   connector)
53     ("Pd" punctuation   dash)
54     ("Ps" punctuation   open)
55     ("Pe" punctuation   close)
56     ("Pi" punctuation   initial-quote)
57     ("Pf" punctuation   final-quote)
58     ("Po" punctuation   other)
59     ("Sm" symbol        math)
60     ("Sc" symbol        currency)
61     ("Sk" symbol        modifier)
62     ("So" symbol        other)
63     ))
64
65 (defconst ideographic-radicals
66   (let ((v (make-vector 215 nil))
67         (i 1))
68     (while (< i 215)
69       (aset v i (decode-char '=ucs (+ #x2EFF i)))
70       (setq i (1+ i)))
71     v))
72
73 (defun ideographic-radical (number)
74   (aref ideographic-radicals number))
75
76 (defconst shuowen-radicals
77   [?一 ?上 ?示 ?三 ?王 ?玉 ?玨 ?气 ?士 ?丨 ; 010
78    ?屮 ?艸 ?蓐 ?茻 ?小 ?八 ?釆 ?半 ?牛 ?犛 ; 020
79    ?告 ?口 ?凵 ?吅 ?哭 ?走 ?止 ?癶 ?步 ?此 ; 030
80    ?正 ?是 ?辵 ?彳 ?廴 ?㢟 ?行 ?齒 ?牙 ?足 ; 040
81    ?疋 ?品 ?龠 ?冊 ?㗊 ?舌 ?干 ?谷 ?只 ?㕯 ; 050
82    ?句 ?丩 ?古 ?十 ?卅 ?言 ?誩 ?音 ?䇂 ?丵 ; 060
83    ?菐 ?𠬞 ?廾 ?共 ?異 ?舁 ?𦥑 ?䢅 ?爨 ?革 ; 070
84    ?鬲 ?䰜 ?爪 ?𠃨 ?鬥 ?又 ?𠂇 ?㕜 ?支 ?𦘒 ; 080
85    ?聿 ?畫 ?隶 ?臤 ?臣 ?殳 ?殺 ?𠘧 ?寸 ?皮 ; 090
86    ?㼱 ?攴 ?敎 ?卜 ?用 ?爻 ?㸚 ?𥄎 ?目 ?䀠 ; 100
87    ?眉 ?盾 ?自 ?白 ?鼻 ?皕 ?習 ?羽 ?隹 ?奞 ; 110
88    ?萑 ?𦫳 ?苜 ?羊 ?羴 ?瞿 ?雔 ?雥 ?鳥 ?烏 ; 120
89    ?𠦒 ?冓 ?幺 ?𢆶 ?叀 ?玄 ?予 ?放 ?𠬪 ?𣦼 ; 130
90    ?歺 ?死 ?冎 ?骨 ?肉 ?筋 ?刀 ?刃 ?㓞 ?丰 ; 140
91    ?耒 ?𧢲 ?竹 ?箕 ?丌 ?左 ?工 ?㠭 ?巫 ?甘 ; 150
92    ?曰 ?乃 ?丂 ?可 ?兮 ?号 ?亏 ?旨 ?喜 ?壴 ; 160
93    ?鼓 ?豈 ?豆 ?豊 ?豐 ?䖒 ?虍 ?虎 ?虤 ?皿 ; 170
94    ?𠙴 ?去 ?血 ?丶 ?丹 ?青 ?井 ?皀 ?鬯 ?食 ; 180
95    ?亼 ?會 ?倉 ?入 ?缶 ?矢 ?高 ?冂 ?𩫏 ?京 ; 190
96    ?亯 ?𣆪 ?畗 ?㐭 ?嗇 ?來 ?麥 ?夊 ?舛 ?䑞 ; 200
97    ?韋 ?弟 ?夂 ?久 ?桀 ?木 ?東 ?林 ?才 ?叒 ; 210
98    ?之 ?帀 ?出 ?𣎵 ?生 ?乇 ?𠂹 ?𠌶 ?華 ?𥝌 ; 220
99    ?稽 ?巢 ?桼 ?束 ?㯻 ?囗 ?員 ?貝 ?邑 ?𨛜 ; 230
100    ?日 ?旦 ?倝 ?㫃 ?冥 ?晶 ?月 ?有 ?明 ?囧 ; 240
101    ?夕 ?多 ?毌 ?㔾 ?𣎺 ?𠧪 ?齊 ?朿 ?片 ?鼎 ; 250
102    ])
103
104 (defun shuowen-radical (number)
105   (aref shuowen-radicals (1- number)))
106
107 (defvar char-db-file-coding-system 'utf-8-mcs-er)
108
109 (defvar char-db-feature-domains
110   '(ucs ucs/compat daikanwa cns gt jis jis/alt jis/a jis/b
111         jis-x0212 jis-x0213 cdp shinjigen misc unknown))
112
113 (defvar char-db-ignored-attributes '(ideographic-products))
114
115 (defun char-attribute-name< (ka kb)
116   (cond
117    ((eq '->denotational kb)
118     t)
119    ((eq '->subsumptive kb)
120     (not (eq '->denotational ka)))
121    ((eq '->denotational ka)
122     nil)
123    ((eq '->subsumptive ka)
124     nil)
125    ((and (symbolp ka)
126          (string-match "^->" (symbol-name ka)))
127     (cond ((and (symbolp kb)
128                 (string-match "^->" (symbol-name kb)))
129            (string< (symbol-name ka)
130                     (symbol-name kb))
131            ))
132     )
133    ((and (symbolp kb)
134          (string-match "^->" (symbol-name kb)))
135     t)
136    ((and (symbolp ka)
137          (string-match "^<-" (symbol-name ka)))
138     (cond ((symbolp kb)
139            (cond ((string-match "^<-" (symbol-name kb))
140                   (string< (symbol-name ka)
141                            (symbol-name kb))
142                   )
143                  ;; ((string-match "^->" (symbol-name kb))
144                  ;;  t)
145                  )))
146     )
147    ((and (symbolp kb)
148          (string-match "^<-" (symbol-name kb)))
149     t
150     ;; (not (string-match "^->" (symbol-name ka)))
151     )
152    ((find-charset ka)
153     (if (find-charset kb)
154         (if (<= (charset-id ka) 1)
155             (if (<= (charset-id kb) 1)
156                 (cond
157                  ((= (charset-dimension ka)
158                      (charset-dimension kb))
159                   (> (charset-id ka)(charset-id kb)))
160                  (t
161                   (> (charset-dimension ka)
162                      (charset-dimension kb))
163                   ))
164               t)
165           (if (<= (charset-id kb) 1)
166               nil
167             (< (charset-id ka)(charset-id kb))))
168       nil))
169    ((find-charset kb)
170     t)
171    ((symbolp ka)
172     (cond ((symbolp kb)
173            (string< (symbol-name ka)
174                     (symbol-name kb)))
175           (t)))
176    ((symbolp kb)
177     nil)))
178
179 (defvar char-db-coded-charset-priority-list
180   '(ascii
181     control-1
182     latin-iso8859-1
183     latin-iso8859-2
184     latin-iso8859-3
185     latin-iso8859-4
186     latin-iso8859-9
187     latin-jisx0201
188     cyrillic-iso8859-5
189     greek-iso8859-7
190     thai-tis620
191     =jis-x0208
192     =jis-x0208@1978
193     =jis-x0208@1983
194     japanese-jisx0212
195     chinese-gb2312
196     =jis-x0208@1990
197     chinese-cns11643-1
198     chinese-cns11643-2
199     chinese-cns11643-3
200     chinese-cns11643-4
201     chinese-cns11643-5
202     chinese-cns11643-6
203     chinese-cns11643-7
204     =jis-x0213-1-2000
205     =jis-x0213-2-2000
206     korean-ksc5601
207     chinese-isoir165
208     katakana-jisx0201
209     hebrew-iso8859-8
210     chinese-gb12345
211     latin-viscii
212     ethiopic-ucs
213     =big5-cdp
214     =gt
215     ideograph-daikanwa-2
216     ideograph-daikanwa
217     =cbeta
218     ideograph-hanziku-1
219     ideograph-hanziku-2
220     ideograph-hanziku-3
221     ideograph-hanziku-4
222     ideograph-hanziku-5
223     ideograph-hanziku-6
224     ideograph-hanziku-7
225     ideograph-hanziku-8
226     ideograph-hanziku-9
227     ideograph-hanziku-10
228     ideograph-hanziku-11
229     ideograph-hanziku-12
230     =gt-k
231     =ucs@iso
232     =ucs@unicode
233     =big5
234     =big5-eten
235     =jis-x0208@1997
236     =zinbun-oracle
237     =ruimoku-v6
238     =jef-china3))
239
240 (defun char-db-make-char-spec (char)
241   (let (ret char-spec)
242     (cond ((characterp char)
243            (cond ((and (setq ret (encode-char char '=ucs 'defined-only))
244                        (not (and (<= #xE000 ret)(<= ret #xF8FF))))
245                   (setq char-spec (list (cons '=ucs ret)))
246                   (cond ((setq ret (get-char-attribute char 'name))
247                          (setq char-spec (cons (cons 'name ret) char-spec))
248                          )
249                         ((setq ret (get-char-attribute char 'name*))
250                          (setq char-spec (cons (cons 'name* ret) char-spec))
251                          ))
252                   )
253                  ((setq ret
254                         (catch 'tag
255                           (let ((rest char-db-coded-charset-priority-list)
256                                 ccs)
257                             (while rest
258                               (setq ccs (charset-name
259                                          (find-charset (car rest))))
260                               (if (setq ret
261                                         (encode-char char ccs
262                                                      'defined-only))
263                                   (throw 'tag (cons ccs ret)))
264                               (setq rest (cdr rest))))))
265                   (setq char-spec (list ret))
266                   (dolist (ccs (delq (car ret) (charset-list)))
267                     (if (and (or (charset-iso-final-char ccs)
268                                  (memq ccs
269                                        '(=daikanwa
270                                          =daikanwa@rev2
271                                          ;; =gt-k
272                                          =jis-x0208@1997
273                                          )))
274                              (setq ccs (charset-name ccs))
275                              (null (assq ccs char-spec))
276                              (setq ret (encode-char char ccs 'defined-only)))
277                         (setq char-spec (cons (cons ccs ret) char-spec))))
278                   (if (null char-spec)
279                       (setq char-spec (split-char char)))
280                   (cond ((setq ret (get-char-attribute char 'name))
281                          (setq char-spec (cons (cons 'name ret) char-spec))
282                          )
283                         ((setq ret (get-char-attribute char 'name*))
284                          (setq char-spec (cons (cons 'name* ret) char-spec))
285                          ))
286                   ))
287            char-spec)
288           ((consp char)
289            char))))
290     
291 (defun char-db-insert-char-spec (char &optional readable column
292                                       required-features)
293   (unless column
294     (setq column (current-column)))
295   (let (char-spec temp-char)
296     (setq char-spec (char-db-make-char-spec char))
297     (unless (or (characterp char) ; char
298                 (condition-case nil
299                     (setq char (find-char char-spec))
300                   (error nil)))
301       ;; define temporary character
302       ;;   Current implementation is dirty.
303       (setq temp-char (define-char (cons '(ideograph-daikanwa . 0)
304                                          char-spec)))
305       (remove-char-attribute temp-char 'ideograph-daikanwa)
306       (setq char temp-char))
307     (insert-char-attributes char
308                             readable
309                             (union (mapcar #'car char-spec)
310                                    required-features))
311     (when temp-char
312       ;; undefine temporary character
313       ;;   Current implementation is dirty.
314       (setq char-spec (char-attribute-alist temp-char))
315       (while char-spec
316         (remove-char-attribute temp-char (car (car char-spec)))
317         (setq char-spec (cdr char-spec))))))
318
319 (defun char-db-insert-alist (alist &optional readable column)
320   (unless column
321     (setq column (current-column)))
322   (let ((line-breaking
323          (concat "\n" (make-string (1+ column) ?\ )))
324         name value
325         ret al ; cal
326         key
327         lbs cell rest separator)
328     (insert "(")
329     (while alist
330       (setq name (car (car alist))
331             value (cdr (car alist)))
332       (cond ((eq name 'char)
333              (insert "(char . ")
334              (if (setq ret (condition-case nil
335                                (find-char value)
336                              (error nil)))
337                  (progn
338                    (setq al nil
339                          ;; cal nil
340                          )
341                    (while value
342                      (setq key (car (car value)))
343                      ;; (if (find-charset key)
344                      ;;     (setq cal (cons key cal))
345                      (setq al (cons key al))
346                      ;; )
347                      (setq value (cdr value)))
348                    (insert-char-attributes ret
349                                            readable
350                                            (or al 'none) ; cal
351                                            ))
352                (insert (prin1-to-string value)))
353              (insert ")")
354              (insert line-breaking))
355             ((consp value)
356              (insert (format "(%-18s " name))
357              (setq lbs (concat "\n" (make-string (current-column) ?\ )))
358              (while (consp value)
359                (setq cell (car value))
360                (if (and (consp cell)
361                         (consp (car cell))
362                         (setq ret (condition-case nil
363                                       (find-char cell)
364                                     (error nil)))
365                         )
366                    (progn
367                      (setq rest cell
368                            al nil
369                            ;; cal nil
370                            )
371                      (while rest
372                        (setq key (car (car rest)))
373                        ;; (if (find-charset key)
374                        ;;     (setq cal (cons key cal))
375                        (setq al (cons key al))
376                        ;; )
377                        (setq rest (cdr rest)))
378                      (if separator
379                          (insert lbs))
380                      (insert-char-attributes ret
381                                              readable
382                                              al ; cal
383                                              )
384                      (setq separator lbs))
385                  (if separator
386                      (insert separator))
387                  (insert (prin1-to-string cell))
388                  (setq separator " "))
389                (setq value (cdr value)))
390              (insert ")")
391              (insert line-breaking))
392             (t
393              (insert (format "(%-18s . %S)%s"
394                              name value
395                              line-breaking))))
396       (setq alist (cdr alist))))
397   (insert ")"))
398
399 (defun char-db-insert-char-reference (plist &optional readable column)
400   (unless column
401     (setq column (current-column)))
402   (let ((line-breaking
403          (concat "\n" (make-string (1+ column) ?\ )))
404         (separator "")
405         name value)
406     (insert "(")
407     (while plist
408       (setq name (pop plist))
409       (setq value (pop plist))
410       (cond ((eq name :char)
411              (insert separator)
412              (insert ":char\t")
413              (cond ((numberp value)
414                     (setq value (decode-char '=ucs value)))
415                    ;; ((consp value)
416                    ;;  (setq value (or (find-char value)
417                    ;;                  value)))
418                    )
419              (char-db-insert-char-spec value readable)
420              (insert line-breaking)
421              (setq separator ""))
422             ((eq name :radical)
423              (insert (format "%s%s\t%d ; %c%s"
424                              separator
425                              name value
426                              (ideographic-radical value)
427                              line-breaking))
428              (setq separator ""))
429             (t
430              (insert (format "%s%s\t%S" separator name value))
431              (setq separator line-breaking)))
432       ))
433   (insert ")"))
434
435 (defun char-db-decode-isolated-char (ccs code-point)
436   (let (ret)
437     (setq ret
438           (cond ((eq ccs 'arabic-iso8859-6)
439                  (decode-char ccs code-point))
440                 ((and (memq ccs '(=gt-pj-1
441                                   =gt-pj-2
442                                   =gt-pj-3
443                                   =gt-pj-4
444                                   =gt-pj-5
445                                   =gt-pj-6
446                                   =gt-pj-7
447                                   =gt-pj-8
448                                   =gt-pj-9
449                                   =gt-pj-10
450                                   =gt-pj-11))
451                       (setq ret (decode-char ccs code-point))
452                       (setq ret (encode-char ret '=gt 'defined-only)))
453                  (decode-builtin-char '=gt ret))
454                 (t
455                  (decode-builtin-char ccs code-point))))
456     (cond ((and (<= 0 (char-int ret))
457                 (<= (char-int ret) #x1F))
458            (decode-char '=ucs (+ #x2400 (char-int ret))))
459           ((= (char-int ret) #x7F)
460            ?\u2421)
461           (t ret))))
462
463 (defvar char-db-convert-obsolete-format t)
464
465 (defun char-db-insert-ccs-feature (name value line-breaking)
466   (insert
467    (format
468     (cond ((or (memq name '(=daikanwa
469                             =daikanwa@rev1 =daikanwa@rev2
470                             =gt =gt-k =cbeta =zinbun-oracle))
471                (string-match "^=adobe-" (symbol-name name)))
472            "(%-18s . %05d)\t; %c")
473           ((eq name 'mojikyo)
474            "(%-18s . %06d)\t; %c")
475           ((>= (charset-dimension name) 2)
476            "(%-18s . #x%04X)\t; %c")
477           (t
478            "(%-18s . #x%02X)\t; %c"))
479     name
480     (if (= (charset-iso-graphic-plane name) 1)
481         (logior value
482                 (cond ((= (charset-dimension name) 1)
483                        #x80)
484                       ((= (charset-dimension name) 2)
485                        #x8080)
486                       ((= (charset-dimension name) 3)
487                        #x808080)
488                       (t 0)))
489       value)
490     (char-db-decode-isolated-char name value)))
491   (if (and (= (charset-chars name) 94)
492            (= (charset-dimension name) 2))
493       (insert (format " [%02d-%02d]"
494                       (- (lsh value -8) 32)
495                       (- (logand value 255) 32))))
496   (insert line-breaking))
497
498 (defun char-db-insert-relation-feature (char name value line-breaking
499                                              ccss readable)
500   (insert (format "(%-18s%s " name line-breaking))
501   (let ((lbs (concat "\n" (make-string (current-column) ?\ )))
502         separator cell sources required-features
503         ret)
504     (while (consp value)
505       (setq cell (car value))
506       (if (integerp cell)
507           (setq cell (decode-char '=ucs cell)))
508       (cond
509        ((eq name '->subsumptive)
510         (when (or (not (some (lambda (atr)
511                                (get-char-attribute cell atr))
512                              char-db-ignored-attributes))
513                   (some (lambda (ccs)
514                           (encode-char cell ccs 'defined-only))
515                         ccss))
516           (if separator
517               (insert lbs))
518           (let ((char-db-ignored-attributes
519                  (cons '<-subsumptive
520                        char-db-ignored-attributes)))
521             (insert-char-attributes cell readable))
522           (setq separator lbs))
523         )
524        ((characterp cell)
525         (setq sources
526               (get-char-attribute
527                char (intern (format "%s*sources" name))))
528         (setq required-features nil)
529         (dolist (source sources)
530           (cond
531            ((memq source '(JP JP/Jouyou shinjigen-1))
532             (setq required-features
533                   (union required-features
534                          '(=jis-x0208
535                            =jis-x0208@1990
536                            =jis-x0213-1-2000
537                            =jis-x0213-2-2000
538                            =jis-x0212
539                            =jis-x0208@1983
540                            =jis-x0208@1978))))
541            ((eq source 'CN)
542             (setq required-features
543                   (union required-features
544                          '(=gb2312
545                            =gb12345
546                            =iso-ir165)))))
547           (cond
548            ((find-charset (setq ret (intern (format "=%s" source))))
549             (setq required-features
550                   (cons ret required-features)))
551            (t (setq required-features
552                     (cons source required-features)))))
553         (cond ((string-match "@JP" (symbol-name name))
554                (setq required-features
555                      (union required-features
556                             '(=jis-x0208
557                               =jis-x0208@1990
558                               =jis-x0213-1-2000
559                               =jis-x0213-2-2000
560                               =jis-x0212
561                               =jis-x0208@1983
562                               =jis-x0208@1978))))
563               ((string-match "@CN" (symbol-name name))
564                (setq required-features
565                      (union required-features
566                             '(=gb2312
567                               =gb12345
568                               =iso-ir165)))))
569         (if separator
570             (insert lbs))
571         (if readable
572             (insert (format "%S" cell))
573           (char-db-insert-char-spec cell readable
574                                     nil
575                                     required-features))
576         (setq separator lbs))
577        ((consp cell)
578         (if separator
579             (insert lbs))
580         (if (consp (car cell))
581             (char-db-insert-char-spec cell readable)
582           (char-db-insert-char-reference cell readable))
583         (setq separator lbs))
584        (t
585         (if separator
586             (insert separator))
587         (insert (prin1-to-string cell))
588         (setq separator " ")))
589       (setq value (cdr value)))
590     (insert ")")
591     (insert line-breaking)))
592
593 (defun insert-char-attributes (char &optional readable attributes column)
594   (unless column
595     (setq column (current-column)))
596   (let (name value ; has-long-ccs-name
597         rest
598         radical strokes
599         (line-breaking
600          (concat "\n" (make-string (1+ column) ?\ )))
601         lbs cell separator ret
602         key al cal
603         dest-ccss ; sources required-features
604         ccss)
605     (let (atr-d)
606       (setq attributes
607             (sort (if attributes
608                       (if (consp attributes)
609                           (progn
610                             (dolist (name attributes)
611                               (unless (memq name char-db-ignored-attributes)
612                                 (if (find-charset name)
613                                     (push name ccss))
614                                 (push name atr-d)))
615                             atr-d))
616                     (dolist (name (char-attribute-list))
617                       (unless (memq name char-db-ignored-attributes)
618                         (if (find-charset name)
619                             (push name ccss))
620                         (push name atr-d)))
621                     atr-d)
622                   #'char-attribute-name<)))
623     (insert "(")
624     (when (memq '<-subsumptive attributes)
625       (when readable
626         (when (setq value (get-char-attribute char '<-subsumptive))
627           (char-db-insert-relation-feature char '<-subsumptive value
628                                            line-breaking
629                                            ccss readable)))
630       (setq attributes (delq '<-subsumptive attributes)))
631     (when (and (memq '<-denotational attributes)
632                (setq value (get-char-attribute char '<-denotational)))
633       (char-db-insert-relation-feature char '<-denotational value
634                                        line-breaking
635                                        ccss readable)
636       (setq attributes (delq '<-denotational attributes)))
637     (when (and (memq 'name attributes)
638                (setq value (get-char-attribute char 'name)))
639       (insert (format
640                (if (> (+ (current-column) (length value)) 48)
641                    "(name . %S)%s"
642                  "(name               . %S)%s")
643                value line-breaking))
644       (setq attributes (delq 'name attributes))
645       )
646     (when (and (memq 'name* attributes)
647                (setq value (get-char-attribute char 'name*)))
648       (insert (format
649                (if (> (+ (current-column) (length value)) 48)
650                    "(name* . %S)%s"
651                  "(name*              . %S)%s")
652                value line-breaking))
653       (setq attributes (delq 'name* attributes))
654       )
655     (when (and (memq 'script attributes)
656                (setq value (get-char-attribute char 'script)))
657       (insert (format "(script\t\t%s)%s"
658                       (mapconcat (function prin1-to-string)
659                                  value " ")
660                       line-breaking))
661       (setq attributes (delq 'script attributes))
662       )
663     (dolist (name '(=>ucs =>ucs*))
664       (when (and (memq name attributes)
665                  (setq value (get-char-attribute char name)))
666         (insert (format "(%-18s . #x%04X)\t; %c%s"
667                         name value (decode-char '=ucs value)
668                         line-breaking))
669         (setq attributes (delq name attributes))))
670     (dolist (name '(=>ucs@gb =>ucs@cns =>ucs@jis =>ucs@ks =>ucs@big5))
671       (when (and (memq name attributes)
672                  (setq value (get-char-attribute char name)))
673         (insert (format "(%-18s . #x%04X)\t; %c%s"
674                         name value
675                         (decode-char (intern
676                                       (concat "="
677                                               (substring
678                                                (symbol-name name) 2)))
679                                      value)
680                         line-breaking))
681         (setq attributes (delq name attributes))
682         ))
683     (dolist (name '(=>daikanwa))
684       (when (and (memq name attributes)
685                  (setq value (get-char-attribute char name)))
686         (insert
687          (if (integerp value)
688              (format "(%-18s . %05d)\t; %c%s"
689                      name value (decode-char '=daikanwa value)
690                      line-breaking)
691            (format "(%-18s %s)\t; %c%s"
692                    name
693                    (mapconcat (function prin1-to-string)
694                               value " ")
695                    (char-representative-of-daikanwa char)
696                    line-breaking)))
697         (setq attributes (delq name attributes))))
698     (when (and (memq 'general-category attributes)
699                (setq value (get-char-attribute char 'general-category)))
700       (insert (format
701                "(general-category\t%s) ; %s%s"
702                (mapconcat (lambda (cell)
703                             (format "%S" cell))
704                           value " ")
705                (cond ((rassoc value unidata-normative-category-alist)
706                       "Normative Category")
707                      ((rassoc value unidata-informative-category-alist)
708                       "Informative Category")
709                      (t
710                       "Unknown Category"))
711                line-breaking))
712       (setq attributes (delq 'general-category attributes))
713       )
714     (when (and (memq 'bidi-category attributes)
715                (setq value (get-char-attribute char 'bidi-category)))
716       (insert (format "(bidi-category\t. %S)%s"
717                       value
718                       line-breaking))
719       (setq attributes (delq 'bidi-category attributes))
720       )
721     (unless (or (not (memq 'mirrored attributes))
722                 (eq (setq value (get-char-attribute char 'mirrored 'empty))
723                     'empty))
724       (insert (format "(mirrored\t\t. %S)%s"
725                       value
726                       line-breaking))
727       (setq attributes (delq 'mirrored attributes))
728       )
729     (cond
730      ((and (memq 'decimal-digit-value attributes)
731            (setq value (get-char-attribute char 'decimal-digit-value)))
732       (insert (format "(decimal-digit-value . %S)%s"
733                       value
734                       line-breaking))
735       (setq attributes (delq 'decimal-digit-value attributes))
736       (when (and (memq 'digit-value attributes)
737                  (setq value (get-char-attribute char 'digit-value)))
738         (insert (format "(digit-value\t . %S)%s"
739                         value
740                         line-breaking))
741         (setq attributes (delq 'digit-value attributes))
742         )
743       (when (and (memq 'numeric-value attributes)
744                  (setq value (get-char-attribute char 'numeric-value)))
745         (insert (format "(numeric-value\t . %S)%s"
746                         value
747                         line-breaking))
748         (setq attributes (delq 'numeric-value attributes))
749         )
750       )
751      (t
752       (when (and (memq 'digit-value attributes)
753                  (setq value (get-char-attribute char 'digit-value)))
754         (insert (format "(digit-value\t. %S)%s"
755                         value
756                         line-breaking))
757         (setq attributes (delq 'digit-value attributes))
758         )
759       (when (and (memq 'numeric-value attributes)
760                  (setq value (get-char-attribute char 'numeric-value)))
761         (insert (format "(numeric-value\t. %S)%s"
762                         value
763                         line-breaking))
764         (setq attributes (delq 'numeric-value attributes))
765         )))
766     (when (and (memq 'iso-10646-comment attributes)
767                (setq value (get-char-attribute char 'iso-10646-comment)))
768       (insert (format "(iso-10646-comment\t. %S)%s"
769                       value
770                       line-breaking))
771       (setq attributes (delq 'iso-10646-comment attributes))
772       )
773     (when (and (memq 'morohashi-daikanwa attributes)
774                (setq value (get-char-attribute char 'morohashi-daikanwa)))
775       (insert (format "(morohashi-daikanwa\t%s)%s"
776                       (mapconcat (function prin1-to-string) value " ")
777                       line-breaking))
778       (setq attributes (delq 'morohashi-daikanwa attributes))
779       )
780     (setq radical nil
781           strokes nil)
782     (when (and (memq 'ideographic-radical attributes)
783                (setq value (get-char-attribute char 'ideographic-radical)))
784       (setq radical value)
785       (insert (format "(ideographic-radical . %S)\t; %c%s"
786                       radical
787                       (ideographic-radical radical)
788                       line-breaking))
789       (setq attributes (delq 'ideographic-radical attributes))
790       )
791     (when (and (memq 'shuowen-radical attributes)
792                (setq value (get-char-attribute char 'shuowen-radical)))
793       (insert (format "(shuowen-radical\t. %S)\t; %c%s"
794                       value
795                       (shuowen-radical value)
796                       line-breaking))
797       (setq attributes (delq 'shuowen-radical attributes))
798       )
799     (let (key)
800       (dolist (domain
801                (append
802                 char-db-feature-domains
803                 (let (dest domain)
804                   (dolist (feature (char-attribute-list))
805                     (setq feature (symbol-name feature))
806                     (when (string-match
807                            "\\(radical\\|strokes\\)@\\([^@*]+\\)\\(\\*\\|$\\)"
808                            feature)
809                       (setq domain (intern (match-string 2 feature)))
810                      (unless (memq domain dest)
811                        (setq dest (cons domain dest)))))
812                   (sort dest #'string<))))
813         (setq key (intern (format "%s@%s" 'ideographic-radical domain)))
814         (when (and (memq key attributes)
815                    (setq value (get-char-attribute char key)))
816           (setq radical value)
817           (insert (format "(%s . %S)\t; %c%s"
818                           key
819                           radical
820                           (ideographic-radical radical)
821                           line-breaking))
822           (setq attributes (delq key attributes))
823           )
824         (setq key (intern (format "%s@%s" 'ideographic-strokes domain)))
825         (when (and (memq key attributes)
826                    (setq value (get-char-attribute char key)))
827           (setq strokes value)
828           (insert (format "(%s . %S)%s"
829                           key
830                           strokes
831                           line-breaking))
832           (setq attributes (delq key attributes))
833           )
834         (setq key (intern (format "%s@%s" 'total-strokes domain)))
835         (when (and (memq key attributes)
836                    (setq value (get-char-attribute char key)))
837           (insert (format "(%s       . %S)%s"
838                           key
839                           value
840                           line-breaking))
841           (setq attributes (delq key attributes))
842           )
843         (dolist (feature '(ideographic-radical
844                            ideographic-strokes
845                            total-strokes))
846           (setq key (intern (format "%s@%s*sources" feature domain)))
847           (when (and (memq key attributes)
848                      (setq value (get-char-attribute char key)))
849             (insert (format "(%s%s" key line-breaking))
850             (dolist (cell value)
851               (insert (format " %s" cell)))
852             (insert ")")
853             (insert line-breaking)
854             (setq attributes (delq key attributes))
855             ))
856         ))
857     (when (and (memq 'ideographic-strokes attributes)
858                (setq value (get-char-attribute char 'ideographic-strokes)))
859       (setq strokes value)
860       (insert (format "(ideographic-strokes . %S)%s"
861                       strokes
862                       line-breaking))
863       (setq attributes (delq 'ideographic-strokes attributes))
864       )
865     (when (and (memq 'kangxi-radical attributes)
866                (setq value (get-char-attribute char 'kangxi-radical)))
867       (unless (eq value radical)
868         (insert (format "(kangxi-radical\t . %S)\t; %c%s"
869                         value
870                         (ideographic-radical value)
871                         line-breaking))
872         (or radical
873             (setq radical value)))
874       (setq attributes (delq 'kangxi-radical attributes))
875       )
876     (when (and (memq 'kangxi-strokes attributes)
877                (setq value (get-char-attribute char 'kangxi-strokes)))
878       (unless (eq value strokes)
879         (insert (format "(kangxi-strokes\t . %S)%s"
880                         value
881                         line-breaking))
882         (or strokes
883             (setq strokes value)))
884       (setq attributes (delq 'kangxi-strokes attributes))
885       )
886     (when (and (memq 'japanese-radical attributes)
887                (setq value (get-char-attribute char 'japanese-radical)))
888       (unless (eq value radical)
889         (insert (format "(japanese-radical\t . %S)\t; %c%s"
890                         value
891                         (ideographic-radical value)
892                         line-breaking))
893         (or radical
894             (setq radical value)))
895       (setq attributes (delq 'japanese-radical attributes))
896       )
897     (when (and (memq 'japanese-strokes attributes)
898                (setq value (get-char-attribute char 'japanese-strokes)))
899       (unless (eq value strokes)
900         (insert (format "(japanese-strokes\t . %S)%s"
901                         value
902                         line-breaking))
903         (or strokes
904             (setq strokes value)))
905       (setq attributes (delq 'japanese-strokes attributes))
906       )
907     (when (and (memq 'cns-radical attributes)
908                (setq value (get-char-attribute char 'cns-radical)))
909       (insert (format "(cns-radical\t . %S)\t; %c%s"
910                       value
911                       (ideographic-radical value)
912                       line-breaking))
913       (setq attributes (delq 'cns-radical attributes))
914       )
915     (when (and (memq 'cns-strokes attributes)
916                (setq value (get-char-attribute char 'cns-strokes)))
917       (unless (eq value strokes)
918         (insert (format "(cns-strokes\t . %S)%s"
919                         value
920                         line-breaking))
921         (or strokes
922             (setq strokes value)))
923       (setq attributes (delq 'cns-strokes attributes))
924       )
925     (when (and (memq 'shinjigen-1-radical attributes)
926                (setq value (get-char-attribute char 'shinjigen-1-radical)))
927       (unless (eq value radical)
928         (insert (format "(shinjigen-1-radical . %S)\t; %c%s"
929                         value
930                         (ideographic-radical value)
931                         line-breaking))
932         (or radical
933             (setq radical value)))
934       (setq attributes (delq 'shinjigen-1-radical attributes))
935       )
936     (when (and (memq 'ideographic- attributes)
937                (setq value (get-char-attribute char 'ideographic-)))
938       (insert "(ideographic-       ")
939       (setq lbs (concat "\n" (make-string (current-column) ?\ ))
940             separator nil)
941       (while (consp value)
942         (setq cell (car value))
943         (if (integerp cell)
944             (setq cell (decode-char '=ucs cell)))
945         (cond ((characterp cell)
946                (if separator
947                    (insert lbs))
948                (if readable
949                    (insert (format "%S" cell))
950                  (char-db-insert-char-spec cell readable))
951                (setq separator lbs))
952               ((consp cell)
953                (if separator
954                    (insert lbs))
955                (if (consp (car cell))
956                    (char-db-insert-char-spec cell readable)
957                  (char-db-insert-char-reference cell readable))
958                (setq separator lbs))
959               (t
960                (if separator
961                    (insert separator))
962                (insert (prin1-to-string cell))
963                (setq separator " ")))
964         (setq value (cdr value)))
965       (insert ")")
966       (insert line-breaking)
967       (setq attributes (delq 'ideographic- attributes)))
968     (when (and (memq 'total-strokes attributes)
969                (setq value (get-char-attribute char 'total-strokes)))
970       (insert (format "(total-strokes       . %S)%s"
971                       value
972                       line-breaking))
973       (setq attributes (delq 'total-strokes attributes))
974       )
975     (when (and (memq '->ideograph attributes)
976                (setq value (get-char-attribute char '->ideograph)))
977       (insert (format "(->ideograph\t%s)%s"
978                       (mapconcat (lambda (code)
979                                    (cond ((symbolp code)
980                                           (symbol-name code))
981                                          ((integerp code)
982                                           (format "#x%04X" code))
983                                          (t
984                                           (format "%s %S"
985                                                   line-breaking code))))
986                                  value " ")
987                       line-breaking))
988       (setq attributes (delq '->ideograph attributes))
989       )
990     ;; (when (and (memq '->decomposition attributes)
991     ;;            (setq value (get-char-attribute char '->decomposition)))
992     ;;   (insert (format "(->decomposition\t%s)%s"
993     ;;                   (mapconcat (lambda (code)
994     ;;                                (cond ((symbolp code)
995     ;;                                       (symbol-name code))
996     ;;                                      ((characterp code)
997     ;;                                       (if readable
998     ;;                                           (format "%S" code)
999     ;;                                         (format "#x%04X"
1000     ;;                                                 (char-int code))
1001     ;;                                         ))
1002     ;;                                      ((integerp code)
1003     ;;                                       (format "#x%04X" code))
1004     ;;                                      (t
1005     ;;                                       (format "%s%S" line-breaking code))))
1006     ;;                              value " ")
1007     ;;                   line-breaking))
1008     ;;   (setq attributes (delq '->decomposition attributes))
1009     ;;   )
1010     (if (equal (get-char-attribute char '->titlecase)
1011                (get-char-attribute char '->uppercase))
1012         (setq attributes (delq '->titlecase attributes)))
1013     (when (and (memq '->mojikyo attributes)
1014                (setq value (get-char-attribute char '->mojikyo)))
1015       (insert (format "(->mojikyo\t\t. %06d)\t; %c%s"
1016                       value (decode-char 'mojikyo value)
1017                       line-breaking))
1018       (setq attributes (delq '->mojikyo attributes))
1019       )
1020     (when (and (memq 'hanyu-dazidian-vol attributes)
1021                (setq value (get-char-attribute char 'hanyu-dazidian-vol)))
1022       (insert (format "(hanyu-dazidian-vol  . %d)%s"
1023                       value line-breaking))
1024       (setq attributes (delq 'hanyu-dazidian-vol attributes))
1025       )
1026     (when (and (memq 'hanyu-dazidian-page attributes)
1027                (setq value (get-char-attribute char 'hanyu-dazidian-page)))
1028       (insert (format "(hanyu-dazidian-page . %d)%s"
1029                       value line-breaking))
1030       (setq attributes (delq 'hanyu-dazidian-page attributes))
1031       )
1032     (when (and (memq 'hanyu-dazidian-char attributes)
1033                (setq value (get-char-attribute char 'hanyu-dazidian-char)))
1034       (insert (format "(hanyu-dazidian-char . %d)%s"
1035                       value line-breaking))
1036       (setq attributes (delq 'hanyu-dazidian-char attributes))
1037       )
1038     (unless readable
1039       (dolist (ignored '(composition
1040                          ->denotational <-subsumptive ->ucs-unified
1041                          ->ideographic-component-forms))
1042         (setq attributes (delq ignored attributes))))
1043     (while attributes
1044       (setq name (car attributes))
1045       (if (setq value (get-char-attribute char name))
1046           (cond ((setq ret (find-charset name))
1047                  (setq name (charset-name ret))
1048                  (if (and (not (memq name dest-ccss))
1049                           (prog1
1050                               (setq value (get-char-attribute char name))
1051                             (setq dest-ccss (cons name dest-ccss))))
1052                      (char-db-insert-ccs-feature name value line-breaking))
1053                  )
1054                 ((string-match "^=>ucs@" (symbol-name name))
1055                  (insert (format "(%-18s . #x%04X)\t; %c%s"
1056                                  name value (decode-char '=ucs value)
1057                                  line-breaking))
1058                  )
1059                 ((eq name 'jisx0208-1978/4X)
1060                  (insert (format "(%-18s . #x%04X)%s"
1061                                  name value
1062                                  line-breaking))
1063                  )
1064                 ((and
1065                   (not readable)
1066                   (not (eq name '->subsumptive))
1067                   (not (eq name '->uppercase))
1068                   (not (eq name '->lowercase))
1069                   (not (eq name '->titlecase))
1070                   (not (eq name '->canonical))
1071                   (not (eq name '->Bopomofo))
1072                   (not (eq name '->mistakable))
1073                   (not (eq name '->ideographic-variants))
1074                   (null (get-char-attribute
1075                          char (intern (format "%s*sources" name))))
1076                   (not (string-match "\\*sources$" (symbol-name name)))
1077                   (null (get-char-attribute
1078                          char (intern (format "%s*note" name))))
1079                   (not (string-match "\\*note$" (symbol-name name)))
1080                   (or (eq name '<-identical)
1081                       (eq name '<-uppercase)
1082                       (eq name '<-lowercase)
1083                       (eq name '<-titlecase)
1084                       (eq name '<-canonical)
1085                       (eq name '<-ideographic-variants)
1086                       ;; (eq name '<-synonyms)
1087                       (string-match "^<-synonyms" (symbol-name name))
1088                       (eq name '<-mistakable)
1089                       (when (string-match "^->" (symbol-name name))
1090                         (cond
1091                          ((string-match "^->fullwidth" (symbol-name name))
1092                           (not (and (consp value)
1093                                     (characterp (car value))
1094                                     (encode-char
1095                                      (car value) '=ucs 'defined-only)))
1096                           )
1097                          (t)))
1098                       ))
1099                  )
1100                 ((or (eq name 'ideographic-structure)
1101                      (eq name 'ideographic-combination)
1102                      (eq name 'ideographic-)
1103                      (eq name '=decomposition)
1104                      (string-match "^=>decomposition" (symbol-name name))
1105                      (string-match "^\\(->\\|<-\\)[^*]*$" (symbol-name name))
1106                      (string-match "^\\(->\\|<-\\)[^*]*\\*sources$"
1107                                    (symbol-name name))
1108                      )
1109                  (char-db-insert-relation-feature char name value
1110                                                   line-breaking
1111                                                   ccss readable))
1112                 ((memq name '(ideograph=
1113                               original-ideograph-of
1114                               ancient-ideograph-of
1115                               vulgar-ideograph-of
1116                               wrong-ideograph-of
1117                               ;; simplified-ideograph-of
1118                               ideographic-variants
1119                               ;; ideographic-different-form-of
1120                               ))
1121                  (insert (format "(%-18s%s " name line-breaking))
1122                  (setq lbs (concat "\n" (make-string (current-column) ?\ ))
1123                        separator nil)
1124                  (while (consp value)
1125                    (setq cell (car value))
1126                    (if (and (consp cell)
1127                             (consp (car cell)))
1128                        (progn
1129                          (if separator
1130                              (insert lbs))
1131                          (char-db-insert-alist cell readable)
1132                          (setq separator lbs))
1133                      (if separator
1134                          (insert separator))
1135                      (insert (prin1-to-string cell))
1136                      (setq separator " "))
1137                    (setq value (cdr value)))
1138                  (insert ")")
1139                  (insert line-breaking))
1140                 ((consp value)
1141                  (insert (format "(%-18s " name))
1142                  (setq lbs (concat "\n" (make-string (current-column) ?\ ))
1143                        separator nil)
1144                  (while (consp value)
1145                    (setq cell (car value))
1146                    (if (and (consp cell)
1147                             (consp (car cell))
1148                             (setq ret (condition-case nil
1149                                           (find-char cell)
1150                                         (error nil))))
1151                        (progn
1152                          (setq rest cell
1153                                al nil
1154                                cal nil)
1155                          (while rest
1156                            (setq key (car (car rest)))
1157                            (if (find-charset key)
1158                                (setq cal (cons key cal))
1159                              (setq al (cons key al)))
1160                            (setq rest (cdr rest)))
1161                          (if separator
1162                              (insert lbs))
1163                          (insert-char-attributes ret
1164                                                  readable
1165                                                  al cal)
1166                          (setq separator lbs))
1167                      (setq ret (prin1-to-string cell))
1168                      (if separator
1169                          (if (< (+ (current-column)
1170                                    (length ret)
1171                                    (length separator))
1172                                 76)
1173                              (insert separator)
1174                            (insert lbs)))
1175                      (insert ret)
1176                      (setq separator " "))
1177                    (setq value (cdr value)))
1178                  (insert ")")
1179                  (insert line-breaking))
1180                 (t
1181                  (insert (format "(%-18s" name))
1182                  (setq ret (prin1-to-string value))
1183                  (unless (< (+ (current-column)
1184                                (length ret)
1185                                3)
1186                             76)
1187                    (insert line-breaking))
1188                  (insert " . " ret ")" line-breaking)
1189                  ;; (insert (format "(%-18s . %S)%s"
1190                  ;;                 name value
1191                  ;;                 line-breaking))
1192                  )
1193                 ))
1194       (setq attributes (cdr attributes)))
1195     (insert ")")))
1196
1197 (defun insert-char-data (char &optional readable
1198                               attributes)
1199   (save-restriction
1200     (narrow-to-region (point)(point))
1201     (insert "(define-char
1202   '")
1203     (insert-char-attributes char readable attributes)
1204     (insert ")\n")
1205     (goto-char (point-min))
1206     (while (re-search-forward "[ \t]+$" nil t)
1207       (replace-match ""))
1208     ;; from tabify.
1209     (goto-char (point-min))
1210     (while (re-search-forward "[ \t][ \t][ \t]*" nil t)
1211       (let ((column (current-column))
1212             (indent-tabs-mode t))
1213         (delete-region (match-beginning 0) (point))
1214         (indent-to column)))
1215     (goto-char (point-max))
1216     ;; (tabify (point-min)(point-max))
1217     ))
1218
1219 (defun insert-char-data-with-variant (char &optional printable
1220                                            no-ucs-unified
1221                                            script excluded-script)
1222   (insert-char-data char printable)
1223   (let ((variants (char-variants char))
1224         rest
1225         variant vs ret)
1226     (setq variants (sort variants #'<))
1227     (setq rest variants)
1228     (setq variants (cons char variants))
1229     (while rest
1230       (setq variant (car rest))
1231       (unless (get-char-attribute variant '<-subsumptive)
1232         (if (and (or (null script)
1233                      (null (setq vs (get-char-attribute variant 'script)))
1234                      (memq script vs))
1235                  (or (null excluded-script)
1236                      (null (setq vs (get-char-attribute variant 'script)))
1237                      (not (memq excluded-script vs))))
1238             (unless (and no-ucs-unified (get-char-attribute variant '=ucs))
1239               (insert-char-data variant printable)
1240               (if (setq ret (char-variants variant))
1241                   (while ret
1242                     (or (memq (car ret) variants)
1243                         ;; (get-char-attribute (car ret) '<-subsumptive)
1244                         (setq rest (nconc rest (list (car ret)))))
1245                     (setq ret (cdr ret)))))))
1246       (setq rest (cdr rest)))))
1247
1248 (defun insert-char-range-data (min max &optional script excluded-script)
1249   (let ((code min)
1250         char)
1251     (while (<= code max)
1252       (setq char (decode-char '=ucs code))
1253       (if (encode-char char '=ucs 'defined-only)
1254           (insert-char-data-with-variant char nil 'no-ucs-unified
1255                                          script excluded-script))
1256       (setq code (1+ code)))))
1257
1258 (defun write-char-range-data-to-file (min max file
1259                                           &optional script excluded-script)
1260   (let ((coding-system-for-write char-db-file-coding-system))
1261     (with-temp-buffer
1262       (insert (format ";; -*- coding: %s -*-\n"
1263                       char-db-file-coding-system))
1264       (insert-char-range-data min max script excluded-script)
1265       (write-region (point-min)(point-max) file))))
1266
1267 (defvar what-character-original-window-configuration)
1268
1269 ;;;###autoload
1270 (defun what-char-definition (char)
1271   (interactive (list (char-after)))
1272   (let ((buf (get-buffer-create "*Character Description*"))
1273         (the-buf (current-buffer))
1274         (win-conf (current-window-configuration)))
1275     (pop-to-buffer buf)
1276     (make-local-variable 'what-character-original-window-configuration)
1277     (setq what-character-original-window-configuration win-conf)
1278     (setq buffer-read-only nil)
1279     (erase-buffer)
1280     (condition-case err
1281         (progn
1282           (insert-char-data-with-variant char 'printable)
1283           (unless (char-attribute-alist char)
1284             (insert (format ";; = %c\n"
1285                             (let* ((rest (split-char char))
1286                                    (ccs (pop rest))
1287                                    (code (pop rest)))
1288                               (while rest
1289                                 (setq code (logior (lsh code 8)
1290                                                    (pop rest))))
1291                               (decode-char ccs code)))))
1292           ;; (char-db-update-comment)
1293           (set-buffer-modified-p nil)
1294           (view-mode the-buf (lambda (buf)
1295                                (set-window-configuration
1296                                 what-character-original-window-configuration)
1297                                ))
1298           (goto-char (point-min)))
1299       (error (progn
1300                (set-window-configuration
1301                 what-character-original-window-configuration)
1302                (signal (car err) (cdr err)))))))
1303
1304 (provide 'char-db-util)
1305
1306 ;;; char-db-util.el ends here