note 112821 added to function.iconv-mime-decode
| From: | DirkBecker | Date: | Fri, 26 Jul 2013 09:46:59 +0000 |
| Subject: | note 112821 added to function.iconv-mime-decode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-195780@lists.php.net to get a copy of this message | ||
While creating a new webmailer, I had to coop with a lot of mails and only half of them were correct
encoded!
Often the text is tagged as ISO but in real its UTF :/
After trying a lot of solutions and combination a found a way which seems to work for all our mails.
Maybe its usefull to someone else too.
<?php
function mime_encode($data)
{
$resp = imap_utf8(trim($data));
if(preg_match("/=\?/", $resp))
$resp = iconv_mime_decode($data, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, "ISO-8859-15");
if(json_encode($resp) == 'null')
$resp = utf8_encode($resp);
return $resp;
}
?>
----
Server IP: 69.147.83.199
Probable Submitter: 212.91.237.59
----
Manual Page -- http://php.net/manual/en/function.iconv-mime-decode.php
Edit -- https://master.php.net/note/edit/112821
Del: integrated -- https://master.php.net/note/delete/112821/integrated
Del: useless -- https://master.php.net/note/delete/112821/useless
Del: bad code -- https://master.php.net/note/delete/112821/bad+code
Del: spam -- https://master.php.net/note/delete/112821/spam
Del: non-english -- https://master.php.net/note/delete/112821/non-english
Del: in docs -- https://master.php.net/note/delete/112821/in+docs
Del: other reasons-- https://master.php.net/note/delete/112821
Reject -- https://master.php.net/note/reject/112821
Search -- https://master.php.net/manage/user-notes.php