note 106078 added to function.quoted-printable-encode
| From: | ericth at NOSPAM dot pennyworth dot com | Date: | Fri, 07 Oct 2011 20:46:14 +0000 |
| Subject: | note 106078 added to function.quoted-printable-encode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-183720@lists.php.net to get a copy of this message | ||
I have re-written the PHP 5.3.8 function for quoted_printable_encode into PHP for use with PHP <
5.3. Tested with PHP 5.2.11.
<?php
define('PHP_QPRINT_MAXL', 75);
function php_quot_print_encode($str)
{
$lp = 0;
$ret = '';
$hex = "0123456789ABCDEF";
$length = strlen($str);
$str_index = 0;
while ($length--) {
if ((($c = $str[$str_index++]) == "\015") && ($str[$str_index] ==
"\012") && $length > 0) {
$ret .= "\015";
$ret .= $str[$str_index++];
$length--;
$lp = 0;
} else {
if (ctype_cntrl($c)
|| (ord($c) == 0x7f)
|| (ord($c) & 0x80)
|| ($c == '=')
|| (($c == ' ') && ($str[$str_index] == "\015")))
{
if (($lp += 3) > PHP_QPRINT_MAXL)
{
$ret .= '=';
$ret .= "\015";
$ret .= "\012";
$lp = 3;
}
$ret .= '=';
$ret .= $hex[ord($c) >> 4];
$ret .= $hex[ord($c) & 0xf];
}
else
{
if ((++$lp) > PHP_QPRINT_MAXL)
{
$ret .= '=';
$ret .= "\015";
$ret .= "\012";
$lp = 1;
}
$ret .= $c;
}
}
}
return $ret;
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 72.5.239.5
----
Manual Page -- http://www.php.net/manual/en/function.quoted-printable-encode.php
Edit -- https://master.php.net/note/edit/106078
Del: integrated -- https://master.php.net/note/delete/106078/integrated
Del: useless -- https://master.php.net/note/delete/106078/useless
Del: bad code -- https://master.php.net/note/delete/106078/bad+code
Del: spam -- https://master.php.net/note/delete/106078/spam
Del: non-english -- https://master.php.net/note/delete/106078/non-english
Del: in docs -- https://master.php.net/note/delete/106078/in+docs
Del: other reasons-- https://master.php.net/note/delete/106078
Reject -- https://master.php.net/note/reject/106078
Search -- https://master.php.net/manage/user-notes.php