1 ;;; ideo-trans.el --- Translation utility for Ideographic Strings
3 ;; Copyright (C) 2003,2004 MORIOKA Tomohiko
5 ;; Author: MORIOKA Tomohiko <tomo@kanji.zinbun.kyoto-u.ac.jp>
6 ;; Keywords: Ideographs, Character Database, Chaon, CHISE
8 ;; This file is a part of tomoyo-tools.
10 ;; This program is free software; you can redistribute it and/or
11 ;; modify it under the terms of the GNU General Public License as
12 ;; published by the Free Software Foundation; either version 2, or (at
13 ;; your option) any later version.
15 ;; This program is distributed in the hope that it will be useful, but
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ;; General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with this program; see the file COPYING. If not, write to
22 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
28 (defun ideo-translate-string-into-simplified-chinese (string)
29 "Simplify Chinese traditional characters in STRING."
34 (cond ((setq ret (char-feature chr '=>ucs@gb))
35 (setq chr (decode-char '=ucs@gb ret)))
36 ((setq ret (char-ucs chr))
37 (setq chr (decode-char '=ucs@gb ret))
38 (if (setq ret (get-char-attribute chr '=>ucs*))
39 (decode-char '=ucs@gb ret)
43 (if (setq ret (encode-char uchr 'chinese-gb12345))
44 (decode-char 'chinese-gb2312 ret)
49 (define-obsolete-function-alias 'ideo-trans-simplify-chinese-string
50 'ideo-translate-string-into-simplified-chinese)
53 (defun ideo-translate-string-into-simplified-japanese (string)
54 "Simplify traditional Kanji characters in STRING."
58 (setq ret (or (char-feature chr '->simplified@JP/Jouyou)
59 (char-feature chr '->simplified@JP)
60 (char-feature chr '->simplified)))
63 ((setq ret (char-feature chr '=>ucs@jis))
64 (decode-char '=ucs@jis ret))
65 ((setq ret (char-ucs chr))
66 (decode-char '=ucs@jp ret))
71 (defun ideo-translate-region-into-traditional (start end)
75 (narrow-to-region start end)
77 (let (chr ret rret i prompt)
78 (while (and (skip-chars-forward "\x00-\xFF")
80 (setq chr (char-after))
81 (if (setq ret (or (get-char-attribute chr '<-simplified@JP/Jouyou)
82 (get-char-attribute chr '<-simplified@jp-jouyou)
83 (get-char-attribute chr '<-simplified@JP)
84 (get-char-attribute chr '<-simplified@jp)
85 (get-char-attribute chr '<-jp-simplified)
86 (get-char-attribute chr '<-simplified)))
93 (mapconcat (lambda (cell)
95 (format "%d. %c" i cell))
98 (while (and (setq rret
100 (read-string prompt)))
102 (<= rret (length ret))))))
104 (insert (nth (1- rret) ret)))
108 (forward-char))))))))
114 (provide 'ideo-trans)
116 ;;; ideo-trans.el ends here