2003-12-12 16:17:41 -05:00
|
|
|
begin
|
|
|
|
require 'iconv'
|
|
|
|
|
|
|
|
module REXML
|
|
|
|
module Encoding
|
|
|
|
@@__REXML_encoding_methods =<<-EOL
|
|
|
|
def decode(str)
|
2004-12-13 06:50:13 -05:00
|
|
|
return Iconv::iconv("utf-8", "shift_jis", str)[0]
|
2003-12-12 16:17:41 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def encode content
|
2004-12-13 06:50:13 -05:00
|
|
|
return Iconv::iconv("shift_jis", "utf-8", content)[0]
|
2003-12-12 16:17:41 -05:00
|
|
|
end
|
|
|
|
EOL
|
|
|
|
end
|
|
|
|
end
|
|
|
|
rescue LoadError
|
|
|
|
begin
|
|
|
|
require 'uconv'
|
|
|
|
|
|
|
|
module REXML
|
|
|
|
module Encoding
|
|
|
|
@@__REXML_encoding_methods =<<-EOL
|
2004-12-13 06:50:13 -05:00
|
|
|
def encode(content)
|
2003-12-12 16:17:41 -05:00
|
|
|
Uconv::u8tosjis(content)
|
|
|
|
end
|
|
|
|
|
2004-12-13 06:50:13 -05:00
|
|
|
def decode(str)
|
2003-12-12 16:17:41 -05:00
|
|
|
Uconv::sjistou8(str)
|
|
|
|
end
|
|
|
|
EOL
|
|
|
|
end
|
|
|
|
end
|
|
|
|
rescue LoadError
|
|
|
|
raise "uconv or iconv is required for Japanese encoding support."
|
|
|
|
end
|
|
|
|
end
|