(chinese-simplify-string): Use `char-feature' instead of
[chise/tomoyo-tools.git] / ideo-trans.el
index 882319d..3e9689a 100644 (file)
@@ -97,8 +97,8 @@
                    (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)
+                   (if (setq ret (char-feature chr '=>ucs*))
+                       (setq chr (decode-char '=ucs@gb ret))
                      chr))
                   (t chr)))
        (char-to-string
   (let (ret)
     (mapconcat
      (lambda (chr)
+       (setq uchr
+            (cond ((setq ret (char-feature chr '=>ucs@jis))
+                   (setq chr (decode-char '=ucs@jis ret)))
+                  ((setq ret (char-ucs chr))
+                   (setq chr (decode-char '=ucs@jis ret))
+                   (if (setq ret (char-feature chr '=>ucs*))
+                       (setq chr (decode-char '=ucs@jis ret))
+                     chr))
+                  (t chr)))
        (setq ret (or (char-feature chr '->simplified@JP/Jouyou)
                     (char-feature chr '->simplified@JP)
                     (char-feature chr '->simplified)))
     (nth (1- ret) chars)))
 
 ;;;###autoload
-(defun chinese-traditionalize-string (string)
+(defun chinese-traditionalize-string (string &optional selector)
   "Convert simplified Chinese characters in STRING to traditional characters."
+  (unless selector
+    (setq selector
+         (lambda (chars)
+           (ideo-trans-select-char chars (format "%c => " chr)))))
   (let (ret)
     (mapconcat
      (lambda (chr)
        (char-to-string
        (cond ((car (char-feature chr '<-simplified))
               (if (cdr ret)
-                  (ideo-trans-select-char ret (format "%c => " chr))
+                  (funcall selector ret)
                 (car ret)))
              ((progn
                 (setq ret
   'chinese-traditionalize-string)
 
 ;;;###autoload
-(defun japanese-traditionalize-string (string)
+(defun japanese-traditionalize-string (string &optional selector)
   "Convert simplified Kanji in STRING into traditional characters."
+  (unless selector
+    (setq selector
+         (lambda (chars)
+           (ideo-trans-select-char chars (format "%c => " chr)))))
   (let (ret)
     (mapconcat
      (lambda (chr)
                             (char-feature chr '<-simplified@JP)
                             (char-feature chr '<-simplified)))
               (if (cdr ret)
-                  (ideo-trans-select-char ret (format "%c => " chr))
+                  (funcall selector ret)
                 (car ret)))
              ((progn
                 (setq ret