Reputation: 1319
I use Chilkat component. I faced with a problem. I have an email mime string. There is a html body. In most cases it is Content-Transfer-Encoding: quoted-printable. I need to get html body and show it readable. I do it like this, php code:
$data = new CkByteData();
$this->ckEmail->GetMbHtmlBody($this->ckEmail->charset(), $data);
$body = $data->getBytes();
Seems in most cases it works. But sometime it shows unreadable chars. I checked that $this->ckEmail->charset()
returned 'utf-8', but when I tried 'iso-8859-1' it became work. I am confused here with these encodings. Do I need to detect the encoding of html body (or text body) so then show it correctly using GetMbHtmlBody ? How to make it well ? I want to show all characters correctly with any encoding.
Upvotes: 0
Views: 294
Reputation: 38618
If the mail client that generated the message did it properly, then the charset parameter on the text/html
Content-Type header will be correct and you'll be able to use that.
That is a big "if", however, since mail is notoriously broken in the real world and you often have to detect the charset in the HTML content of the text/html
MIME part and use that instead.
Upvotes: 1