I modified the below version of legolas558 at users dot sausafe dot net and added a wrapping option.
<?php
/**
* Codeer een String naar zogenaamde 'quoted printable'. Dit type van coderen wordt
* gebruikt om de content van 8 bit e-mail berichten als 7 bits te versturen.
*
* @access public
* @param string $str De String die we coderen
* @param bool $wrap Voeg linebreaks toe na 74 tekens?
* @return string
*/
function quoted_printable_encode($str, $wrap=true)
{
$return = '';
$iL = strlen($str);
for($i=0; $i<$iL; $i++)
{
$char = $str[$i];
if(ctype_print($char) && !ctype_punct($char)) $return .= $char;
else $return .= sprintf('=%02X', ord($char));
}
return ($wrap === true)
? wordwrap($return, 74, " =\n")
: $return;
}
?>