[TYPO3-core] Another patch request for t3lib_htmlmail

Dmitry Dulepov dima at spamcop.net
Thu Jan 26 16:53:01 CET 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi!

Stanislas Rolland wrote:
>  			// Make sure the string contains only Unix linebreaks
>  		$string = str_replace(chr(13).chr(10), chr(10), $string);	// Replace Windows breaks (\r\n)
>  		$string = str_replace(chr(13), chr(10), $string);		// Replace Mac breaks (\r)

Btw, faster:

$string = preg_replace('/\r?\n/', chr(10), $string);
$string = preg_replace('/\r/', chr(10), $string);

>  		$theLines = explode(chr(10),$string);	// Split lines

$theLines = preg_split('/\n/',$string);

>$newVal = ereg_replace(chr(32).'$','=20',$newVal);
>$newVal = ereg_replace(chr(9).'$','=09',$newVal);

$newVal = preg_replace('/\x20$/m','=20',$newVal);
$newVal = preg_replace('/\t$/m','=09',$newVal);

> +		return ereg_replace($lineBreak.'$','',$newString);

return preg_replace('/\r?\n$/D','',$newString);

Generally, preg_* are faster than ereg_* or other string functions.

You do not have to include it all in your patch but if you do, it will
be better.

Dmitry.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (MingW32)

iD8DBQFD2PBdRVcYnKJ8N6kRAk2qAJ481n09NY5RqRbiwn5w+3LAHOcsuACeJBtR
I6d3EBqv6oduQzd6PXD43xQ=
=sWYY
-----END PGP SIGNATURE-----



More information about the TYPO3-team-core mailing list