#48322 [Opn->Csd]: strcoll() does not work with UTF-8 strings on Mac OS X

From: Date: Tue, 19 May 2009 10:51:00 +0000
Subject: #48322 [Opn->Csd]: strcoll() does not work with UTF-8 strings on Mac OS X
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-137489@lists.php.net to get a copy of this message
ID: 48322 Updated by: jani@php.net Reported By: netspy at me dot com -Status: Open +Status: Closed -Bug Type: Unknown/Other Function +Bug Type: *Unicode Issues Operating System: Mac OS X PHP Version: 5.2.9 New Comment: It doesn't work on any system below PHP 6. You can always use the intl extension from PECL while waiting for proper unicode support: http://pecl.php.net/intl Using the collator (http://php.net/collator) you can achieve sorting with any locales. Previous Comments: ------------------------------------------------------------------------ [2009-05-18 22:37:22] netspy at me dot com Description: ------------ strcoll() does not sort UTF-8 strings correctly on Mac OS X. Reproduce code: --------------- $locale = 'de_DE.UTF-8'; $string = "abcdefghijklmnopqrstuvwxyzäöüß"; $array = array(); for ($i=0; $i<mb_strlen($string, 'UTF-8'); $i++) { $array[]=mb_substr($string, $i, 1, 'UTF-8'); } $oldLocale = setlocale(LC_COLLATE, "0"); print("\nOld: $oldLocale New: "); print(setlocale(LC_COLLATE, $locale)); usort($array, 'strcoll'); setlocale(LC_COLLATE, $oldLocale); print("\n" . implode('', $array) . "\n"); Expected result: ---------------- Old: C New: de_DE.UTF-8 aäbcdefghijklmnoöpqrsßtuüvwxyz Actual result: -------------- Old: C New: de_DE.UTF-8 abcdefghijklmnopqrstuvwxyzßäöü ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=48322&edit=1

« previous php.bugs (#137489) next »