2003-06-09 21:31:01 -04:00
|
|
|
begin
|
2003-12-08 21:41:33 -05:00
|
|
|
require 'iconv'
|
2003-06-09 21:31:01 -04:00
|
|
|
|
2003-12-08 21:41:33 -05:00
|
|
|
module REXML
|
|
|
|
module Encoding
|
|
|
|
@@__REXML_encoding_methods =<<-EOL
|
|
|
|
def decode(str)
|
|
|
|
return Iconv::iconv("utf-8", "euc-jp", str)[0]
|
|
|
|
end
|
2003-06-09 21:31:01 -04:00
|
|
|
|
2003-12-08 21:41:33 -05:00
|
|
|
def encode content
|
|
|
|
return Iconv::iconv("euc-jp", "utf-8", content)[0]
|
|
|
|
end
|
|
|
|
EOL
|
|
|
|
end
|
|
|
|
end
|
2003-06-09 21:31:01 -04:00
|
|
|
rescue LoadError
|
2003-07-09 18:28:42 -04:00
|
|
|
begin
|
2003-12-08 21:41:33 -05:00
|
|
|
require 'uconv'
|
|
|
|
|
|
|
|
module REXML
|
|
|
|
module Encoding
|
|
|
|
@@__REXML_encoding_methods =<<-EOL
|
|
|
|
def decode(str)
|
|
|
|
return Uconv::euctou8(str)
|
|
|
|
end
|
2003-07-09 18:28:42 -04:00
|
|
|
|
2003-12-08 21:41:33 -05:00
|
|
|
def encode content
|
|
|
|
return Uconv::u8toeuc(content)
|
|
|
|
end
|
|
|
|
EOL
|
|
|
|
end
|
|
|
|
end
|
2003-07-09 18:28:42 -04:00
|
|
|
rescue LoadError
|
2003-10-10 08:54:46 -04:00
|
|
|
raise "uconv or iconv is required for Japanese encoding support."
|
2003-07-09 18:28:42 -04:00
|
|
|
end
|
2003-06-09 21:31:01 -04:00
|
|
|
end
|