note 51378 added to function.quoted-printable-decode

From: Date: Tue, 29 Mar 2005 09:08:24 +0000
Subject: note 51378 added to function.quoted-printable-decode
Groups: php.notes 
Request: Send a blank email to php-notes+get-87130@lists.php.net to get a copy of this message
This function appeared twice already and in both versions it's got error in rule replacing chunk_split, because it misses the last line in encoded text if it's shorter than 73 characters. My solution (got rid of replace_callback) <? function quoted_printable_encode( $sString ) { /*instead of replace_callback i used <b>e</b> modifier for regex rule, which works as eval php function*/ $sString = preg_replace( '/[^\x21-\x3C\x3E-\x7E\x09\x20]/e', 'sprintf( "=%02x", ord ( "$0" ) ) ;', $sString ); /*now added to this rule one or more chars which lets last line to be matched and included in results*/ preg_match_all( '/.{1,73}([^=]{0,3})?/', $sString, $aMatch ); return implode( '=' . CR, $aMatch[0] ); } ?> ---- Manual Page -- http://www.php.net/manual/en/function.quoted-printable-decode.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+51378 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51378&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51378&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51378&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51378&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51378&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+51378&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#87130) next »