- mb_convert_encoding: documentation ( source)
<?php
$html = <<<EOD
<html>
<p>
<a href="http://google.com/?q=あいうえお" title="<'あいうえお'>">"&"<br>
</html>
EOD;
$html = mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8');
$dom = new DOMDocument();
@$dom->loadHTML($html);
$html = $dom->saveHTML();
echo $html;
exit;