diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/rexml/encodings/EUC-JP.rb | 4 | ||||
| -rw-r--r-- | lib/rexml/encodings/SHIFT_JIS.rb | 18 |
2 files changed, 19 insertions, 3 deletions
diff --git a/lib/rexml/encodings/EUC-JP.rb b/lib/rexml/encodings/EUC-JP.rb index 1be5663be..def760b30 100644 --- a/lib/rexml/encodings/EUC-JP.rb +++ b/lib/rexml/encodings/EUC-JP.rb @@ -18,11 +18,11 @@ rescue LoadError module REXML module Encoding def from_euc_jp(str) - return Iconv::iconv("utf-8", "euc-jp", str).join + return Iconv::iconv("utf-8", "euc-jp", str).join('') end def to_euc_jp content - return Iconv::iconv("euc-jp", "utf-8", content).join + return Iconv::iconv("euc-jp", "utf-8", content).join('') end end end diff --git a/lib/rexml/encodings/SHIFT_JIS.rb b/lib/rexml/encodings/SHIFT_JIS.rb index 865017453..27e456940 100644 --- a/lib/rexml/encodings/SHIFT_JIS.rb +++ b/lib/rexml/encodings/SHIFT_JIS.rb @@ -13,5 +13,21 @@ begin end end rescue LoadError - raise "uconv is required for Japanese encoding support." + begin + require 'iconv' + module REXML + module Encoding + def from_shift_jis(str) + return Iconv::iconv("utf-8", "shift_jis", str).join('') + end + + def to_shift_jis content + return Iconv::iconv("shift_jis", "utf-8", content).join('') + end + end + end + rescue LoadError + raise "uconv or iconv is required for Japanese encoding support." + end + end |
