Added alternative to mb_convert_encoding in Emogrifier, closes #7378

This commit is contained in:
Claudio Sanches 2015-02-12 09:40:41 -02:00
parent a17bd25c96
commit 455b27e125
1 changed files with 10 additions and 2 deletions

View File

@ -352,7 +352,11 @@ class Emogrifier {
$this->copyCssWithMediaToStyleNode($cssParts, $xmlDocument);
if ($this->preserveEncoding) {
return mb_convert_encoding($xmlDocument->saveHTML(), self::ENCODING, 'HTML-ENTITIES');
if ( function_exists( 'mb_convert_encoding' ) ) {
return mb_convert_encoding( $xmlDocument->saveHTML(), self::ENCODING, 'HTML-ENTITIES' );
} else {
return htmlspecialchars_decode( utf8_encode( html_entity_decode( $xmlDocument->saveHTML(), ENT_COMPAT, self::ENCODING ) ) );
}
} else {
return $xmlDocument->saveHTML();
}
@ -536,7 +540,11 @@ class Emogrifier {
$bodyWithoutUnprocessableTags = $this->html;
}
return mb_convert_encoding($bodyWithoutUnprocessableTags, 'HTML-ENTITIES', self::ENCODING);
if ( function_exists( 'mb_convert_encoding' ) ) {
return mb_convert_encoding( $bodyWithoutUnprocessableTags, 'HTML-ENTITIES', self::ENCODING );
} else {
return htmlspecialchars_decode( utf8_decode( htmlentities( $bodyWithoutUnprocessableTags, ENT_COMPAT, self::ENCODING, false ) ) );
}
}
/**