php.net |  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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: redrat at mail dot ru
New email:
PHP Version: OS:

 

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

Test script:
---------------
<?php

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


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-02-09 08:40 UTC] cataphract@php.net
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] cataphract@php.net
-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-2020 The PHP Group
All rights reserved.
Last updated: Wed Oct 28 03:01:23 2020 UTC