mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-12-22 08:21:52 +00:00
Replace 8.1-deprecated utf8_ funcs with mbstring (#326)
This commit is contained in:
parent
3fc193c755
commit
dff4746e13
@ -398,8 +398,8 @@ class HTMLPurifier_Encoder
|
|||||||
// characters to their true byte-wise ASCII/UTF-8 equivalents.
|
// characters to their true byte-wise ASCII/UTF-8 equivalents.
|
||||||
$str = strtr($str, self::testEncodingSupportsASCII($encoding));
|
$str = strtr($str, self::testEncodingSupportsASCII($encoding));
|
||||||
return $str;
|
return $str;
|
||||||
} elseif ($encoding === 'iso-8859-1') {
|
} elseif ($encoding === 'iso-8859-1' && function_exists('mb_convert_encoding')) {
|
||||||
$str = utf8_encode($str);
|
$str = mb_convert_encoding($str, 'UTF-8', 'ISO-8859-1');
|
||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
$bug = HTMLPurifier_Encoder::testIconvTruncateBug();
|
$bug = HTMLPurifier_Encoder::testIconvTruncateBug();
|
||||||
@ -450,8 +450,8 @@ class HTMLPurifier_Encoder
|
|||||||
// Normal stuff
|
// Normal stuff
|
||||||
$str = self::iconv('utf-8', $encoding . '//IGNORE', $str);
|
$str = self::iconv('utf-8', $encoding . '//IGNORE', $str);
|
||||||
return $str;
|
return $str;
|
||||||
} elseif ($encoding === 'iso-8859-1') {
|
} elseif ($encoding === 'iso-8859-1' && function_exists('mb_convert_encoding')) {
|
||||||
$str = utf8_decode($str);
|
$str = mb_convert_encoding($str, 'ISO-8859-1', 'UTF-8');
|
||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
trigger_error('Encoding not supported', E_USER_ERROR);
|
trigger_error('Encoding not supported', E_USER_ERROR);
|
||||||
|
Loading…
Reference in New Issue
Block a user