diff options
author | kou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-10-28 06:43:38 +0000 |
---|---|---|
committer | kou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-10-28 06:43:38 +0000 |
commit | af83fcfe4de5d0497e78789efdfb7e7daf251805 (patch) | |
tree | 96c6190cd863b7597cdb57aae78fd15f878a5fe5 /lib | |
parent | 292c659b5ce2b8e01d59f87713450e6c66ca14a0 (diff) | |
download | ruby-af83fcfe4de5d0497e78789efdfb7e7daf251805.tar.gz |
* lib/rexml/document.rb (REXML::Document#write): Add :encoding option
to support custom XML encoding.
[Feature #4872] (work in progress)
* test/rexml/test_document.rb: Add tests for the above change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rexml/document.rb | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/rexml/document.rb b/lib/rexml/document.rb index 6ac527fa83..5508a60be4 100644 --- a/lib/rexml/document.rb +++ b/lib/rexml/document.rb @@ -207,17 +207,19 @@ module REXML indent = options[:indent] transitive = options[:transitive] ie_hack = options[:ie_hack] + encoding = options[:encoding] else - output, indent, transitive, ie_hack, = *arguments + output, indent, transitive, ie_hack, encoding, = *arguments end - output ||= $stdout - indent ||= -1 + output ||= $stdout + indent ||= -1 transitive = false if transitive.nil? ie_hack = false if ie_hack.nil? + encoding ||= xml_decl.encoding - if xml_decl.encoding != 'UTF-8' && !output.kind_of?(Output) - output = Output.new( output, xml_decl.encoding ) + if encoding != 'UTF-8' && !output.kind_of?(Output) + output = Output.new( output, encoding ) end formatter = if indent > -1 if transitive |