1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/rexml/document.rb (REXML::Document#write): Document encoding

option. Now different encoding between XML file's encoding and
  XML declaration's encodiong is support.
  [Feature #4872] (work in progress)
* lib/rexml/xmldecl.rb (REXML::XMLDecl#write): Always use XMLDecl's
  encoding.
* test/rexml/test_document.rb: Update tests for the above change.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37440 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
kou 2012-11-03 03:53:09 +00:00
parent 69eedf6a18
commit 3f817764e2
4 changed files with 35 additions and 15 deletions

View file

@ -165,11 +165,16 @@ EOX
indent = -1
transitive = false
ie_hack = false
encoding = "Shift_JIS"
encoding = "Windows-31J"
xml_declaration_encoding = "Shift_JIS"
@document.xml_decl.encoding = xml_declaration_encoding
japanese_text = "こんにちは"
@document.root.text = japanese_text
@document.write(output, indent, transitive, ie_hack, encoding)
assert_equal(<<-EOX, output)
<?xml version='1.0' encoding='SHIFT_JIS'?>
<message>Hello world!</message>
assert_equal(<<-EOX.encode(encoding), output)
<?xml version='1.0' encoding='#{xml_declaration_encoding}'?>
<message>#{japanese_text}</message>
EOX
end
end
@ -215,10 +220,15 @@ EOX
def test_encoding
output = ""
@document.write(:output => output, :encoding => "Shift_JIS")
assert_equal(<<-EOX, output)
<?xml version='1.0' encoding='SHIFT_JIS'?>
<message>Hello world!</message>
encoding = "Windows-31J"
xml_declaration_encoding = "Shift_JIS"
@document.xml_decl.encoding = xml_declaration_encoding
japanese_text = "こんにちは"
@document.root.text = japanese_text
@document.write(:output => output, :encoding => encoding)
assert_equal(<<-EOX.encode(encoding), output)
<?xml version='1.0' encoding='#{xml_declaration_encoding}'?>
<message>#{japanese_text}</message>
EOX
end
end