2003-10-10 08:54:46 -04:00
|
|
|
require "iconv"
|
|
|
|
raise LoadError unless defined? Iconv
|
|
|
|
|
|
|
|
module REXML
|
2003-12-08 21:41:33 -05:00
|
|
|
module Encoding
|
2005-04-09 13:03:32 -04:00
|
|
|
def decode_iconv(str)
|
|
|
|
Iconv.conv(UTF_8, @encoding, str)
|
2003-12-08 21:41:33 -05:00
|
|
|
end
|
2003-10-10 08:54:46 -04:00
|
|
|
|
2005-04-09 13:03:32 -04:00
|
|
|
def encode_iconv(content)
|
|
|
|
Iconv.conv(@encoding, UTF_8, content)
|
|
|
|
end
|
|
|
|
|
|
|
|
register("ICONV") do |obj|
|
|
|
|
Iconv.conv(UTF_8, obj.encoding, nil)
|
|
|
|
class << obj
|
|
|
|
alias decode decode_iconv
|
|
|
|
alias encode encode_iconv
|
|
|
|
end
|
2003-12-08 21:41:33 -05:00
|
|
|
end
|
|
|
|
end
|
2003-10-10 08:54:46 -04:00
|
|
|
end
|