Skip to content

Commit

Permalink
php5 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Jul 20, 2019
1 parent 4f16acf commit 960bbd5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
class Utils
{
const ENCODINGS = [
private static $encodings = [
'ASCII' => 'ascii',
'UTF-8' => 'utf-8',
'SJIS' => 'shift_jis',
Expand Down Expand Up @@ -296,13 +296,13 @@ public static function parse($html)
*/
private static function normalize($string)
{
$detected = mb_detect_encoding($string, implode(',', array_keys(self::ENCODINGS)), true);
$detected = mb_detect_encoding($string, implode(',', array_keys(self::$encodings)), true);

if ($detected && isset(self::ENCODINGS[$detected])) {
if ($detected && isset(self::$encodings[$detected])) {
$string = mb_convert_encoding($string, 'HTML-ENTITIES', $detected);
$string = preg_replace(
'/<head[^>]*>/',
'<head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset='.self::ENCODINGS[$detected].'">',
'<head><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset='.self::$encodings[$detected].'">',
$string
);
}
Expand Down

0 comments on commit 960bbd5

Please sign in to comment.