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