note 56478 added to function.mb-encode-mimeheader

From: Date: Sun, 04 Sep 2005 04:31:00 +0000
Subject: note 56478 added to function.mb-encode-mimeheader
Groups: php.notes 
Request: Send a blank email to php-notes+get-94710@lists.php.net to get a copy of this message
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; } ?> ---- Manual Page -- http://www.php.net/manual/en/function.mb-encode-mimeheader.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+56478 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56478&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56478&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56478&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56478&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56478&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56478&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+56478&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#94710) next »