summaryrefslogtreecommitdiffstats
path: root/lib/rexml/output.rb
diff options
context:
space:
mode:
authorser <ser@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-06-10 01:31:01 +0000
committerser <ser@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-06-10 01:31:01 +0000
commit75b6d8aa32fbb9166aee732e05398e2984f2b92d (patch)
treed3e1f95a5acf262a9dd46e9663b7034bb285b406 /lib/rexml/output.rb
parent2480062df118c8b08fc48686c24084c1ce142f8e (diff)
downloadruby-75b6d8aa32fbb9166aee732e05398e2984f2b92d.tar.gz
ruby-75b6d8aa32fbb9166aee732e05398e2984f2b92d.tar.xz
ruby-75b6d8aa32fbb9166aee732e05398e2984f2b92d.zip
Initial revision
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@3925 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rexml/output.rb')
-rw-r--r--lib/rexml/output.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/rexml/output.rb b/lib/rexml/output.rb
new file mode 100644
index 000000000..7d4ab2e13
--- /dev/null
+++ b/lib/rexml/output.rb
@@ -0,0 +1,22 @@
+require 'rexml/encoding'
+
+module REXML
+ class Output
+ include Encoding
+ attr_reader :encoding
+ def initialize real_IO, encd="iso-8859-1"
+ @output = real_IO
+ self.encoding = encd
+
+ eval <<-EOL
+ alias :encode :to_#{encoding.tr('-', '_').downcase}
+ alias :decode :from_#{encoding.tr('-', '_').downcase}
+ EOL
+ @to_utf = encd == UTF_8 ? false : true
+ end
+
+ def <<( content )
+ @output << (@to_utf ? encode(content) : content)
+ end
+ end
+end