aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rexml/encodings/SHIFT_JIS.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rexml/encodings/SHIFT_JIS.rb')
-rw-r--r--lib/rexml/encodings/SHIFT_JIS.rb18
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/rexml/encodings/SHIFT_JIS.rb b/lib/rexml/encodings/SHIFT_JIS.rb
index 8650174538..27e4569403 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