From ebbde2b17bb6537aa9cf489a174cdbedee5d6ebc Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sat, 25 Jul 2009 12:44:59 +0200 Subject: rollback of the utf8_isASCII() patch Ignore-this: e5afeb833d0e0b0bf05ff5f497a3130d Tests showed the old code was faster and I was too stupid to read the test results rolling back: Fri Jul 24 10:40:09 CEST 2009 Andreas Haerter * Much faster version of utf8_isASCII() This version uses a non-capturing regular expression instead of looping through all characters of the string. M ./inc/utf8.php -5 +2 darcs-hash:20090725104459-7ad00-c4849ca67293083fee8021c2c198dab1dcb435a2.gz --- inc/utf8.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'inc/utf8.php') diff --git a/inc/utf8.php b/inc/utf8.php index 85e5f4f7e..e2f016942 100644 --- a/inc/utf8.php +++ b/inc/utf8.php @@ -62,10 +62,13 @@ if(!function_exists('utf8_isASCII')){ /** * Checks if a string contains 7bit ASCII only * - * @author Andreas Haerter + * @author Andreas Gohr */ function utf8_isASCII($str){ - return (preg_match('/(?:[^\x00-\x7F])/', $str) !== 1); + for($i=0; $i127) return false; + } + return true; } } -- cgit v1.2.3