[go: nahoru, domu]

Voting

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

The Note You're Voting On

legolas558 at users dot sausafe dot net
17 years ago
As soletan at toxa dot de reported, that function is very bad and does not provide valid enquoted printable strings. While using it I saw spam agents marking the emails as QP_EXCESS and sometimes the email client did not recognize the header at all; I really lost time :(. This is the new version (we use it in the Drake CMS core) that works seamlessly:

<?php

//L: note $encoding that is uppercase
//L: also your PHP installation must have ctype_alpha, otherwise write it yourself
function quoted_printable_encode($string, $encoding='UTF-8') {
// use this function with headers, not with the email body as it misses word wrapping
$len = strlen($string);
$result = '';
$enc = false;
for(
$i=0;$i<$len;++$i) {
$c = $string[$i];
if (
ctype_alpha($c))
$result.=$c;
else if (
$c==' ') {
$result.='_';
$enc = true;
} else {
$result.=sprintf("=%02X", ord($c));
$enc = true;
}
}
//L: so spam agents won't mark your email with QP_EXCESS
if (!$enc) return $string;
return
'=?'.$encoding.'?q?'.$result.'?=';
}

I hope it helps ;)

?>

<< Back to user notes page

To Top