diff options
author | kou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-10-28 12:42:37 +0000 |
---|---|---|
committer | kou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-10-28 12:42:37 +0000 |
commit | a7322e3678d8c5be0e528a346fa42444325e5349 (patch) | |
tree | 8634ad836a7aac3bc0e812baa0f793609f178340 /test/rexml | |
parent | a750424cab13cab79de7d7922f32f31be6f415f3 (diff) | |
download | ruby-a7322e3678d8c5be0e528a346fa42444325e5349.tar.gz |
* lib/rexml/parsers/baseparser.rb: Fix a bug that UTF-8 is used
for UTF-16XX encoded XML that doesn't have encoding="UTF-16" in
XML declration.
* test/rexml/test_document.rb: Add tests for the above change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37363 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/rexml')
-rw-r--r-- | test/rexml/test_document.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/rexml/test_document.rb b/test/rexml/test_document.rb index 028fa988a6..4c5d7d1dd8 100644 --- a/test/rexml/test_document.rb +++ b/test/rexml/test_document.rb @@ -246,5 +246,27 @@ EOX assert_equal("UTF-16", document.encoding) end end + + class NoEncodingTest < self + def test_utf_16le + xml = <<-EOX.encode("UTF-16LE").force_encoding("ASCII-8BIT") +<?xml version="1.0"?> +<message>Hello world!</message> +EOX + bom = "\ufeff".encode("UTF-16LE").force_encoding("ASCII-8BIT") + document = REXML::Document.new(bom + xml) + assert_equal("UTF-16", document.encoding) + end + + def test_utf_16be + xml = <<-EOX.encode("UTF-16BE").force_encoding("ASCII-8BIT") +<?xml version="1.0"?> +<message>Hello world!</message> +EOX + bom = "\ufeff".encode("UTF-16BE").force_encoding("ASCII-8BIT") + document = REXML::Document.new(bom + xml) + assert_equal("UTF-16", document.encoding) + end + end end end |