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: Closed Package: Strings related
PHP Version: 5.6.14 OS: FreeBSD 10.1
Private report: No CVE-ID: None
 [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

Pull Requests

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.
 [2021-07-30 11:01 UTC] git@php.net
Automatic comment on behalf of cmb69
Revision: https://github.com/php/doc-en/commit/5dcdcf32f847c297f1fe174aea802a489cecaf1d
Log: Fix #70799: strcasecmp is not locale aware
 [2021-07-30 11:01 UTC] git@php.net
-Status: Verified +Status: Closed
 [2021-07-30 12:58 UTC] git@php.net
Automatic comment on behalf of mumumu
Revision: https://github.com/php/doc-ja/commit/5e713c220d2a689f026737f55dbad3da139f9ac3
Log: Fix #70799: strcasecmp is not locale aware
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 15:01:32 2024 UTC