|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61023 Wrong sorting in strnatcasecmp for cyrillic letters
Submitted: 2012-02-09 08:01 UTC Modified: 2012-02-09 08:40 UTC
From: redrat at mail dot ru Assigned:
Status: Not a bug Package: Strings related
PHP Version: 5.3.10 OS: FreeBSD 6.x-8.x
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: redrat at mail dot ru
New email:
PHP Version: OS:


 [2012-02-09 08:01 UTC] redrat at mail dot ru
The strnatcasecmp function wrongly sorts strings in Russian, putting all uppercase letters before lowercase letters.

Test script:

echo strnatcmp("alpha", "Beta")."\t";
echo strnatcasecmp("alpha", "Beta").PHP_EOL;

echo strnatcmp("альфа", "Бета")."\t";
echo strnatcasecmp("альфа", "Бета").PHP_EOL;


Expected result:
1       -1
1       -1

Actual result:
1       -1
1       1


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-02-09 08:40 UTC]
I'm afraid the strnat* functions don't support any sort of localization. Take a look at functions that are locale-dependent like strcoll or ICU collators (intl extension).
 [2012-02-09 08:40 UTC]
-Status: Open +Status: Not a bug
 [2012-02-09 10:12 UTC] redrat at mail dot ru
Oh, I see... Well, there is some another methods around here to play with.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Apr 18 05:01:24 2021 UTC