aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rexml/document.rb
diff options
context:
space:
mode:
authorkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-28 06:43:38 +0000
committerkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-10-28 06:43:38 +0000
commitaf83fcfe4de5d0497e78789efdfb7e7daf251805 (patch)
tree96c6190cd863b7597cdb57aae78fd15f878a5fe5 /lib/rexml/document.rb
parent292c659b5ce2b8e01d59f87713450e6c66ca14a0 (diff)
downloadruby-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/rexml/document.rb')
-rw-r--r--lib/rexml/document.rb12
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