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