diff options
author | Andreas Gohr <andi@splitbrain.org> | 2009-07-25 12:44:59 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2009-07-25 12:44:59 +0200 |
commit | ebbde2b17bb6537aa9cf489a174cdbedee5d6ebc (patch) | |
tree | 8076cd888fb43b455b656faa260ccbe1eae4cb8e /inc | |
parent | f2da7e0bcc3c9c38f4b14e42b4632291343bf343 (diff) | |
download | rpg-ebbde2b17bb6537aa9cf489a174cdbedee5d6ebc.tar.gz rpg-ebbde2b17bb6537aa9cf489a174cdbedee5d6ebc.tar.bz2 |
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 <netzmeister@andreas-haerter.de>
* 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
Diffstat (limited to 'inc')
-rw-r--r-- | inc/utf8.php | 7 |
1 files changed, 5 insertions, 2 deletions
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 <netzmeister@andreas-haerter.de> + * @author Andreas Gohr <andi@splitbrain.org> */ function utf8_isASCII($str){ - return (preg_match('/(?:[^\x00-\x7F])/', $str) !== 1); + for($i=0; $i<strlen($str); $i++){ + if(ord($str{$i}) >127) return false; + } + return true; } } |