PHP 8.4.24 Released!

Voting

: five minus one?
(Example: nine)

The Note You're Voting On

andre at luyer dot nl
17 years ago
A small update for Andrew's code below. This one leaves the original CRLF pairs intact (and allowing the preg_replace to work as intended):

<?php
if (!function_exists("quoted_printable_encode")) {
  /**
  * Process a string to fit the requirements of RFC2045 section 6.7. Note that
  * this works, but replaces more characters than the minimum set. For readability
  * the spaces and CRLF pairs aren't encoded though.
  */
  function quoted_printable_encode($string) {
    return preg_replace('/[^\r\n]{73}[^=\r\n]{2}/', "$0=\r\n",
      str_replace("%", "=", str_replace("%0D%0A", "\r\n", 
        str_replace("%20"," ",rawurlencode($string)))));
  }
}
?>

Regards, André

<< Back to user notes page

To Top