Created
April 6, 2017 20:58
-
-
Save mllvzeth/8108b6507eb09a2e849bb07c3bf84131 to your computer and use it in GitHub Desktop.
load HTML as UTF-8 using simple hack:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @mdmitry at gmail dot com | |
* | |
*/ | |
$doc = new DOMDocument(); | |
$doc->loadHTML('<?xml encoding="UTF-8">' . $html); | |
// dirty fix | |
foreach ($doc->childNodes as $item) | |
if ($item->nodeType == XML_PI_NODE) | |
$doc->removeChild($item); // remove hack | |
$doc->encoding = 'UTF-8'; // insert proper |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment