note 56478 deleted from function.mb-encode-mimeheader by nlopess
| From: | nlopess@php.net | Date: | Sun, 04 Sep 2005 08:36:37 +0000 |
| Subject: | note 56478 deleted from function.mb-encode-mimeheader by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-94717@lists.php.net to get a copy of this message | ||
Note Submitter:
----
I spoke too soon with the post below. Although changing the internal encoding does appear to fix
the splitting problem, another garbling problem has cropped up for some input cases.
It appears, as masataka points out below, that the internal encoding needs to be set to UTF-8 for
mb_encode_mimeheader(...) to work smoothly.
Manually splitting and setting the internal encoding to UTF-8 seems to work so far. (For UTF-8 or
ISO-2022-JP output.)
<?php
function mb_encode_mimehead_wrap($str, $charset, ...)
{
$internal_encoding = mb_internal_encoding();
mb_internal_encoding('UTF-8');
$encoded = '';
while ($str !== '') {
$segment = mb_strcut($str, 0, 29, $charset);
if ($encoded !== '')
$encoded .= "\r\n\t";
$encoded .= mb_encode_mimeheader($segment, $charset, ...);
$str = mb_strcut($str, 29, 1024, $charset);
}
mb_internal_encoding($internal_encoding);
return $encoded;
}
?>