From ce43dc989f62d5787739b40b6883648401c51891 Mon Sep 17 00:00:00 2001 From: tomo Date: Thu, 8 Apr 2004 11:22:42 +0000 Subject: [PATCH] (ideo-translate-string-into-simplified-chinese): Use `char-feature' to refer `=>ucs@gb'; use `=ucs@gb' instead of `=ucs' to decode; try to convert compatible ideographs to non-compatible ideographs. (ideo-translate-string-into-simplified-japanese): New function. --- ideo-trans.el | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/ideo-trans.el b/ideo-trans.el index 6a1a1fd..df05dae 100644 --- a/ideo-trans.el +++ b/ideo-trans.el @@ -31,10 +31,14 @@ (mapconcat (lambda (chr) (setq uchr - (if (setq ret (or (char-ucs chr) - (get-char-attribute chr '=>ucs@gb))) - (decode-char '=ucs ret) - chr)) + (cond ((setq ret (char-feature chr '=>ucs@gb)) + (setq chr (decode-char '=ucs@gb ret))) + ((setq ret (char-ucs chr)) + (setq chr (decode-char '=ucs@gb ret)) + (if (setq ret (get-char-attribute chr '=>ucs*)) + (decode-char '=ucs@gb ret) + chr)) + (t chr))) (char-to-string (if (setq ret (encode-char uchr 'chinese-gb12345)) (decode-char 'chinese-gb2312 ret) @@ -46,6 +50,24 @@ 'ideo-translate-string-into-simplified-chinese) ;;;###autoload +(defun ideo-translate-string-into-simplified-japanese (string) + "Simplify traditional Kanji characters in STRING." + (let (uchr ret) + (mapconcat + (lambda (chr) + (setq ret (or (char-feature chr '->simplified@JP/Jouyou) + (char-feature chr '->simplified@JP) + (char-feature chr '->simplified))) + (char-to-string + (cond ((car ret)) + ((setq ret (char-feature chr '=>ucs@jis)) + (decode-char '=ucs@jis ret)) + ((setq ret (char-ucs chr)) + (decode-char '=ucs@jp ret)) + (t chr)))) + string ""))) + +;;;###autoload (defun ideo-translate-region-into-traditional (start end) (interactive "r") (save-excursion -- 1.7.10.4