From f2da7e0bcc3c9c38f4b14e42b4632291343bf343 Mon Sep 17 00:00:00 2001 From: Andreas Haerter Date: Fri, 24 Jul 2009 10:40:09 +0200 Subject: Much faster version of utf8_isASCII() Ignore-this: 1adbc2b33e76b3a76e650c340e9644e6 This version uses a non-capturing regular expression instead of looping through all characters of the string. darcs-hash:20090724084009-2cb76-ad1630c7aca53f0bdb596525b0693304a9b4cc88.gz --- inc/utf8.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'inc/utf8.php') diff --git a/inc/utf8.php b/inc/utf8.php index e2f016942..85e5f4f7e 100644 --- a/inc/utf8.php +++ b/inc/utf8.php @@ -62,13 +62,10 @@ if(!function_exists('utf8_isASCII')){ /** * Checks if a string contains 7bit ASCII only * - * @author Andreas Gohr + * @author Andreas Haerter */ function utf8_isASCII($str){ - for($i=0; $i127) return false; - } - return true; + return (preg_match('/(?:[^\x00-\x7F])/', $str) !== 1); } } -- cgit v1.2.3