note 86449 modified in function.quoted-printable-decode by danbrown
| From: | danbrown@php.net | Date: | Mon, 20 Oct 2008 13:44:54 +0000 |
| Subject: | note 86449 modified in function.quoted-printable-decode by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-145507@lists.php.net to get a copy of this message | ||
Taking a bunch of the earlier comments together, you can synthesize a nice short and reasonably
efficient quoted_printable_encode function like this:
Note that I put this in my standard library file, so I wrap it in a !function_exists in order that
if there is a pre-existing PHP one it will just work and this will evaluate to a noop.
<?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 aren't encoded as =20 though.
*/
function quoted_printable_encode($string) {
return preg_replace('/[^\r\n]{73}[^=\r\n]{2}/', "$0=\r\n",
str_replace("%","=",str_replace("%20","
",rawurlencode($string))));
}
}
?>
Regards,
Andrew McMillan.
--was--
Taking a bunch of the earlier comments together, you can synthesize a nice short and reasonably
efficient quoted_printable_encode function like this:
Note that I put this in my standard library file, so I wrap it in a !function_exists in order that
if there is a pre-existing PHP one it will just work and this will evaluate to a noop.
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 aren't encoded as =20 though.
*/
function quoted_printable_encode($string) {
return preg_replace('/[^\r\n]{73}[^=\r\n]{2}/', "$0=\r\n",
str_replace("%","=",str_replace("%20","
",rawurlencode($string))));
}
}
Regards,
Andrew McMillan.
http://php.net/manual/en/function.quoted-printable-decode.php