/ home / oamrtfttrtgf / public_html / vendor / dompdf / dompdf / src / Dompdf.php
/**
* Loads an HTML string
* Parse errors are stored in the global array _dompdf_warnings.
* @todo use the $encoding variable
*
* @param string $str HTML text to load
* @param string $encoding Not used yet
*/
public function loadHtml($str, $encoding = 'UTF-8')
{
$this->saveLocale();
// FIXME: Determine character encoding, switch to UTF8, update meta tag. Need better http/file stream encoding detection, currently relies on text or meta tag.
$known_encodings = mb_list_encodings();
mb_detect_order('auto');
if (($file_encoding = mb_detect_encoding($str, null, true)) === false) {
$file_encoding = "auto";
}
if (in_array(strtoupper($file_encoding), array('UTF-8','UTF8')) === false) {
$str = mb_convert_encoding($str, 'UTF-8', $file_encoding);
}
$metatags = array(
'@<meta\s+http-equiv="Content-Type"\s+content="(?:[\w/]+)(?:;\s*?charset=([^\s"]+))?@i',
'@<meta\s+content="(?:[\w/]+)(?:;\s*?charset=([^\s"]+))"?\s+http-equiv="Content-Type"@i',
'@<meta [^>]*charset\s*=\s*["\']?\s*([^"\' ]+)@i',
);
foreach ($metatags as $metatag) {
if (preg_match($metatag, $str, $matches)) {
if (isset($matches[1]) && in_array($matches[1], $known_encodings)) {
$document_encoding = $matches[1];
break;
}
}