From 93647e81a6d46c2e3f52618521a5b78b61e686d5 Mon Sep 17 00:00:00 2001 From: kou Date: Thu, 23 Oct 2014 08:23:10 +0000 Subject: * lib/rexml/source.rb (REXML::IOSource#encoding_updated): Fix a bug that can't parse XML correctly when Encoding.default_internal is different with XML encoding. REXML::Source converts XML encoding on read. So IO should not convert XML encoding. Based on patch by NAKAMURA Usaku. [ruby-dev:48686] [Bug #10418] * test/rexml/test_encoding.rb (REXMLTests::EncodingTester#test_parse_utf16_with_utf8_default_internal): Add the for the above case. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48109 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/rexml/test_encoding.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test') diff --git a/test/rexml/test_encoding.rb b/test/rexml/test_encoding.rb index 9a41957faf..058fb974b2 100644 --- a/test/rexml/test_encoding.rb +++ b/test/rexml/test_encoding.rb @@ -94,5 +94,14 @@ module REXMLTests assert_equal("UTF-16", utf16.encoding) assert( utf16[0].kind_of?(REXML::XMLDecl)) end + + def test_parse_utf16_with_utf8_default_internal + EnvUtil.with_default_internal("UTF-8") do + utf16 = File.open(fixture_path("utf16.xml")) do |f| + REXML::Document.new(f) + end + assert_equal("UTF-16", utf16.encoding) + end + end end end -- cgit v1.2.3