I have an application for reading email from a webmail and saving the data in a database. I am using the PHP's imap library to do most of the work.
The problem is that most emails have more than one charset (mostly ISO-8859-1 and UTF-8), so I have to read the charset from email and I decode it to ISO-8859-1 using the iconv function.
It works fine for most charsets, but when I read the Windows-1252 charset and try to decode it the iconv function isn't returning anything.
If I try to change the iconv function to the mb_convert_string, it doesn't convert all of the characters correctly.
this is my code:
if( $part->parameters[$i]->attribute == 'charset' )
$charset = $part->parameters[$i]->value;
if (strtolower($charset) != 'iso-8859-1')
$this->emailMessageTxt = iconv($charset, 'iso-8859-1', $this->emailMessageTxt);
Is there an error in there?