1--TEST--
2Dom\HTMLDocument UTF-8 BOM encoding test
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7
8$dom = Dom\HTMLDocument::createFromFile(__DIR__ . "/utf8_bom.html");
9var_dump($dom->charset);
10$dom->documentElement->firstChild->nextElementSibling->textContent = "é";
11$output = $dom->saveHtml();
12echo $output, "\n";
13$dom->saveHtmlFile(__DIR__ . "/utf8_bom_output.tmp");
14var_dump(file_get_contents(__DIR__ . "/utf8_bom_output.tmp") === $output);
15
16echo "--- After changing encoding to UTF-8 ---\n";
17$dom->charset = "UTF-8";
18echo $dom->saveHtml(), "\n";
19
20?>
21--CLEAN--
22<?php
23@unlink(__DIR__ . "/utf8_bom_output.tmp");
24?>
25--EXPECT--
26string(5) "UTF-8"
27<!DOCTYPE html><html><head>
28<!-- intentional lies and deceit -->
29<meta charset="utf-16">
30</head>
31<body>é</body></html>
32bool(true)
33--- After changing encoding to UTF-8 ---
34<!DOCTYPE html><html><head>
35<!-- intentional lies and deceit -->
36<meta charset="utf-16">
37</head>
38<body>é</body></html>
39