more precise codepage detection
This commit is contained in:
parent
32c4614a32
commit
0d9d0a4b70
@ -229,9 +229,11 @@ class Linkinfo extends \Zotlabs\Web\Controller {
|
||||
$header = $result['header'];
|
||||
$body = $result['body'];
|
||||
|
||||
$cp = (preg_match('/meta.+content=["|\']text\/html;\s+charset=([^"|\']+)/i', $body, $o) ? $o[1] : 'AUTO');
|
||||
if(strtoupper($cp) == 'ISO-8859-5')
|
||||
$cp = 'AUTO';
|
||||
// Check codepage in page or in HTTP headers if not exist
|
||||
$cp = (preg_match('/meta.+content=["|\']text\/html;\s+charset=([^"|\']+)/i', $body, $o) ? $o[1] : '');
|
||||
if(empty($cp) || strtoupper($cp) == 'ISO-8859-5')
|
||||
$cp = (preg_match('/Content-Type: text\/html;\s+charset=(.+)/im', $header, $o) ? $o[1] : 'AUTO');
|
||||
|
||||
$body = mb_convert_encoding($body, 'UTF-8', $cp);
|
||||
$body = mb_convert_encoding($body, 'HTML-ENTITIES', "UTF-8");
|
||||
|
||||
|
Reference in New Issue
Block a user