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