|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 03 09:00:01 2025 UTC |
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