(ZOB-{02065 - 02088}): New characters.
[chise/xemacs-chise.git.1] / 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, 2008 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    ?克 ?彔 ?禾 ?秝 ?黍 ?香 ?米 ?毇 ?臼 ?凶 ; 260
103    ?𣎳 ?林 ?麻 ?尗 ?耑 ?韭 ?瓜 ?瓠 ?宀 ?宫 ; 270
104    ])
105
106 (defun shuowen-radical (number)
107   (aref shuowen-radicals (1- number)))
108
109 (defvar char-db-file-coding-system 'utf-8-mcs-er)
110
111 (defvar char-db-feature-domains
112   '(ucs ucs/compat daikanwa cns gt jis jis/alt jis/a jis/b
113         jis-x0212 jis-x0213 cdp shinjigen misc unknown))
114
115 (defvar char-db-ignored-attributes '(ideographic-products))
116
117 (defun char-attribute-name< (ka kb)
118   (cond
119    ((eq '->denotational kb)
120     t)
121    ((eq '->subsumptive kb)
122     (not (eq '->denotational ka)))
123    ((eq '->denotational ka)
124     nil)
125    ((eq '->subsumptive ka)
126     nil)
127    ((and (symbolp ka)
128          (string-match "^->" (symbol-name ka)))
129     (cond ((and (symbolp kb)
130                 (string-match "^->" (symbol-name kb)))
131            (string< (symbol-name ka)
132                     (symbol-name kb))
133            ))
134     )
135    ((and (symbolp kb)
136          (string-match "^->" (symbol-name kb)))
137     t)
138    ((and (symbolp ka)
139          (string-match "^<-" (symbol-name ka)))
140     (cond ((symbolp kb)
141            (cond ((string-match "^<-" (symbol-name kb))
142                   (string< (symbol-name ka)
143                            (symbol-name kb))
144                   )
145                  ;; ((string-match "^->" (symbol-name kb))
146                  ;;  t)
147                  )))
148     )
149    ((and (symbolp kb)
150          (string-match "^<-" (symbol-name kb)))
151     t
152     ;; (not (string-match "^->" (symbol-name ka)))
153     )
154    ((find-charset ka)
155     (if (find-charset kb)
156         (if (<= (charset-id ka) 1)
157             (if (<= (charset-id kb) 1)
158                 (cond
159                  ((= (charset-dimension ka)
160                      (charset-dimension kb))
161                   (> (charset-id ka)(charset-id kb)))
162                  (t
163                   (> (charset-dimension ka)
164                      (charset-dimension kb))
165                   ))
166               t)
167           (if (<= (charset-id kb) 1)
168               nil
169             (< (charset-id ka)(charset-id kb))))
170       nil))
171    ((find-charset kb)
172     t)
173    ((symbolp ka)
174     (cond ((symbolp kb)
175            (string< (symbol-name ka)
176                     (symbol-name kb)))
177           (t)))
178    ((symbolp kb)
179     nil)))
180
181 (defvar char-db-coded-charset-priority-list
182   '(ascii
183     control-1
184     latin-iso8859-1
185     latin-iso8859-2
186     latin-iso8859-3
187     latin-iso8859-4
188     latin-iso8859-9
189     latin-jisx0201
190     cyrillic-iso8859-5
191     greek-iso8859-7
192     thai-tis620
193     =jis-x0208
194     =jis-x0208@1978
195     =jis-x0208@1983
196     japanese-jisx0212
197     chinese-gb2312
198     =jis-x0208@1990
199     chinese-cns11643-1
200     chinese-cns11643-2
201     chinese-cns11643-3
202     chinese-cns11643-4
203     chinese-cns11643-5
204     chinese-cns11643-6
205     chinese-cns11643-7
206     =jis-x0213-1-2000
207     =jis-x0213-2-2000
208     korean-ksc5601
209     chinese-isoir165
210     katakana-jisx0201
211     hebrew-iso8859-8
212     chinese-gb12345
213     latin-viscii
214     ethiopic-ucs
215     =big5-cdp
216     =gt
217     ideograph-daikanwa-2
218     ideograph-daikanwa
219     =cbeta
220     ideograph-hanziku-1
221     ideograph-hanziku-2
222     ideograph-hanziku-3
223     ideograph-hanziku-4
224     ideograph-hanziku-5
225     ideograph-hanziku-6
226     ideograph-hanziku-7
227     ideograph-hanziku-8
228     ideograph-hanziku-9
229     ideograph-hanziku-10
230     ideograph-hanziku-11
231     ideograph-hanziku-12
232     =gt-k
233     =ucs@iso
234     =ucs@unicode
235     =big5
236     =big5-eten
237     =jis-x0208@1997
238     =zinbun-oracle
239     =ruimoku-v6
240     =jef-china3))
241
242 (defun char-db-make-char-spec (char)
243   (let (ret char-spec)
244     (cond ((characterp char)
245            (cond ((and (setq ret (encode-char char '=ucs 'defined-only))
246                        (not (and (<= #xE000 ret)(<= ret #xF8FF))))
247                   (setq char-spec (list (cons '=ucs ret)))
248                   (cond ((setq ret (get-char-attribute char 'name))
249                          (setq char-spec (cons (cons 'name ret) char-spec))
250                          )
251                         ((setq ret (get-char-attribute char 'name*))
252                          (setq char-spec (cons (cons 'name* ret) char-spec))
253                          ))
254                   )
255                  ((setq ret
256                         (catch 'tag
257                           (let ((rest char-db-coded-charset-priority-list)
258                                 ccs)
259                             (while rest
260                               (setq ccs (charset-name
261                                          (find-charset (car rest))))
262                               (if (setq ret
263                                         (encode-char char ccs
264                                                      'defined-only))
265                                   (throw 'tag (cons ccs ret)))
266                               (setq rest (cdr rest))))))
267                   (setq char-spec (list ret))
268                   (dolist (ccs (delq (car ret) (charset-list)))
269                     (if (and (or (charset-iso-final-char ccs)
270                                  (memq ccs
271                                        '(=daikanwa
272                                          =daikanwa@rev2
273                                          ;; =gt-k
274                                          =jis-x0208@1997
275                                          )))
276                              (setq ccs (charset-name ccs))
277                              (null (assq ccs char-spec))
278                              (setq ret (encode-char char ccs 'defined-only)))
279                         (setq char-spec (cons (cons ccs ret) char-spec))))
280                   (if (null char-spec)
281                       (setq char-spec (split-char char)))
282                   (cond ((setq ret (get-char-attribute char 'name))
283                          (setq char-spec (cons (cons 'name ret) char-spec))
284                          )
285                         ((setq ret (get-char-attribute char 'name*))
286                          (setq char-spec (cons (cons 'name* ret) char-spec))
287                          ))
288                   ))
289            char-spec)
290           ((consp char)
291            char))))
292     
293 (defun char-db-insert-char-spec (char &optional readable column
294                                       required-features)
295   (unless column
296     (setq column (current-column)))
297   (let (char-spec temp-char)
298     (setq char-spec (char-db-make-char-spec char))
299     (unless (or (characterp char) ; char
300                 (condition-case nil
301                     (setq char (find-char char-spec))
302                   (error nil)))
303       ;; define temporary character
304       ;;   Current implementation is dirty.
305       (setq temp-char (define-char (cons '(ideograph-daikanwa . 0)
306                                          char-spec)))
307       (remove-char-attribute temp-char 'ideograph-daikanwa)
308       (setq char temp-char))
309     (insert-char-attributes char
310                             readable
311                             (union (mapcar #'car char-spec)
312                                    required-features))
313     (when temp-char
314       ;; undefine temporary character
315       ;;   Current implementation is dirty.
316       (setq char-spec (char-attribute-alist temp-char))
317       (while char-spec
318         (remove-char-attribute temp-char (car (car char-spec)))
319         (setq char-spec (cdr char-spec))))))
320
321 (defun char-db-insert-alist (alist &optional readable column)
322   (unless column
323     (setq column (current-column)))
324   (let ((line-breaking
325          (concat "\n" (make-string (1+ column) ?\ )))
326         name value
327         ret al ; cal
328         key
329         lbs cell rest separator)
330     (insert "(")
331     (while alist
332       (setq name (car (car alist))
333             value (cdr (car alist)))
334       (cond ((eq name 'char)
335              (insert "(char . ")
336              (if (setq ret (condition-case nil
337                                (find-char value)
338                              (error nil)))
339                  (progn
340                    (setq al nil
341                          ;; cal nil
342                          )
343                    (while value
344                      (setq key (car (car value)))
345                      ;; (if (find-charset key)
346                      ;;     (setq cal (cons key cal))
347                      (setq al (cons key al))
348                      ;; )
349                      (setq value (cdr value)))
350                    (insert-char-attributes ret
351                                            readable
352                                            (or al 'none) ; cal
353                                            ))
354                (insert (prin1-to-string value)))
355              (insert ")")
356              (insert line-breaking))
357             ((consp value)
358              (insert (format "(%-18s " name))
359              (setq lbs (concat "\n" (make-string (current-column) ?\ )))
360              (while (consp value)
361                (setq cell (car value))
362                (if (and (consp cell)
363                         (consp (car cell))
364                         (setq ret (condition-case nil
365                                       (find-char cell)
366                                     (error nil)))
367                         )
368                    (progn
369                      (setq rest cell
370                            al nil
371                            ;; cal nil
372                            )
373                      (while rest
374                        (setq key (car (car rest)))
375                        ;; (if (find-charset key)
376                        ;;     (setq cal (cons key cal))
377                        (setq al (cons key al))
378                        ;; )
379                        (setq rest (cdr rest)))
380                      (if separator
381                          (insert lbs))
382                      (insert-char-attributes ret
383                                              readable
384                                              al ; cal
385                                              )
386                      (setq separator lbs))
387                  (if separator
388                      (insert separator))
389                  (insert (prin1-to-string cell))
390                  (setq separator " "))
391                (setq value (cdr value)))
392              (insert ")")
393              (insert line-breaking))
394             (t
395              (insert (format "(%-18s . %S)%s"
396                              name value
397                              line-breaking))))
398       (setq alist (cdr alist))))
399   (insert ")"))
400
401 (defun char-db-insert-char-reference (plist &optional readable column)
402   (unless column
403     (setq column (current-column)))
404   (let ((line-breaking
405          (concat "\n" (make-string (1+ column) ?\ )))
406         (separator "")
407         name value)
408     (insert "(")
409     (while plist
410       (setq name (pop plist))
411       (setq value (pop plist))
412       (cond ((eq name :char)
413              (insert separator)
414              (insert ":char\t")
415              (cond ((numberp value)
416                     (setq value (decode-char '=ucs value)))
417                    ;; ((consp value)
418                    ;;  (setq value (or (find-char value)
419                    ;;                  value)))
420                    )
421              (char-db-insert-char-spec value readable)
422              (insert line-breaking)
423              (setq separator ""))
424             ((eq name :radical)
425              (insert (format "%s%s\t%d ; %c%s"
426                              separator
427                              name value
428                              (ideographic-radical value)
429                              line-breaking))
430              (setq separator ""))
431             (t
432              (insert (format "%s%s\t%S" separator name value))
433              (setq separator line-breaking)))
434       ))
435   (insert ")"))
436
437 (defun char-db-decode-isolated-char (ccs code-point)
438   (let (ret)
439     (setq ret
440           (cond ((eq ccs 'arabic-iso8859-6)
441                  (decode-char ccs code-point))
442                 ((and (memq ccs '(=gt-pj-1
443                                   =gt-pj-2
444                                   =gt-pj-3
445                                   =gt-pj-4
446                                   =gt-pj-5
447                                   =gt-pj-6
448                                   =gt-pj-7
449                                   =gt-pj-8
450                                   =gt-pj-9
451                                   =gt-pj-10
452                                   =gt-pj-11))
453                       (setq ret (decode-char ccs code-point))
454                       (setq ret (encode-char ret '=gt 'defined-only)))
455                  (decode-builtin-char '=gt ret))
456                 (t
457                  (decode-builtin-char ccs code-point))))
458     (cond ((and (<= 0 (char-int ret))
459                 (<= (char-int ret) #x1F))
460            (decode-char '=ucs (+ #x2400 (char-int ret))))
461           ((= (char-int ret) #x7F)
462            ?\u2421)
463           (t ret))))
464
465 (defvar char-db-convert-obsolete-format t)
466
467 (defun char-db-insert-ccs-feature (name value line-breaking)
468   (insert
469    (format
470     (cond ((or (memq name '(=daikanwa
471                             =daikanwa@rev1 =daikanwa@rev2
472                             =gt =gt-k =cbeta =zinbun-oracle))
473                (string-match "^=adobe-" (symbol-name name)))
474            "(%-18s . %05d)\t; %c")
475           ((eq name 'mojikyo)
476            "(%-18s . %06d)\t; %c")
477           ((>= (charset-dimension name) 2)
478            "(%-18s . #x%04X)\t; %c")
479           (t
480            "(%-18s . #x%02X)\t; %c"))
481     name
482     (if (= (charset-iso-graphic-plane name) 1)
483         (logior value
484                 (cond ((= (charset-dimension name) 1)
485                        #x80)
486                       ((= (charset-dimension name) 2)
487                        #x8080)
488                       ((= (charset-dimension name) 3)
489                        #x808080)
490                       (t 0)))
491       value)
492     (char-db-decode-isolated-char name value)))
493   (if (and (= (charset-chars name) 94)
494            (= (charset-dimension name) 2))
495       (insert (format " [%02d-%02d]"
496                       (- (lsh value -8) 32)
497                       (- (logand value 255) 32))))
498   (insert line-breaking))
499
500 (defun char-db-insert-relation-feature (char name value line-breaking
501                                              ccss readable)
502   (insert (format "(%-18s%s " name line-breaking))
503   (let ((lbs (concat "\n" (make-string (current-column) ?\ )))
504         separator cell sources required-features
505         ret)
506     (while (consp value)
507       (setq cell (car value))
508       (if (integerp cell)
509           (setq cell (decode-char '=ucs cell)))
510       (cond
511        ((eq name '->subsumptive)
512         (when (or (not (some (lambda (atr)
513                                (get-char-attribute cell atr))
514                              char-db-ignored-attributes))
515                   (some (lambda (ccs)
516                           (encode-char cell ccs 'defined-only))
517                         ccss))
518           (if separator
519               (insert lbs))
520           (let ((char-db-ignored-attributes
521                  (cons '<-subsumptive
522                        char-db-ignored-attributes)))
523             (insert-char-attributes cell readable))
524           (setq separator lbs))
525         )
526        ((characterp cell)
527         (setq sources
528               (get-char-attribute
529                char (intern (format "%s*sources" name))))
530         (setq required-features nil)
531         (dolist (source sources)
532           (cond
533            ((memq source '(JP JP/Jouyou shinjigen-1))
534             (setq required-features
535                   (union required-features
536                          '(=jis-x0208
537                            =jis-x0208@1990
538                            =jis-x0213-1-2000
539                            =jis-x0213-2-2000
540                            =jis-x0212
541                            =jis-x0208@1983
542                            =jis-x0208@1978))))
543            ((eq source 'CN)
544             (setq required-features
545                   (union required-features
546                          '(=gb2312
547                            =gb12345
548                            =iso-ir165)))))
549           (cond
550            ((find-charset (setq ret (intern (format "=%s" source))))
551             (setq required-features
552                   (cons ret required-features)))
553            (t (setq required-features
554                     (cons source required-features)))))
555         (cond ((string-match "@JP" (symbol-name name))
556                (setq required-features
557                      (union required-features
558                             '(=jis-x0208
559                               =jis-x0208@1990
560                               =jis-x0213-1-2000
561                               =jis-x0213-2-2000
562                               =jis-x0212
563                               =jis-x0208@1983
564                               =jis-x0208@1978))))
565               ((string-match "@CN" (symbol-name name))
566                (setq required-features
567                      (union required-features
568                             '(=gb2312
569                               =gb12345
570                               =iso-ir165)))))
571         (if separator
572             (insert lbs))
573         (if readable
574             (insert (format "%S" cell))
575           (char-db-insert-char-spec cell readable
576                                     nil
577                                     required-features))
578         (setq separator lbs))
579        ((consp cell)
580         (if separator
581             (insert lbs))
582         (if (consp (car cell))
583             (char-db-insert-char-spec cell readable)
584           (char-db-insert-char-reference cell readable))
585         (setq separator lbs))
586        (t
587         (if separator
588             (insert separator))
589         (insert (prin1-to-string cell))
590         (setq separator " ")))
591       (setq value (cdr value)))
592     (insert ")")
593     (insert line-breaking)))
594
595 (defun insert-char-attributes (char &optional readable attributes column)
596   (unless column
597     (setq column (current-column)))
598   (let (name value ; has-long-ccs-name
599         rest
600         radical strokes
601         (line-breaking
602          (concat "\n" (make-string (1+ column) ?\ )))
603         lbs cell separator ret
604         key al cal
605         dest-ccss ; sources required-features
606         ccss)
607     (let (atr-d)
608       (setq attributes
609             (sort (if attributes
610                       (if (consp attributes)
611                           (progn
612                             (dolist (name attributes)
613                               (unless (memq name char-db-ignored-attributes)
614                                 (if (find-charset name)
615                                     (push name ccss))
616                                 (push name atr-d)))
617                             atr-d))
618                     (dolist (name (char-attribute-list))
619                       (unless (memq name char-db-ignored-attributes)
620                         (if (find-charset name)
621                             (push name ccss))
622                         (push name atr-d)))
623                     atr-d)
624                   #'char-attribute-name<)))
625     (insert "(")
626     (when (memq '<-subsumptive attributes)
627       (when readable
628         (when (setq value (get-char-attribute char '<-subsumptive))
629           (char-db-insert-relation-feature char '<-subsumptive value
630                                            line-breaking
631                                            ccss readable)))
632       (setq attributes (delq '<-subsumptive attributes)))
633     (when (and (memq '<-denotational attributes)
634                (setq value (get-char-attribute char '<-denotational)))
635       (char-db-insert-relation-feature char '<-denotational value
636                                        line-breaking
637                                        ccss readable)
638       (setq attributes (delq '<-denotational attributes)))
639     (when (and (memq 'name attributes)
640                (setq value (get-char-attribute char 'name)))
641       (insert (format
642                (if (> (+ (current-column) (length value)) 48)
643                    "(name . %S)%s"
644                  "(name               . %S)%s")
645                value line-breaking))
646       (setq attributes (delq 'name attributes))
647       )
648     (when (and (memq 'name* attributes)
649                (setq value (get-char-attribute char 'name*)))
650       (insert (format
651                (if (> (+ (current-column) (length value)) 48)
652                    "(name* . %S)%s"
653                  "(name*              . %S)%s")
654                value line-breaking))
655       (setq attributes (delq 'name* attributes))
656       )
657     (when (and (memq 'script attributes)
658                (setq value (get-char-attribute char 'script)))
659       (insert (format "(script\t\t%s)%s"
660                       (mapconcat (function prin1-to-string)
661                                  value " ")
662                       line-breaking))
663       (setq attributes (delq 'script attributes))
664       )
665     (dolist (name '(=>ucs =>ucs*))
666       (when (and (memq name attributes)
667                  (setq value (get-char-attribute char name)))
668         (insert (format "(%-18s . #x%04X)\t; %c%s"
669                         name value (decode-char '=ucs value)
670                         line-breaking))
671         (setq attributes (delq name attributes))))
672     (dolist (name '(=>ucs@gb =>ucs@cns =>ucs@jis =>ucs@ks =>ucs@big5))
673       (when (and (memq name attributes)
674                  (setq value (get-char-attribute char name)))
675         (insert (format "(%-18s . #x%04X)\t; %c%s"
676                         name value
677                         (decode-char (intern
678                                       (concat "="
679                                               (substring
680                                                (symbol-name name) 2)))
681                                      value)
682                         line-breaking))
683         (setq attributes (delq name attributes))
684         ))
685     (dolist (name '(=>daikanwa))
686       (when (and (memq name attributes)
687                  (setq value (get-char-attribute char name)))
688         (insert
689          (if (integerp value)
690              (format "(%-18s . %05d)\t; %c%s"
691                      name value (decode-char '=daikanwa value)
692                      line-breaking)
693            (format "(%-18s %s)\t; %c%s"
694                    name
695                    (mapconcat (function prin1-to-string)
696                               value " ")
697                    (char-representative-of-daikanwa char)
698                    line-breaking)))
699         (setq attributes (delq name attributes))))
700     (when (and (memq 'general-category attributes)
701                (setq value (get-char-attribute char 'general-category)))
702       (insert (format
703                "(general-category\t%s) ; %s%s"
704                (mapconcat (lambda (cell)
705                             (format "%S" cell))
706                           value " ")
707                (cond ((rassoc value unidata-normative-category-alist)
708                       "Normative Category")
709                      ((rassoc value unidata-informative-category-alist)
710                       "Informative Category")
711                      (t
712                       "Unknown Category"))
713                line-breaking))
714       (setq attributes (delq 'general-category attributes))
715       )
716     (when (and (memq 'bidi-category attributes)
717                (setq value (get-char-attribute char 'bidi-category)))
718       (insert (format "(bidi-category\t. %S)%s"
719                       value
720                       line-breaking))
721       (setq attributes (delq 'bidi-category attributes))
722       )
723     (unless (or (not (memq 'mirrored attributes))
724                 (eq (setq value (get-char-attribute char 'mirrored 'empty))
725                     'empty))
726       (insert (format "(mirrored\t\t. %S)%s"
727                       value
728                       line-breaking))
729       (setq attributes (delq 'mirrored attributes))
730       )
731     (cond
732      ((and (memq 'decimal-digit-value attributes)
733            (setq value (get-char-attribute char 'decimal-digit-value)))
734       (insert (format "(decimal-digit-value . %S)%s"
735                       value
736                       line-breaking))
737       (setq attributes (delq 'decimal-digit-value attributes))
738       (when (and (memq 'digit-value attributes)
739                  (setq value (get-char-attribute char 'digit-value)))
740         (insert (format "(digit-value\t . %S)%s"
741                         value
742                         line-breaking))
743         (setq attributes (delq 'digit-value attributes))
744         )
745       (when (and (memq 'numeric-value attributes)
746                  (setq value (get-char-attribute char 'numeric-value)))
747         (insert (format "(numeric-value\t . %S)%s"
748                         value
749                         line-breaking))
750         (setq attributes (delq 'numeric-value attributes))
751         )
752       )
753      (t
754       (when (and (memq 'digit-value attributes)
755                  (setq value (get-char-attribute char 'digit-value)))
756         (insert (format "(digit-value\t. %S)%s"
757                         value
758                         line-breaking))
759         (setq attributes (delq 'digit-value attributes))
760         )
761       (when (and (memq 'numeric-value attributes)
762                  (setq value (get-char-attribute char 'numeric-value)))
763         (insert (format "(numeric-value\t. %S)%s"
764                         value
765                         line-breaking))
766         (setq attributes (delq 'numeric-value attributes))
767         )))
768     (when (and (memq 'iso-10646-comment attributes)
769                (setq value (get-char-attribute char 'iso-10646-comment)))
770       (insert (format "(iso-10646-comment\t. %S)%s"
771                       value
772                       line-breaking))
773       (setq attributes (delq 'iso-10646-comment attributes))
774       )
775     (when (and (memq 'morohashi-daikanwa attributes)
776                (setq value (get-char-attribute char 'morohashi-daikanwa)))
777       (insert (format "(morohashi-daikanwa\t%s)%s"
778                       (mapconcat (function prin1-to-string) value " ")
779                       line-breaking))
780       (setq attributes (delq 'morohashi-daikanwa attributes))
781       )
782     (setq radical nil
783           strokes nil)
784     (when (and (memq 'ideographic-radical attributes)
785                (setq value (get-char-attribute char 'ideographic-radical)))
786       (setq radical value)
787       (insert (format "(ideographic-radical . %S)\t; %c%s"
788                       radical
789                       (ideographic-radical radical)
790                       line-breaking))
791       (setq attributes (delq 'ideographic-radical attributes))
792       )
793     (when (and (memq 'shuowen-radical attributes)
794                (setq value (get-char-attribute char 'shuowen-radical)))
795       (insert (format "(shuowen-radical\t. %S)\t; %c%s"
796                       value
797                       (shuowen-radical value)
798                       line-breaking))
799       (setq attributes (delq 'shuowen-radical attributes))
800       )
801     (let (key)
802       (dolist (domain
803                (append
804                 char-db-feature-domains
805                 (let (dest domain)
806                   (dolist (feature (char-attribute-list))
807                     (setq feature (symbol-name feature))
808                     (when (string-match
809                            "\\(radical\\|strokes\\)@\\([^@*]+\\)\\(\\*\\|$\\)"
810                            feature)
811                       (setq domain (intern (match-string 2 feature)))
812                      (unless (memq domain dest)
813                        (setq dest (cons domain dest)))))
814                   (sort dest #'string<))))
815         (setq key (intern (format "%s@%s" 'ideographic-radical domain)))
816         (when (and (memq key attributes)
817                    (setq value (get-char-attribute char key)))
818           (setq radical value)
819           (insert (format "(%s . %S)\t; %c%s"
820                           key
821                           radical
822                           (ideographic-radical radical)
823                           line-breaking))
824           (setq attributes (delq key attributes))
825           )
826         (setq key (intern (format "%s@%s" 'ideographic-strokes domain)))
827         (when (and (memq key attributes)
828                    (setq value (get-char-attribute char key)))
829           (setq strokes value)
830           (insert (format "(%s . %S)%s"
831                           key
832                           strokes
833                           line-breaking))
834           (setq attributes (delq key attributes))
835           )
836         (setq key (intern (format "%s@%s" 'total-strokes domain)))
837         (when (and (memq key attributes)
838                    (setq value (get-char-attribute char key)))
839           (insert (format "(%s       . %S)%s"
840                           key
841                           value
842                           line-breaking))
843           (setq attributes (delq key attributes))
844           )
845         (dolist (feature '(ideographic-radical
846                            ideographic-strokes
847                            total-strokes))
848           (setq key (intern (format "%s@%s*sources" feature domain)))
849           (when (and (memq key attributes)
850                      (setq value (get-char-attribute char key)))
851             (insert (format "(%s%s" key line-breaking))
852             (dolist (cell value)
853               (insert (format " %s" cell)))
854             (insert ")")
855             (insert line-breaking)
856             (setq attributes (delq key attributes))
857             ))
858         ))
859     (when (and (memq 'ideographic-strokes attributes)
860                (setq value (get-char-attribute char 'ideographic-strokes)))
861       (setq strokes value)
862       (insert (format "(ideographic-strokes . %S)%s"
863                       strokes
864                       line-breaking))
865       (setq attributes (delq 'ideographic-strokes attributes))
866       )
867     (when (and (memq 'kangxi-radical attributes)
868                (setq value (get-char-attribute char 'kangxi-radical)))
869       (unless (eq value radical)
870         (insert (format "(kangxi-radical\t . %S)\t; %c%s"
871                         value
872                         (ideographic-radical value)
873                         line-breaking))
874         (or radical
875             (setq radical value)))
876       (setq attributes (delq 'kangxi-radical attributes))
877       )
878     (when (and (memq 'kangxi-strokes attributes)
879                (setq value (get-char-attribute char 'kangxi-strokes)))
880       (unless (eq value strokes)
881         (insert (format "(kangxi-strokes\t . %S)%s"
882                         value
883                         line-breaking))
884         (or strokes
885             (setq strokes value)))
886       (setq attributes (delq 'kangxi-strokes attributes))
887       )
888     (when (and (memq 'japanese-radical attributes)
889                (setq value (get-char-attribute char 'japanese-radical)))
890       (unless (eq value radical)
891         (insert (format "(japanese-radical\t . %S)\t; %c%s"
892                         value
893                         (ideographic-radical value)
894                         line-breaking))
895         (or radical
896             (setq radical value)))
897       (setq attributes (delq 'japanese-radical attributes))
898       )
899     (when (and (memq 'japanese-strokes attributes)
900                (setq value (get-char-attribute char 'japanese-strokes)))
901       (unless (eq value strokes)
902         (insert (format "(japanese-strokes\t . %S)%s"
903                         value
904                         line-breaking))
905         (or strokes
906             (setq strokes value)))
907       (setq attributes (delq 'japanese-strokes attributes))
908       )
909     (when (and (memq 'cns-radical attributes)
910                (setq value (get-char-attribute char 'cns-radical)))
911       (insert (format "(cns-radical\t . %S)\t; %c%s"
912                       value
913                       (ideographic-radical value)
914                       line-breaking))
915       (setq attributes (delq 'cns-radical attributes))
916       )
917     (when (and (memq 'cns-strokes attributes)
918                (setq value (get-char-attribute char 'cns-strokes)))
919       (unless (eq value strokes)
920         (insert (format "(cns-strokes\t . %S)%s"
921                         value
922                         line-breaking))
923         (or strokes
924             (setq strokes value)))
925       (setq attributes (delq 'cns-strokes attributes))
926       )
927     (when (and (memq 'shinjigen-1-radical attributes)
928                (setq value (get-char-attribute char 'shinjigen-1-radical)))
929       (unless (eq value radical)
930         (insert (format "(shinjigen-1-radical . %S)\t; %c%s"
931                         value
932                         (ideographic-radical value)
933                         line-breaking))
934         (or radical
935             (setq radical value)))
936       (setq attributes (delq 'shinjigen-1-radical attributes))
937       )
938     (when (and (memq 'ideographic- attributes)
939                (setq value (get-char-attribute char 'ideographic-)))
940       (insert "(ideographic-       ")
941       (setq lbs (concat "\n" (make-string (current-column) ?\ ))
942             separator nil)
943       (while (consp value)
944         (setq cell (car value))
945         (if (integerp cell)
946             (setq cell (decode-char '=ucs cell)))
947         (cond ((characterp cell)
948                (if separator
949                    (insert lbs))
950                (if readable
951                    (insert (format "%S" cell))
952                  (char-db-insert-char-spec cell readable))
953                (setq separator lbs))
954               ((consp cell)
955                (if separator
956                    (insert lbs))
957                (if (consp (car cell))
958                    (char-db-insert-char-spec cell readable)
959                  (char-db-insert-char-reference cell readable))
960                (setq separator lbs))
961               (t
962                (if separator
963                    (insert separator))
964                (insert (prin1-to-string cell))
965                (setq separator " ")))
966         (setq value (cdr value)))
967       (insert ")")
968       (insert line-breaking)
969       (setq attributes (delq 'ideographic- attributes)))
970     (when (and (memq 'total-strokes attributes)
971                (setq value (get-char-attribute char 'total-strokes)))
972       (insert (format "(total-strokes       . %S)%s"
973                       value
974                       line-breaking))
975       (setq attributes (delq 'total-strokes attributes))
976       )
977     (when (and (memq '->ideograph attributes)
978                (setq value (get-char-attribute char '->ideograph)))
979       (insert (format "(->ideograph\t%s)%s"
980                       (mapconcat (lambda (code)
981                                    (cond ((symbolp code)
982                                           (symbol-name code))
983                                          ((integerp code)
984                                           (format "#x%04X" code))
985                                          (t
986                                           (format "%s %S"
987                                                   line-breaking code))))
988                                  value " ")
989                       line-breaking))
990       (setq attributes (delq '->ideograph attributes))
991       )
992     ;; (when (and (memq '->decomposition attributes)
993     ;;            (setq value (get-char-attribute char '->decomposition)))
994     ;;   (insert (format "(->decomposition\t%s)%s"
995     ;;                   (mapconcat (lambda (code)
996     ;;                                (cond ((symbolp code)
997     ;;                                       (symbol-name code))
998     ;;                                      ((characterp code)
999     ;;                                       (if readable
1000     ;;                                           (format "%S" code)
1001     ;;                                         (format "#x%04X"
1002     ;;                                                 (char-int code))
1003     ;;                                         ))
1004     ;;                                      ((integerp code)
1005     ;;                                       (format "#x%04X" code))
1006     ;;                                      (t
1007     ;;                                       (format "%s%S" line-breaking code))))
1008     ;;                              value " ")
1009     ;;                   line-breaking))
1010     ;;   (setq attributes (delq '->decomposition attributes))
1011     ;;   )
1012     (if (equal (get-char-attribute char '->titlecase)
1013                (get-char-attribute char '->uppercase))
1014         (setq attributes (delq '->titlecase attributes)))
1015     (when (and (memq '->mojikyo attributes)
1016                (setq value (get-char-attribute char '->mojikyo)))
1017       (insert (format "(->mojikyo\t\t. %06d)\t; %c%s"
1018                       value (decode-char 'mojikyo value)
1019                       line-breaking))
1020       (setq attributes (delq '->mojikyo attributes))
1021       )
1022     (when (and (memq 'hanyu-dazidian-vol attributes)
1023                (setq value (get-char-attribute char 'hanyu-dazidian-vol)))
1024       (insert (format "(hanyu-dazidian-vol  . %d)%s"
1025                       value line-breaking))
1026       (setq attributes (delq 'hanyu-dazidian-vol attributes))
1027       )
1028     (when (and (memq 'hanyu-dazidian-page attributes)
1029                (setq value (get-char-attribute char 'hanyu-dazidian-page)))
1030       (insert (format "(hanyu-dazidian-page . %d)%s"
1031                       value line-breaking))
1032       (setq attributes (delq 'hanyu-dazidian-page attributes))
1033       )
1034     (when (and (memq 'hanyu-dazidian-char attributes)
1035                (setq value (get-char-attribute char 'hanyu-dazidian-char)))
1036       (insert (format "(hanyu-dazidian-char . %d)%s"
1037                       value line-breaking))
1038       (setq attributes (delq 'hanyu-dazidian-char attributes))
1039       )
1040     (unless readable
1041       (dolist (ignored '(composition
1042                          ->denotational <-subsumptive ->ucs-unified
1043                          ->ideographic-component-forms))
1044         (setq attributes (delq ignored attributes))))
1045     (while attributes
1046       (setq name (car attributes))
1047       (if (setq value (get-char-attribute char name))
1048           (cond ((setq ret (find-charset name))
1049                  (setq name (charset-name ret))
1050                  (if (and (not (memq name dest-ccss))
1051                           (prog1
1052                               (setq value (get-char-attribute char name))
1053                             (setq dest-ccss (cons name dest-ccss))))
1054                      (char-db-insert-ccs-feature name value line-breaking))
1055                  )
1056                 ((string-match "^=>ucs@" (symbol-name name))
1057                  (insert (format "(%-18s . #x%04X)\t; %c%s"
1058                                  name value (decode-char '=ucs value)
1059                                  line-breaking))
1060                  )
1061                 ((eq name 'jisx0208-1978/4X)
1062                  (insert (format "(%-18s . #x%04X)%s"
1063                                  name value
1064                                  line-breaking))
1065                  )
1066                 ((and
1067                   (not readable)
1068                   (not (eq name '->subsumptive))
1069                   (not (eq name '->uppercase))
1070                   (not (eq name '->lowercase))
1071                   (not (eq name '->titlecase))
1072                   (not (eq name '->canonical))
1073                   (not (eq name '->Bopomofo))
1074                   (not (eq name '->mistakable))
1075                   (not (eq name '->ideographic-variants))
1076                   (null (get-char-attribute
1077                          char (intern (format "%s*sources" name))))
1078                   (not (string-match "\\*sources$" (symbol-name name)))
1079                   (null (get-char-attribute
1080                          char (intern (format "%s*note" name))))
1081                   (not (string-match "\\*note$" (symbol-name name)))
1082                   (or (eq name '<-identical)
1083                       (eq name '<-uppercase)
1084                       (eq name '<-lowercase)
1085                       (eq name '<-titlecase)
1086                       (eq name '<-canonical)
1087                       (eq name '<-ideographic-variants)
1088                       ;; (eq name '<-synonyms)
1089                       (string-match "^<-synonyms" (symbol-name name))
1090                       (eq name '<-mistakable)
1091                       (when (string-match "^->" (symbol-name name))
1092                         (cond
1093                          ((string-match "^->fullwidth" (symbol-name name))
1094                           (not (and (consp value)
1095                                     (characterp (car value))
1096                                     (encode-char
1097                                      (car value) '=ucs 'defined-only)))
1098                           )
1099                          (t)))
1100                       ))
1101                  )
1102                 ((or (eq name 'ideographic-structure)
1103                      (eq name 'ideographic-combination)
1104                      (eq name 'ideographic-)
1105                      (eq name '=decomposition)
1106                      (string-match "^=>decomposition" (symbol-name name))
1107                      (string-match "^\\(->\\|<-\\)[^*]*$" (symbol-name name))
1108                      (string-match "^\\(->\\|<-\\)[^*]*\\*sources$"
1109                                    (symbol-name name))
1110                      )
1111                  (char-db-insert-relation-feature char name value
1112                                                   line-breaking
1113                                                   ccss readable))
1114                 ((memq name '(ideograph=
1115                               original-ideograph-of
1116                               ancient-ideograph-of
1117                               vulgar-ideograph-of
1118                               wrong-ideograph-of
1119                               ;; simplified-ideograph-of
1120                               ideographic-variants
1121                               ;; ideographic-different-form-of
1122                               ))
1123                  (insert (format "(%-18s%s " name line-breaking))
1124                  (setq lbs (concat "\n" (make-string (current-column) ?\ ))
1125                        separator nil)
1126                  (while (consp value)
1127                    (setq cell (car value))
1128                    (if (and (consp cell)
1129                             (consp (car cell)))
1130                        (progn
1131                          (if separator
1132                              (insert lbs))
1133                          (char-db-insert-alist cell readable)
1134                          (setq separator lbs))
1135                      (if separator
1136                          (insert separator))
1137                      (insert (prin1-to-string cell))
1138                      (setq separator " "))
1139                    (setq value (cdr value)))
1140                  (insert ")")
1141                  (insert line-breaking))
1142                 ((consp value)
1143                  (insert (format "(%-18s " name))
1144                  (setq lbs (concat "\n" (make-string (current-column) ?\ ))
1145                        separator nil)
1146                  (while (consp value)
1147                    (setq cell (car value))
1148                    (if (and (consp cell)
1149                             (consp (car cell))
1150                             (setq ret (condition-case nil
1151                                           (find-char cell)
1152                                         (error nil))))
1153                        (progn
1154                          (setq rest cell
1155                                al nil
1156                                cal nil)
1157                          (while rest
1158                            (setq key (car (car rest)))
1159                            (if (find-charset key)
1160                                (setq cal (cons key cal))
1161                              (setq al (cons key al)))
1162                            (setq rest (cdr rest)))
1163                          (if separator
1164                              (insert lbs))
1165                          (insert-char-attributes ret
1166                                                  readable
1167                                                  al cal)
1168                          (setq separator lbs))
1169                      (setq ret (prin1-to-string cell))
1170                      (if separator
1171                          (if (< (+ (current-column)
1172                                    (length ret)
1173                                    (length separator))
1174                                 76)
1175                              (insert separator)
1176                            (insert lbs)))
1177                      (insert ret)
1178                      (setq separator " "))
1179                    (setq value (cdr value)))
1180                  (insert ")")
1181                  (insert line-breaking))
1182                 (t
1183                  (insert (format "(%-18s" name))
1184                  (setq ret (prin1-to-string value))
1185                  (unless (< (+ (current-column)
1186                                (length ret)
1187                                3)
1188                             76)
1189                    (insert line-breaking))
1190                  (insert " . " ret ")" line-breaking)
1191                  ;; (insert (format "(%-18s . %S)%s"
1192                  ;;                 name value
1193                  ;;                 line-breaking))
1194                  )
1195                 ))
1196       (setq attributes (cdr attributes)))
1197     (insert ")")))
1198
1199 (defun insert-char-data (char &optional readable
1200                               attributes)
1201   (save-restriction
1202     (narrow-to-region (point)(point))
1203     (insert "(define-char
1204   '")
1205     (insert-char-attributes char readable attributes)
1206     (insert ")\n")
1207     (goto-char (point-min))
1208     (while (re-search-forward "[ \t]+$" nil t)
1209       (replace-match ""))
1210     ;; from tabify.
1211     (goto-char (point-min))
1212     (while (re-search-forward "[ \t][ \t][ \t]*" nil t)
1213       (let ((column (current-column))
1214             (indent-tabs-mode t))
1215         (delete-region (match-beginning 0) (point))
1216         (indent-to column)))
1217     (goto-char (point-max))
1218     ;; (tabify (point-min)(point-max))
1219     ))
1220
1221 (defun insert-char-data-with-variant (char &optional printable
1222                                            no-ucs-unified
1223                                            script excluded-script)
1224   (insert-char-data char printable)
1225   (let ((variants (char-variants char))
1226         rest
1227         variant vs ret)
1228     (setq variants (sort variants #'<))
1229     (setq rest variants)
1230     (setq variants (cons char variants))
1231     (while rest
1232       (setq variant (car rest))
1233       (unless (get-char-attribute variant '<-subsumptive)
1234         (if (and (or (null script)
1235                      (null (setq vs (get-char-attribute variant 'script)))
1236                      (memq script vs))
1237                  (or (null excluded-script)
1238                      (null (setq vs (get-char-attribute variant 'script)))
1239                      (not (memq excluded-script vs))))
1240             (unless (and no-ucs-unified (get-char-attribute variant '=ucs))
1241               (insert-char-data variant printable)
1242               (if (setq ret (char-variants variant))
1243                   (while ret
1244                     (or (memq (car ret) variants)
1245                         ;; (get-char-attribute (car ret) '<-subsumptive)
1246                         (setq rest (nconc rest (list (car ret)))))
1247                     (setq ret (cdr ret)))))))
1248       (setq rest (cdr rest)))))
1249
1250 (defun insert-char-range-data (min max &optional script excluded-script)
1251   (let ((code min)
1252         char)
1253     (while (<= code max)
1254       (setq char (decode-char '=ucs code))
1255       (if (encode-char char '=ucs 'defined-only)
1256           (insert-char-data-with-variant char nil 'no-ucs-unified
1257                                          script excluded-script))
1258       (setq code (1+ code)))))
1259
1260 (defun write-char-range-data-to-file (min max file
1261                                           &optional script excluded-script)
1262   (let ((coding-system-for-write char-db-file-coding-system))
1263     (with-temp-buffer
1264       (insert (format ";; -*- coding: %s -*-\n"
1265                       char-db-file-coding-system))
1266       (insert-char-range-data min max script excluded-script)
1267       (write-region (point-min)(point-max) file))))
1268
1269 (defvar what-character-original-window-configuration)
1270
1271 ;;;###autoload
1272 (defun what-char-definition (char)
1273   (interactive (list (char-after)))
1274   (let ((buf (get-buffer-create "*Character Description*"))
1275         (the-buf (current-buffer))
1276         (win-conf (current-window-configuration)))
1277     (pop-to-buffer buf)
1278     (make-local-variable 'what-character-original-window-configuration)
1279     (setq what-character-original-window-configuration win-conf)
1280     (setq buffer-read-only nil)
1281     (erase-buffer)
1282     (condition-case err
1283         (progn
1284           (insert-char-data-with-variant char 'printable)
1285           (unless (char-attribute-alist char)
1286             (insert (format ";; = %c\n"
1287                             (let* ((rest (split-char char))
1288                                    (ccs (pop rest))
1289                                    (code (pop rest)))
1290                               (while rest
1291                                 (setq code (logior (lsh code 8)
1292                                                    (pop rest))))
1293                               (decode-char ccs code)))))
1294           ;; (char-db-update-comment)
1295           (set-buffer-modified-p nil)
1296           (view-mode the-buf (lambda (buf)
1297                                (set-window-configuration
1298                                 what-character-original-window-configuration)
1299                                ))
1300           (goto-char (point-min)))
1301       (error (progn
1302                (set-window-configuration
1303                 what-character-original-window-configuration)
1304                (signal (car err) (cdr err)))))))
1305
1306 (provide 'char-db-util)
1307
1308 ;;; char-db-util.el ends here