php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34963 strcoll ignore "_" under Linux
Submitted: 2005-10-23 20:13 UTC Modified: 2005-11-03 19:49 UTC
From: brausepaule at gmx dot de Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 5.0.5 OS: Linux Suse 9.3
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: brausepaule at gmx dot de
New email:
PHP Version: OS:

 

 [2005-10-23 20:13 UTC] brausepaule at gmx dot de
Description:
------------
Under Linux 9.3 the function strcoll ignore the _

Under Windows it's work fine.

Reproduce code:
---------------
$ar = array('auto', 'beton', '?tsch', '?lig', 'test','file 4','file 6','file 7','1 file 2','2 file 1','3 file 3','_file 5');

setlocale (LC_ALL, 'de_DE@euro', 'de_DE', 'de', 'ge', 'german');
usort($ar,'strcoll');

while (list ($key, $value) = each ($ar))
    echo "$key: $value\n";

Expected result:
----------------
Under Windows (it's correct)
0: _file 5
1: 1 file 2
2: 2 file 1
3: 3 file 3
4: ?tsch
5: auto
6: beton
7: file 4
8: file 6
9: file 7
10: ?lig
11: test

Actual result:
--------------
Under Linux:
0: 1 file 2
1: 2 file 1
2: 3 file 3
3: ?tsch
4: auto
5: beton
6: file 4
7: _file 5
8: file 6
9: file 7
10: ?lig
11: test

the setlang works! Without setlang with strcmp it seems like:
0: _file 5
1: 1 file 2
2: 2 file 1
3: 3 file 3
4: auto
5: beton
6: file 4
7: file 6
8: file 7
9: test
10: ?tsch
11: ?lig


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-10-23 20:36 UTC] derick@php.net
What is this "Setlang" you're talking about?
 [2005-10-23 20:59 UTC] brausepaule at gmx dot de
setlang means setlocale
sorry
 [2005-10-23 22:55 UTC] derick@php.net
This is not a bug in PHP. PHP uses the Operating System's collation, which apperently collates in this way. There is nothing we can do about it now. In PHP 6 with Unicode support this behavior will be fixed, as ICU's collation algorithm does sort it the correct way.
 [2005-10-24 22:43 UTC] brausepaule at gmx dot de
It's seems like a Bug.
e.g.
the comparison between _ and a with strcoll results
1. _
2. a

the comparison beetween _b and aa with strcoll results
Linux:
1. aa
2. _b
Windows
1. _b
2. aa

My workaround for Linux is:

function linux_strcoll($a,$b){
  $xa = strlen($a);
  $xb = strlen($b);
  $x = $xa < $xb ? $xb : $xa;
  $wert = $i =0;

  while($i<$x && $wert==0) :
    $wert = strcoll(substr($a,$i,1),substr($b,$i,1));
    $i++;
  endwhile;
return $wert;
}
The Problem the function makes rendering slower

Greats
Brause
 [2005-11-03 19:49 UTC] brausepaule at gmx dot de
Hello derick,
and is't a bug?

Greats
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 23 09:00:03 2025 UTC