1--TEST-- 2Dom\HTMLDocument Shift JIS encoding test 3--EXTENSIONS-- 4dom 5--FILE-- 6<?php 7 8$dom = Dom\HTMLDocument::createFromFile(__DIR__ . "/shift_jis.html"); 9var_dump($dom->charset); 10$dom->documentElement->firstChild->nextElementSibling->textContent .= "é"; 11$output = $dom->saveHtml(); 12echo $output, "\n"; 13$dom->saveHtmlFile(__DIR__ . "/shift_jis.tmp"); 14var_dump(file_get_contents(__DIR__ . "/shift_jis.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__ . "/shift_jis.tmp"); 24?> 25--EXPECT-- 26string(9) "Shift_JIS" 27<!DOCTYPE html><html><head> 28<meta charset="shift_jis"> 29</head> 30<body> 31 �₠ 32?</body></html> 33bool(true) 34--- After changing encoding to UTF-8 --- 35<!DOCTYPE html><html><head> 36<meta charset="shift_jis"> 37</head> 38<body> 39 やあ 40é</body></html> 41