diff options
Diffstat (limited to 'lib/rexml/encodings/EUC-JP.rb')
-rw-r--r-- | lib/rexml/encodings/EUC-JP.rb | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/lib/rexml/encodings/EUC-JP.rb b/lib/rexml/encodings/EUC-JP.rb index 684df0bbd6..db37b6bf0d 100644 --- a/lib/rexml/encodings/EUC-JP.rb +++ b/lib/rexml/encodings/EUC-JP.rb @@ -1,13 +1,28 @@ -require 'uconv' - module REXML module Encoding - def decode_eucjp(str) - Uconv::euctou8(str) - end + begin + require 'uconv' + + def decode_eucjp(str) + Uconv::euctou8(str) + end + + def encode_eucjp content + Uconv::u8toeuc(content) + end + rescue LoadError + require 'nkf' + + EUCTOU8 = '-Ewm0' + U8TOEUC = '-Wem0' - def encode_eucjp content - Uconv::u8toeuc(content) + def decode_eucjp(str) + NKF.nkf(EUCTOU8, str) + end + + def encode_eucjp content + NKF.nkf(U8TOEUC, content) + end end register("EUC-JP") do |obj| |