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