diff options
Diffstat (limited to 'lib/rexml/encodings/EUC-JP.rb')
-rw-r--r-- | lib/rexml/encodings/EUC-JP.rb | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/lib/rexml/encodings/EUC-JP.rb b/lib/rexml/encodings/EUC-JP.rb index cedd6751e7..23a1c3c657 100644 --- a/lib/rexml/encodings/EUC-JP.rb +++ b/lib/rexml/encodings/EUC-JP.rb @@ -13,5 +13,20 @@ begin end end rescue LoadError - raise "uconv is required for Japanese encoding support." + begin + require 'iconv' + module REXML + module Encoding + def from_euc_jp(str) + return Iconv::iconv("utf-8", "euc-jp", str)[0] + end + + def to_euc_jp content + return Iconv::iconv("euc-jp", "utf-8", content)[0] + end + end + end + rescue LoadError + raise "uconv or iconv is required for Japanese encoding support." + end end |