From 762ce89d584fcb8597f6497b0078f4a84f19803e Mon Sep 17 00:00:00 2001 From: YAMAMOTO Mitsuharu Date: Wed, 30 Aug 2006 08:51:52 +0000 Subject: [PATCH] (mac-string-to-utxt): If adjustment for MacJapanese results in ASCII-only string, encode original one directly. --- lisp/ChangeLog | 5 +++++ lisp/term/mac-win.el | 21 +++++++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index b628594097d..d8ec23f04e5 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2006-08-30 YAMAMOTO Mitsuharu + + * term/mac-win.el (mac-string-to-utxt): If adjustment for MacJapanese + results in ASCII-only string, encode original one directly. + 2006-08-29 Romain Francoise * startup.el (normal-splash-screen, fancy-splash-screens): Make diff --git a/lisp/term/mac-win.el b/lisp/term/mac-win.el index 538aa09b2c5..20a65976a5c 100644 --- a/lisp/term/mac-win.el +++ b/lisp/term/mac-win.el @@ -1287,14 +1287,19 @@ correspoinding TextEncodingBase value." (find-coding-systems-string string))) (setq coding-system (coding-system-change-eol-conversion coding-system 'mac)) - (when (and (eq system-type 'darwin) - (eq coding-system 'japanese-shift-jis-mac)) - (setq encoding mac-text-encoding-mac-japanese-basic-variant) - (setq string (subst-char-in-string ?\\ ?\x80 string)) - (subst-char-in-string ?\¥ ?\x5c string t)) - (setq data (mac-code-convert-string - (encode-coding-string string coding-system) - (or encoding coding-system) nil))) + (let ((str string)) + (when (and (eq system-type 'darwin) + (eq coding-system 'japanese-shift-jis-mac)) + (setq encoding mac-text-encoding-mac-japanese-basic-variant) + (setq str (subst-char-in-string ?\\ ?\x80 str)) + (subst-char-in-string ?\¥ ?\x5c str t) + ;; ASCII-only? + (if (string-match "\\`[\x00-\x7f]*\\'" str) + (setq str nil))) + (and str + (setq data (mac-code-convert-string + (encode-coding-string str coding-system) + (or encoding coding-system) nil))))) (or data (encode-coding-string string (if (eq (byteorder) ?B) 'utf-16be-mac 'utf-16le-mac))))) -- 2.11.4.GIT