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
 [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-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 17:01:29 2024 UTC