New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Converting ISO-2022-JP incorrect #191
Comments
Hello, Thanks for your report, I think it's a bug but I don't know how to resolve it. It seams that the lib is not able to decode the numbers ①②③④⑤⑥⑦⑧⑨ |
I just saw this comment
|
I found a way to do it in Charset.php I replace the return iconv($this->getCharsetAlias($charset), 'UTF-8//TRANSLIT//IGNORE', $encodedString); by return mb_convert_encoding($encodedString, 'UTF-8', 'ISO-2022-JP-MS'); and the result is
This issue is related to this PR #137 I need to finish it to be able to fix this issue |
PR137 has been open for over a year. Is there any quick fix I can apply to the current code-base to make it work without breaking all other charsets? |
In src/Charset.php you can replace: public function decodeCharset($encodedString, $charset)
{
if (strtolower($charset) == 'utf-8' || strtolower($charset) == 'us-ascii') {
return $encodedString;
} else {
return iconv($this->getCharsetAlias($charset), 'UTF-8//TRANSLIT//IGNORE', $encodedString);
}
} by (but you need to have mb_convert_encoding in your php) public function decodeCharset($encodedString, $charset)
{
if (strtolower($charset) == 'utf-8' || strtolower($charset) == 'us-ascii') {
return $encodedString;
} elseif (strtolower($charset) == 'iso-2022-jp' ) {
return mb_convert_encoding($encodedString, 'UTF-8', 'ISO-2022-JP-MS');
} else {
return iconv($this->getCharsetAlias($charset), 'UTF-8//TRANSLIT//IGNORE', $encodedString);
}
} |
Thanks for that. Any reason why you're using mb_convert_encoding for this charset only and not for all? |
I'm using mb_convert_encoding because iconv doesn't work with charset ISO-2022-JP-MS. I think mb_convert_encoding is better than iconv but mb_convert_encoding are not compiled in php by default so for the time being we keep inconv. |
Fix in the release 3.0.0 |
I'm not getting the correct text results for an email.
The code is pretty straight-forward:
$rawEmail contains (edited for privacy):
$Parser->getMessageBody( 'text' ) returns:
But what I expect (and see in Thunderbird) is:
This is obviously very different.
Is it a bug? How can I fix this?
The text was updated successfully, but these errors were encountered: