You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Tries to insert `meta[charset]` tag into the proper place in the passed HTML document.
1459
+
*
1460
+
* `DOMDocument::loadHTML` will parse HTML documents as ISO-8859-1 if there is no `meta[charset]` tag.
1461
+
* This means that UTF-8-encoded HTML fragments such as those coming from JSON-LD `articleBody` field would be parsed with incorrect encoding.
1462
+
* Unfortunately, we cannot just put the tag at the start of the HTML fragment, since that would cause parser to auto-insert a `html` element, losing the attributes of the original `html` tag.
1463
+
*
1464
+
* @param string $html UTF-8 encoded document
1465
+
*/
1466
+
privatestaticfunctionensureMetaCharset($html)
1467
+
{
1468
+
$charsetTag = '<meta charset="utf-8">';
1469
+
1470
+
// Only look at first 1024 bytes since, according to HTML5 specification,
1471
+
// that’s where <meta> elements declaring a character encoding must be located.
0 commit comments