[dev] Get Mail Part as UTF-8

Michael M Slusarz slusarz at horde.org
Tue Jan 14 08:41:48 UTC 2014


Catching up on holiday mail...

Quoting Claus Ruete <claus.ruete at student.uni-tuebingen.de>:

> I've read the following example:  
> http://wiki.horde.org/Doc/Dev/Imap_Client/Examples and it works for  
> me, but for about half of the mails I don't get proper utf-8  
> returned, so PHP's json_encode doesn't work :(
>
> So I was hoping somebody could help me with that? I just need  
> everything in utf-8 and nothing else...

This may have already been answered, but the charset of the body data  
will be in the getCharset() method of the Mime Part object (if it is a  
text/* part).

You can use something like:

  $data = Horde_String::convertCharset($part->getContents(),  
$part->getCharset(), 'UTF-8');

to do the conversion.

michael

___________________________________
Michael Slusarz [slusarz at horde.org]



More information about the dev mailing list