PHP 8.5.0 Alpha 1 available for testing

Voting

: max(two, five)?
(Example: nine)

The Note You're Voting On

cedric at gn dot apc dot org
13 years ago
iconv_mime_encode() isn't directly suitable for encoding headers which include "specials" as described in RFC 1522 s4 & s5, for example
<?php
$mimeprefs
= array ("scheme" => "Q",
"input-charset" => "utf-8",
"output-charset" => "utf-8",
"line-break-chars" => "\n");
$enc = iconv_mime_encode('From', '"Réal Namé" <[email protected]>', $prefs);
?>
will wrongly attempt to encode the angle brackets. To use the function in place of mb_encode_mimeheader(), instead you need to encode the words separately, removing the superfluous field name:

<?php
$encoded
= "From: \"". preg_replace('/^:\s+/', '', iconv_mime_encode("", $real, $mimeprefs))."\" <$email>";
?>

Also, values of "line-length" greater than 76 would be illegal under RFC 1522 and resulting encoded words may not be recognised. (Not tested, but 72 would be safer.)

<< Back to user notes page

To Top