note 24646 deleted from function.strtolower by nlopess

From: Date: Sat, 07 Feb 2004 10:06:47 +0000
Subject: note 24646 deleted from function.strtolower by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-64761@lists.php.net to get a copy of this message
Note Submitter: windix@263.net ---- If you use strtolower in Double-Byte-Characters-System, such as GB2312 of Chinese, it makes mistake in some cases. for example: strtolower('Óê Rain'); Result is 'óê rain', not 'Óê rain'. So use the function below: function mstrtolower($str) { $len=strlen($str); for ($i=0; $i<$len; $i++) { if (ord(substr($str,$i,1))>0xa0) { //All GB2312 Chars starts above ascii 0xa0 $tmpstr.=substr($str,$i,2); $i++; } else { $tmpstr.=substr($str,$i,1); } } return $tmpstr; }

« previous php.notes (#64761) next »