;;; ideo-trans.el --- Translation utility for Ideographic Strings ;; Copyright (C) 2003,2004 MORIOKA Tomohiko ;; Author: MORIOKA Tomohiko ;; Keywords: Ideographs, Character Database, Chaon, CHISE ;; This file is a part of tomoyo-tools. ;; 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: ;;;###autoload (defun ideo-translate-string-into-simplified-chinese (string) "Simplify Chinese traditional characters in STRING." (let (uchr ret) (mapconcat (lambda (chr) (setq uchr (if (setq ret (or (char-ucs chr) (get-char-attribute chr '=>ucs@gb))) (decode-char '=ucs ret) chr)) (char-to-string (if (setq ret (encode-char uchr 'chinese-gb12345)) (decode-char 'chinese-gb2312 ret) chr))) string ""))) ;;;###autoload (define-obsolete-function-alias 'ideo-trans-simplify-chinese-string 'ideo-translate-string-into-simplified-chinese) ;;;###autoload (defun ideo-translate-region-into-traditional (start end) (interactive "r") (save-excursion (save-restriction (narrow-to-region start end) (goto-char start) (let (chr ret rret i prompt) (while (and (skip-chars-forward "\x00-\xFF") (not (eobp))) (setq chr (char-after)) (if (setq ret (or (get-char-attribute chr '<-simplified@JP/Jouyou) (get-char-attribute chr '<-simplified@jp-jouyou) (get-char-attribute chr '<-simplified@JP) (get-char-attribute chr '<-simplified@jp) (get-char-attribute chr '<-jp-simplified) (get-char-attribute chr '<-simplified))) (progn (if (cdr ret) (progn (setq i 0) (setq prompt (concat (mapconcat (lambda (cell) (setq i (1+ i)) (format "%d. %c" i cell)) ret " ") " : ")) (while (and (setq rret (string-to-int (read-string prompt))) (not (and (< 0 rret) (<= rret (length ret)))))) (delete-char) (insert (nth (1- rret) ret))) (delete-char) (insert (car ret)))) (or (eobp) (forward-char)))))))) ;;; @ End. ;;; (provide 'ideo-trans) ;;; ideo-trans.el ends here