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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
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: Fri Dec 04 04:01:24 2020 UTC