php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #70799 strcasecmp is not locale aware
Submitted: 2015-10-27 05:30 UTC Modified: 2020-01-27 11:20 UTC
From: yurets at gambler dot ru Assigned:
Status: Verified Package: Strings related
PHP Version: 5.6.14 OS: FreeBSD 10.1
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2015-10-27 05:30 UTC] yurets at gambler dot ru
Description:
------------
---
From manual page: http://www.php.net/function.strcasecmp
---
It's the same CP1251 symbol used in test script, upper- and lower-cased

No problems if using strtolower or strtoupper, only strcasecmp is affected.

Test script:
---------------
<?
setlocale( LC_ALL, "ru_RU.CP1251", "rus_RUS.CP1251", "Russian_Russia.1251" );
echo strcasecmp( "А", "а" );
?>


Expected result:
----------------
0

Actual result:
--------------
-32

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-02-28 21:59 UTC] cmb@php.net
-Package: Unknown/Other Function +Package: Strings related
 [2020-01-27 11:20 UTC] cmb@php.net
-Summary: strcasecmp works incorrect for CP1251 +Summary: strcasecmp is not locale aware -Status: Open +Status: Verified -Type: Bug +Type: Documentation Problem
 [2020-01-27 11:20 UTC] cmb@php.net
That behavior is to be expected, since strcasecmp() is *not*
locale aware (it only handles ASCII characters properly regarding
case-insensivity).  That needs to be documented.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Aug 11 20:01:33 2020 UTC