diff --git a/ChangeLog b/ChangeLog index 595c359615..ffc27525ba 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Oct 28 21:18:37 2012 Kouhei Sutou + + * test/rexml/test_document.rb: Add tests for parsing XML encoded + by UTF-16 with BOM. + Sun Oct 28 19:12:11 2012 Tadayoshi Funaba * ext/date/date_parse.c (iso8601_{ext,bas}_time): should not match diff --git a/test/rexml/test_document.rb b/test/rexml/test_document.rb index 72d0ff696f..02e4a69754 100644 --- a/test/rexml/test_document.rb +++ b/test/rexml/test_document.rb @@ -223,4 +223,26 @@ EOX end end end + + class BomTest < self + def test_utf_16le + xml = <<-EOX.encode("UTF-16LE").force_encoding("ASCII-8BIT") + +Hello world! +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") + +Hello world! +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