X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=ids-read.el;h=ff05c189c4c915370256fe8b9aa4b270c9f5975f;hb=6ef5bfb4397a965dd6a9d523e53b59913d393803;hp=f759d14bad17986a3991e6a833ab010bfc064f08;hpb=14e7cb73cf809a040e4223bb4ece4325d047cc1b;p=chise%2Fids.git diff --git a/ids-read.el b/ids-read.el index f759d14..ff05c18 100644 --- a/ids-read.el +++ b/ids-read.el @@ -1,6 +1,6 @@ ;;; ids-read.el --- Reader for IDS-* files -;; Copyright (C) 2002 MORIOKA Tomohiko +;; Copyright (C) 2002,2003,2004 MORIOKA Tomohiko ;; Author: MORIOKA Tomohiko ;; Keywords: IDS, IDC, Ideographs, UCS, Unicode @@ -27,12 +27,12 @@ (require 'ids) ;;;###autoload -(defun ids-read-buffer (buffer &optional simplify) +(defun ids-read-buffer (buffer &optional simplify soft) (interactive "bBuffer = \nP") (save-excursion (set-buffer buffer) (goto-char (point-min)) - (let (line chs ids code char structure) + (let (line chs ids code char u-char structure) (while (not (eobp)) (unless (looking-at ";") (setq line @@ -40,16 +40,36 @@ (buffer-substring (point-at-bol)(point-at-eol)) "\t")) (setq chs (car line) - ids (nth 2 line)) + ids (nth 2 line) + u-char nil) (setq char (cond ((string-match "U[-+]\\([0-9A-F]+\\)" chs) - (decode-char 'ucs - (string-to-int (match-string 1 chs) 16))) + (setq code (string-to-int (match-string 1 chs) 16)) + (setq u-char (decode-char '=ucs@unicode code)) + (decode-char 'ucs code)) ((string-match "J90-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\)" chs) (decode-char 'japanese-jisx0208-1990 (string-to-int (match-string 1 chs) 16))) + ((string-match + "C\\([1-7]\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\)" + chs) + (decode-char + (intern + (concat "chinese-cns11643-" (match-string 1 chs))) + (string-to-int (match-string 2 chs) 16))) + ((string-match "CDP-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\)" + chs) + (decode-char '=big5-cdp + (string-to-int (match-string 1 chs) 16))) + ((string-match + "HZK\\([0-9][0-9]\\)-\\([0-9A-F][0-9A-F][0-9A-F][0-9A-F]\\)" + chs) + (decode-char (intern + (format "=hanziku-%d" + (string-to-int (match-string 1 chs)))) + (string-to-int (match-string 2 chs) 16))) ((string-match "M-\\([0-9]+\\)'" chs) (setq code (string-to-int (match-string 1 chs))) (map-char-attribute @@ -88,19 +108,33 @@ (>= (length ids) 3) (not (string-match "\\?" ids)) (consp (setq structure (ids-parse-string ids simplify)))) - (put-char-attribute char - 'ideographic-structure - (cdr (car structure)))) + (when (or (not soft) + (null + (get-char-attribute char 'ideographic-structure))) + (put-char-attribute char + 'ideographic-structure + (cdr (car structure)))) + (when (and u-char + (not (eq char u-char)) + (or (not soft) + (null + (get-char-attribute + u-char 'ideographic-structure)))) + (put-char-attribute + u-char 'ideographic-structure + (ideographic-structure-convert-to-domain + (cdr (car structure)) 'unicode))) + ) ) (forward-line) )))) ;;;###autoload -(defun ids-read-file (file &optional simplify) +(defun ids-read-file (file &optional simplify soft) (interactive "fIDS file = \nP") (with-temp-buffer (insert-file-contents file) - (ids-read-buffer (current-buffer) simplify))) + (ids-read-buffer (current-buffer) simplify soft))) ;;; @ End.