note 58515 added to function.mb-encode-mimeheader
| From: | gullevek at gullevek dot org | Date: | Mon, 07 Nov 2005 01:29:18 +0000 |
| Subject: | note 58515 added to function.mb-encode-mimeheader | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-98179@lists.php.net to get a copy of this message | ||
My first post was around 2003, and still the mb_mime_header is broken. It is *NOT* usable with
longer subjects, and mostly unusable with anything else than japanese.
iwakura at junx dot org is also not working for me, it produces also some gargabe.
I updated my old function (the one I posted 2003) and I tested it with overlong subjects in UTF-8,
ISO-2022-JP (japanese), GB2312 (simplified chinese) and EUC-KR (korean) and I got readable results
in thunderbird, mail.app, outlook, etc.
<?php
function _mb_mime_encode($string, $encoding)
{
$pos = 0;
// after 36 single bytes characters if then comes MB, it is broken
// but I trimmed it down to 24, to stay 100% < 76 chars per line
$split = 24;
while ($pos < mb_strlen($string, $encoding))
{
$output = mb_strimwidth($string, $pos, $split, "", $encoding);
$pos += mb_strlen($output, $encoding);
$_string_encoded =
"=?".$encoding."?B?".base64_encode($output)."?=";
if ($_string)
$_string .= "\r\n";
$_string .= $_string_encoded;
}
$string = $_string;
return $string;
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.mb-encode-mimeheader.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+58515
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58515&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58515&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58515&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58515&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58515&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58515&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58515&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+58515&report=yes
Search -- http://master.php.net/manage/user-notes.php