note 50773 added to function.iconv-mime-decode
| From: | dido dot sevilla at gmail dot com | Date: | Wed, 09 Mar 2005 16:00:14 +0000 |
| Subject: | note 50773 added to function.iconv-mime-decode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-86157@lists.php.net to get a copy of this message | ||
In PHP versions that have imap_mime_decode built in, it's possible to emulate the operation of
this function:
<?php
function iconv_mime_decode($str, $mode=0, $charset="UTF-8")
{
$data = imap_mime_header_decode($str);
if (count($data) > 0) {
// because iconv doesn't like the 'default' for charset
$charset = ($data[0]->charset == 'default') ? 'ASCII' :
$data[0]->charset;
return(iconv($charset, $charset, $data[0]->text));
}
return("");
}
?>
I've only tried to use this code snippet to decode ISO-2022-JP messages to UTF-8, but I see no
reason why it shouldn't work in other cases.
----
Manual Page -- http://www.php.net/manual/en/function.iconv-mime-decode.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+50773
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50773&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50773&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50773&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50773&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50773&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+50773&report=yes
Search -- http://master.php.net/manage/user-notes.php