|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-03-13 15:20 UTC] mpmp at zoznam dot sk
Description: ------------ I am using setlocale(LC_ALL, 'slovak'); Accented characters are not properly sorted on Linux. On windows this code runs well. Locales are installed, and other locales related functions run well. Reproduce code: --------------- $pole = array ( 'čaj', 'ľad', 'ťahaj', '?bel', '?la', '?ver', '?iť', '?ger', '?ler', 'ňano', '?j', 'Ľadov?'); setlocale (LC_ALL, "slovak"); sort ($pole, SORT_LOCALE_STRING); Expected result: ---------------- Array ( [0] => ?bel [1] => ?j [2] => čaj [3] => ?ger [4] => ?ver [5] => ľad [6] => Ľadov? [7] => ňano [8] => ?ler [9] => ?la [10] => ťahaj [11] => ?iť ) Actual result: -------------- Array ( [0] => ?bel [1] => ťahaj [2] => ?j [3] => čaj [4] => ?ger [5] => ?iť [6] => ?ver [7] => ?la [8] => ňano [9] => ?ler [10] => Ľadov? [11] => ľad ) PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 07 02:00:01 2025 UTC |
I received the script and I checked it. There is no bug in PHP, and you can "fix" the issue by: 1. converting your script's encoding to iso-8859-2 (as that is the default encoding on atleast my linux), and not the windows-1250 you use now. 2. Generate locale information with the correct encoding. On my Debian system I do that with: a. Edit /etc/locale.gen and add a line that says: sk_SK CP1250 b. Run "locale-gen" (as root) c. Then change your script to use "sk_SK" instead of "slovak". I did solution two and I now get the correct result: [0] => ?bel [1] => ?j [2] => čaj [3] => ?ger [4] => ?ver [5] => ľad [6] => Ľadov? [7] => ňano [8] => ?ler [9] => ?la [10] => ťahaj [11] => ?iť