note 99018 added to function.quoted-printable-encode

From: Date: Thu, 22 Jul 2010 13:22:32 +0000
Subject: note 99018 added to function.quoted-printable-encode
Groups: php.notes 
Request: Send a blank email to php-notes+get-171041@lists.php.net to get a copy of this message
I use that for PHP < 5.3 : function mime_qp_long_line($input,$line_max = 76) { $length=strlen($input); $output=''; $output.=$input[0]; $outlen=1; for ($i=1;$i<$length;$i++) { $outlen++; if ($input[$i]=='=') { if ((intval($outlen/$line_max)!=intval(($outlen+2)/$line_max))) { $output.="=\n"; $outlen+=3; } } $output.=$input[$i]; if ((($outlen+1)%$line_max)===0 && $input[$i]!='=') { $output.="=\n"; $outlen++; } } return $output; } function quoted_printable_encode($input, $line_max = 76) { $hex = array('0','1','2','3','4','5','6','7', '8','9','A','B','C','D','E','F'); $lines = preg_split("/(?:\r\n|\r|\n)/", $input); /* the linebreak also counts as characters in the mime_qp_long_line * rule of spam-assassin */ $escape = "="; $output = ""; $cur_conv_line = ""; $length = 0; $whitespace_pos = 0; $addtl_chars = 0; // iterate lines for ($j=0; $j<count($lines); $j++) { $line = $lines[$j]; $linlen = strlen($line); // iterate chars for ($i = 0; $i < $linlen; $i++) { $c = substr($line, $i, 1); $dec = ord($c); $length++; if ($dec == 32) { // space occurring at end of line, need to encode if (($i == ($linlen - 1))) { $c = "=20"; $length += 2; } $addtl_chars = 0; $whitespace_pos = $i; } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { $h2 = floor($dec/16); $h1 = floor($dec%16); $c = $escape . $hex["$h2"] . $hex["$h1"]; $length += 2; $addtl_chars += 2; } $cur_conv_line .= $c; } // end of for $length = 0; $whitespace_pos = 0; $output .= $cur_conv_line; $cur_conv_line = ""; if ($j<=count($lines)-1) { $output .= $linebreak; } } // end for return mime_qp_long_line(trim($output),$line_max); } // end quoted_printable_encode ---- Server IP: 69.147.83.197 Probable Submitter: 88.160.59.88 ---- Manual Page -- http://www.php.net/manual/en/function.quoted-printable-encode.php Edit -- https://master.php.net/note/edit/99018 Del: integrated -- https://master.php.net/note/delete/99018/integrated Del: useless -- https://master.php.net/note/delete/99018/useless Del: bad code -- https://master.php.net/note/delete/99018/bad+code Del: spam -- https://master.php.net/note/delete/99018/spam Del: non-english -- https://master.php.net/note/delete/99018/non-english Del: in docs -- https://master.php.net/note/delete/99018/in+docs Del: other reasons-- https://master.php.net/note/delete/99018 Reject -- https://master.php.net/note/reject/99018 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#171041) next »