+(defvar char-db-coded-charset-priority-list
+ (let ((rest default-coded-charset-priority-list)
+ dest)
+ (while rest
+ (when (symbolp (car rest))
+ (cond ((memq (car rest)
+ '(latin-viscii-lower
+ latin-viscii-upper
+ ipa
+ lao
+ ethiopic
+ arabic-digit
+ arabic-1-column
+ arabic-2-column)))
+ ((string-match "^chinese-big5" (symbol-name (car rest))))
+ ((string-match "^ideograph-gt-pj-" (symbol-name (car rest)))
+ (unless (memq 'ideograph-gt dest)
+ (setq dest (cons 'ideograph-gt dest))))
+ (t
+ (setq dest (cons (car rest) dest)))))
+ (setq rest (cdr rest)))
+ (append (sort dest #'char-attribute-name<)
+ '(chinese-big5-cdp chinese-big5-eten chinese-big5))))
+
+(defun char-db-insert-char-spec (char &optional readable column)
+ (unless column
+ (setq column (current-column)))
+ (let (char-spec ret al cal key temp-char)
+ (cond ((characterp char)
+ (cond ((and (setq ret (get-char-attribute char 'ucs))
+ (not (and (<= #xE000 ret)(<= ret #xF8FF))))
+ (setq char-spec (list (cons 'ucs ret)))
+ (if (setq ret (get-char-attribute char 'name))
+ (setq char-spec (cons (cons 'name ret) char-spec)))
+ )
+ ((setq ret
+ (let ((default-coded-charset-priority-list
+ char-db-coded-charset-priority-list))
+ (split-char char)))
+ (setq char-spec (list ret))
+ (dolist (ccs (delq (car ret) (charset-list)))
+ (if (or (and (charset-iso-final-char ccs)
+ (setq ret (get-char-attribute char ccs)))
+ (eq ccs 'ideograph-daikanwa))
+ (setq char-spec (cons (cons ccs ret) char-spec))))
+ (if (null char-spec)
+ (setq char-spec (split-char char)))
+ (if (setq ret (get-char-attribute char 'name))
+ (setq char-spec (cons (cons 'name ret) char-spec)))
+ )))
+ ((consp char)
+ (setq char-spec char)
+ (setq char nil)))
+ (unless (or char
+ (condition-case nil
+ (setq char (find-char char-spec))
+ (error nil)))
+ ;; define temporary character
+ ;; Current implementation is dirty.
+ (setq temp-char (define-char (cons '(ideograph-daikanwa . 0)
+ char-spec)))
+ (remove-char-attribute temp-char 'ideograph-daikanwa)
+ (setq char temp-char))
+ (setq al nil
+ cal nil)
+ (while char-spec
+ (setq key (car (car char-spec)))
+ (unless (memq key char-db-ignored-attributes)
+ (if (find-charset key)
+ (setq cal (cons key cal))
+ (setq al (cons key al))))
+ (setq char-spec (cdr char-spec)))
+ (unless (or cal
+ (memq 'ideographic-structure al))
+ (push 'ideographic-structure al))
+ (insert-char-attributes char
+ readable
+ (or al 'none) cal)
+ (when temp-char
+ ;; undefine temporary character
+ ;; Current implementation is dirty.
+ (setq char-spec (char-attribute-alist temp-char))
+ (while char-spec
+ (remove-char-attribute temp-char (car (car char-spec)))
+ (setq char-spec (cdr char-spec))))))
+