note 24729 added to function.strcasecmp
| From: | php-general at lists dot php dot net | Date: | Tue, 27 Aug 2002 10:53:49 +0000 |
| Subject: | note 24729 added to function.strcasecmp | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-35719@lists.php.net to get a copy of this message | ||
The sample above is only true on some platforms that only use a simple 'C' locale, where
individual bytes are considered as complete characters that are converted to lowercase before being
differentiated.
Other locales (see LC_COLLATE and LC_ALL) use the difference of collation order of characters, where
characters may be groups of bytes taken from the input strings, or simply return -1, 0, or 1 as the
collation order is not simply defined by comparing individual characters but by more complex rules.
Don't base your code on a specific non null value returned by strcmp() or strcasecmp(): it is
not portable. Just consider the sign of the result and be sure to use the correct locale!
--
http://www.php.net/manual/en/function.strcasecmp.php
http://master.php.net/manage/user-notes.php?action=edit+24729
http://master.php.net/manage/user-notes.php?action=delete+24729
http://master.php.net/manage/user-notes.php?action=reject+24729