mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* test/rexml/test_document.rb: Add tests for parsing XML encoded
by UTF-16 with BOM. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37360 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f774c96beb
commit
100b3be9ae
2 changed files with 27 additions and 0 deletions
|
@ -1,3 +1,8 @@
|
|||
Sun Oct 28 21:18:37 2012 Kouhei Sutou <kou@cozmixng.org>
|
||||
|
||||
* 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 <tadf@dotrb.org>
|
||||
|
||||
* ext/date/date_parse.c (iso8601_{ext,bas}_time): should not match
|
||||
|
|
|
@ -223,4 +223,26 @@ EOX
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
class BomTest < self
|
||||
def test_utf_16le
|
||||
xml = <<-EOX.encode("UTF-16LE").force_encoding("ASCII-8BIT")
|
||||
<?xml version="1.0" encoding="UTF-16"?>
|
||||
<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" encoding="UTF-16"?>
|
||||
<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
|
||||
|
|
Loading…
Reference in a new issue