From:             marek at lewczuk dot com
Operating system: Windows XP
PHP version:      5CVS-2004-05-26 (dev)
PHP Bug Type:     Arrays related
Bug description:  Sorting arrays in utf-8 charset not possible

Description:
------------
One year ago I have send info about a bug related on sorting arrays with
special, language specific characters like ���. The bug has "closed"
status, so it should be working. But is not... All characters are encoded
in UTF-8 and also I have made proper setLocale. I don't know if this is a
problem with Windows or PHP, but I think that this bug will be also
present  on Linux machines.

The code:
SetLocale(LC_COLLATE, $GLOBALS['__OS__'] == "WINDOWS" ?
"Polish_Poland.65001" : "pl_PL.UTF-8");
SetLocale(LC_CTYPE, $GLOBALS['__OS__'] == "WINDOWS" ?
"Polish_Poland.65001" : "pl_PL.UTF-8");
$array = array ("�liwka", "Zook", "Alfa", "Beta", "Shit");
sort($array);
print_r($array);


Current result of sorting:
Array
(
    [0] => Alfa
    [1] => Beta
    [2] => Shit
    [3] => Zook
    [4] => �liwka
)

And it should be:
Array
(
    [0] => Alfa
    [1] => Beta
    [2] => Shit
    [3] => �liwka
    [4] => Zook
)


Reproduce code:
---------------
SetLocale(LC_COLLATE, $GLOBALS['__OS__'] == "WINDOWS" ?
"Polish_Poland.65001" : "pl_PL.UTF-8");
SetLocale(LC_CTYPE, $GLOBALS['__OS__'] == "WINDOWS" ?
"Polish_Poland.65001" : "pl_PL.UTF-8");
$array = array ("�liwka", "Zook", "Alfa", "Beta", "Shit");
sort($array);
print_r($array);

Expected result:
----------------
Array
(
    [0] => Alfa
    [1] => Beta
    [2] => Shit
    [3] => �liwka
    [4] => Zook
)


Actual result:
--------------
Array
(
    [0] => Alfa
    [1] => Beta
    [2] => Shit
    [3] => Zook
    [4] => �liwka
)

-- 
Edit bug report at http://bugs.php.net/?id=28527&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=28527&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=28527&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=28527&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=28527&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=28527&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=28527&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=28527&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=28527&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=28527&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=28527&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=28527&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=28527&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28527&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=28527&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=28527&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=28527&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28527&r=float

Reply via email to