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