note 69076 added to function.strcmp

From: Date: Tue, 22 Aug 2006 10:21:24 +0000
Subject: note 69076 added to function.strcmp
Groups: php.notes 
Request: Send a blank email to php-notes+get-116163@lists.php.net to get a copy of this message
php dot or dot die at phpuser dot net wrote that he had an unexpected difference in comparing between case sensitive and insensitive. They key there is that the case insensitive comparison converts both strings to lowercase before comparing. Since the underscore character is in a different place when compared to an uppercase or lowercase string, the result is different. There is no 'clear' order of punctuation and other characters in or around the alphabet. Most code assumes ASCII order in which case there are several characters before both upper- and lowercase, a few inbetween, and some after both upper- and lowercase. Note also many other/older implementations of sorting sort accented character wrong since they appear after all other alphabetical characters in most charactersets. There is probably a function in PHP to take this into account though. Therefore I would not recommend to make a detailed assumption on how punctuation and other characters sort in relation to alphabetical characters. If sorting these characters at a specific place and in a specific order is important for you, you should probably write a custom string comparison function that does it the way you want. Usually it's sufficient to have a consistent sorting order though, which is what you get by using either strcmp, or strcasecmp consistently. ---- Server IP: 83.137.20.120 Probable Submitter: 195.73.225.50 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.strcmp.php Edit -- https://master.php.net/note/edit/69076 Del: integrated -- https://master.php.net/note/delete/69076/integrated Del: useless -- https://master.php.net/note/delete/69076/useless Del: bad code -- https://master.php.net/note/delete/69076/bad+code Del: spam -- https://master.php.net/note/delete/69076/spam Del: non-english -- https://master.php.net/note/delete/69076/non-english Del: in docs -- https://master.php.net/note/delete/69076/in+docs Del: other reasons-- https://master.php.net/note/delete/69076 Reject -- https://master.php.net/note/reject/69076 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#116163) next »