2003-06-09 21:31:01 -04:00
|
|
|
require 'rexml/encoding'
|
|
|
|
|
|
|
|
module REXML
|
2008-10-01 09:46:53 -04:00
|
|
|
class Output
|
|
|
|
include Encoding
|
2009-03-05 22:56:38 -05:00
|
|
|
|
2003-12-08 21:41:33 -05:00
|
|
|
attr_reader :encoding
|
|
|
|
|
2008-10-01 09:46:53 -04:00
|
|
|
def initialize real_IO, encd="iso-8859-1"
|
|
|
|
@output = real_IO
|
|
|
|
self.encoding = encd
|
2003-06-09 21:31:01 -04:00
|
|
|
|
2011-03-02 10:36:48 -05:00
|
|
|
@to_utf = encd != 'UTF-8'
|
2008-10-01 09:46:53 -04:00
|
|
|
end
|
2003-06-09 21:31:01 -04:00
|
|
|
|
2008-10-01 09:46:53 -04:00
|
|
|
def <<( content )
|
|
|
|
@output << (@to_utf ? self.encode(content) : content)
|
|
|
|
end
|
2003-12-08 21:41:33 -05:00
|
|
|
|
|
|
|
def to_s
|
|
|
|
"Output[#{encoding}]"
|
|
|
|
end
|
2008-10-01 09:46:53 -04:00
|
|
|
end
|
2003-06-09 21:31:01 -04:00
|
|
|
end
|