ID:               34963
 User updated by:  brausepaule at gmx dot de
 Reported By:      brausepaule at gmx dot de
 Status:           Bogus
 Bug Type:         Unknown/Other Function
 Operating System: Linux Suse 9.3
 PHP Version:      5.0.5
 New Comment:

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


Previous Comments:
------------------------------------------------------------------------

[2005-10-23 22:55:22] [EMAIL PROTECTED]

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-23 20:59:48] brausepaule at gmx dot de

setlang means setlocale
sorry

------------------------------------------------------------------------

[2005-10-23 20:36:06] [EMAIL PROTECTED]

What is this "Setlang" you're talking about?

------------------------------------------------------------------------

[2005-10-23 20:13:08] 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, '[EMAIL PROTECTED]', '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



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=34963&edit=1

Reply via email to