1--TEST-- 2Dom\HTMLDocument Windows-1251 encoding test 3--EXTENSIONS-- 4dom 5--FILE-- 6<?php 7 8$dom = Dom\HTMLDocument::createFromFile(__DIR__ . "/windows1251.html"); 9var_dump($dom->charset); 10$dom->documentElement->firstChild->nextElementSibling->textContent .= "é"; // Note: won't show up in Windows 1251 because it doesn't exist there 11$output = $dom->saveHtml(); 12echo $output, "\n"; 13$dom->saveHtmlFile(__DIR__ . "/windows1251_output.tmp"); 14var_dump(file_get_contents(__DIR__ . "/windows1251_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__ . "/windows1251_output.tmp"); 24?> 25--EXPECT-- 26string(12) "windows-1251" 27<!DOCTYPE html><html><head> 28<meta charset="windows-1251"> 29</head> 30<body> 31 A � B � C 32?</body></html> 33bool(true) 34--- After changing encoding to UTF-8 --- 35<!DOCTYPE html><html><head> 36<meta charset="windows-1251"> 37</head> 38<body> 39 A ф B б C 40é</body></html> 41