Skip to content

Commit

Permalink
Use mb_convert_encoding if it is available
Browse files Browse the repository at this point in the history
  • Loading branch information
Imangazaliev committed Jun 11, 2017
1 parent 44d41de commit 9e4645d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/DiDom/Encoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ class Encoder
*/
public static function convertToHtmlEntities($string, $encoding)
{
if (function_exists('mb_convert_encoding')) {
return mb_convert_encoding($string, 'HTML-ENTITIES', $encoding);
}

if ('UTF-8' !== $encoding) {
$string = iconv($encoding, 'UTF-8//IGNORE', $string);
}
Expand Down

0 comments on commit 9e4645d

Please sign in to comment.