emogrifier
emogrifier copied to clipboard
German umlauts not emogrified correctly
I've a found a problem in the last version. Actually I'm passing a text for an email and a CSS file to it so that it get's inlined. The problem is that the returned text is really strange:
$emogrifier_class = 'Pelago\\Emogrifier';
if ( class_exists( $emogrifier_class ) ) {
try {
$emogrifier = new $emogrifier_class( $content, $css );
$content = $emogrifier->emogrify();
} catch ( Exception $e ) {
$logger->error( $e->getMessage(), array( 'source' => 'emogrifier' ) );
}
} else {
$content = '<style type="text/css">' . $css . '</style>' . $content;
}
So when I pass for example this text:
Solltest du diese Änderung nicht vorgenommen haben, so erstelle bitte umgehend ein Ticket oder kontaktiere uns über das Kontaktformular.
It turns to this after emogrified it:
Solltest du diese Ãnderung nicht vorgenommen haben, so erstelle bitte umgehend ein Ticket oder kontaktiere uns über das Kontaktformular.
As you can see, the german umlauts are not printed correctly. I think this is a bug in the library. So is there any way to fix this?
Have you found the bug? Because currently I'm unable do deploy my project. Maybe I can dirty fix it until you've found time to fix this?
Hi @Johnny99211, thanks for reporting this issue.
Please let us know what encoding are you using for the input (the $content
variable)? Also, how do you verify the output of emogrifier? One way to make sure accented characters are not broken is to ensure the consistency of encoding (input, internal and output encoding).
I've logged out before and after emogrifier. The first log is before and the last after. I'm using UTF-8 all over my documents and also in my email header.
I tried to reproduce your issue here: https://phpsandbox.io/n/wild-credit-bz6n. When the output encoding is set to UTF-8, the output of accented characters is correct. However, when I set the output encoding to ISO8859-1, the result if very similar to what you have.