diff --git a/Tests/LibWeb/Layout/expected/utf-16-be-xhtml-file-should-decode-correctly.txt b/Tests/LibWeb/Layout/expected/utf-16-be-xhtml-file-should-decode-correctly.txt new file mode 100644 index 0000000000..fbcb69e25f --- /dev/null +++ b/Tests/LibWeb/Layout/expected/utf-16-be-xhtml-file-should-decode-correctly.txt @@ -0,0 +1,20 @@ +Viewport <#document> at (0,0) content-size 800x600 children: not-inline + BlockContainer at (0,0) content-size 800x41.46875 [BFC] children: not-inline + BlockContainer
at (8,16) content-size 784x17.46875 children: not-inline + BlockContainer <(anonymous)> at (8,16) content-size 784x0 children: inline + TextNode <#text> + BlockContainerat (8,16) content-size 784x17.46875 children: inline + line 0 width: 29.21875, height: 17.46875, bottom: 17.46875, baseline: 13.53125 + frag 0 from TextNode start: 1, length: 15, rect: [8,16 29.21875x17.46875] + "好啦朋友們" + TextNode <#text> + BlockContainer <(anonymous)> at (8,49.46875) content-size 784x0 children: inline + TextNode <#text> + +ViewportPaintable (Viewport<#document>) [0,0 800x600] + PaintableWithLines (BlockContainer) [0,0 800x41.46875] overflow: [0,0 800x49.46875] + PaintableWithLines (BlockContainer
) [8,16 784x17.46875] overflow: [8,16 784x33.46875] + PaintableWithLines (BlockContainer(anonymous)) [8,16 784x0] + PaintableWithLines (BlockContainer) [8,16 784x17.46875]
+ TextPaintable (TextNode<#text>)
+ PaintableWithLines (BlockContainer(anonymous)) [8,49.46875 784x0]
diff --git a/Tests/LibWeb/Layout/input/utf-16-be-xhtml-file-should-decode-correctly.html b/Tests/LibWeb/Layout/input/utf-16-be-xhtml-file-should-decode-correctly.html
new file mode 100644
index 0000000000..25d0f7fa1a
Binary files /dev/null and b/Tests/LibWeb/Layout/input/utf-16-be-xhtml-file-should-decode-correctly.html differ
diff --git a/Userland/Libraries/LibWeb/HTML/Parser/HTMLEncodingDetection.cpp b/Userland/Libraries/LibWeb/HTML/Parser/HTMLEncodingDetection.cpp
index 9e8c8d9d68..2be4e255b1 100644
--- a/Userland/Libraries/LibWeb/HTML/Parser/HTMLEncodingDetection.cpp
+++ b/Userland/Libraries/LibWeb/HTML/Parser/HTMLEncodingDetection.cpp
@@ -251,10 +251,12 @@ Optional