This is my code:
$oDom = new DOMDocument();
$oDom->loadHTML(\"èàéìòù\");
echo $oDom->saveHTML();
This is the output:
Try to set the encoding type after you have loaded the HTML.
$dom = new DOMDocument();
$dom->loadHTML($data);
$dom->encoding = 'utf-8';
echo $dom->saveHTML();
Other way
What worked for me was:
$doc->loadHTML(mb_convert_encoding($content, 'HTML-ENTITIES', 'UTF-8'));
credit: https://davidwalsh.name/domdocument-utf8-problem