From: tomo Date: Tue, 28 May 2002 10:45:27 +0000 (+0000) Subject: New file. X-Git-Tag: ids-0_0-1~281 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=f9cab9bff3e64d8f851bc9a6806124fa7a42e18d;p=chise%2Fids.git New file. --- diff --git a/ids-read.el b/ids-read.el new file mode 100644 index 0000000..7b7d8d0 --- /dev/null +++ b/ids-read.el @@ -0,0 +1,77 @@ +;;; ids-read.el --- Reader for IDS-* files + +;; Copyright (C) 2002 MORIOKA Tomohiko + +;; Author: MORIOKA Tomohiko +;; Keywords: IDS, IDC, Ideographs, UCS, Unicode + +;; This file is a part of IDS. + +;; This program is free software; you can redistribute it and/or +;; modify it under the terms of the GNU General Public License as +;; published by the Free Software Foundation; either version 2, or (at +;; your option) any later version. + +;; This program is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program; see the file COPYING. If not, write to +;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +;; Boston, MA 02111-1307, USA. + +;;; Code: + +(require 'ids) + +;;;###autoload +(defun ids-read-buffer (buffer) + (interactive "bBuffer = ") + (save-excursion + (set-buffer buffer) + (goto-char (point-min)) + (let (line chs ids char structure) + (while (not (eobp)) + (unless (looking-at ";") + (setq line + (split-string + (buffer-substring (point-at-bol)(point-at-eol)) + "\t")) + (setq chs (car line) + ids (nth 2 line)) + (setq char + (cond + ((string-match "U[-+]\\([0-9A-F]+\\)" chs) + (decode-char 'ucs + (string-to-int (match-string 1 chs) 16))) + ((string-match "M-\\([0-9]+\\)" chs) + (decode-char 'ideograph-daikanwa + (string-to-int (match-string 1 chs)))) + )) + (when (and char + (>= (length ids) 3) + (not (string-match "\\?" ids)) + (consp (setq structure (ids-parse-string ids)))) + (put-char-attribute char + 'ideographic-structure + (cdr (car structure)))) + ) + (forward-line) + )))) + +;;;###autoload +(defun ids-read-file (file) + (interactive "fIDS file = ") + (with-temp-buffer + (insert-file-contents file) + (ids-read-buffer (current-buffer)))) + + +;;; @ End. +;;; + +(provide 'ids-read) + +;;; ids-read.el ends here