This is my code:
$oDom = new DOMDocument();
$oDom->loadHTML(\"èàéìòù\");
echo $oDom->saveHTML();
This is the output:
Solution:
$oDom = new DOMDocument();
$oDom->encoding = 'utf-8';
$oDom->loadHTML( utf8_decode( $sString ) ); // important!
$sHtml = '';
$sHtml .= $oDom->saveHTML( $oDom->documentElement ); // important!
The saveHTML() method works differently specifying a node.
You can use the main node ($oDom->documentElement) adding the desired !DOCTYPE manually.
Another important thing is utf8_decode().
All the attributes and the other methods of the DOMDocument class, in my case, don't produce the desired result.