According to this blog post , for the words cote , cotĂŠ , cĂ´te and cĂ´tĂŠ (already sorted in English), the sort order in French is: cote , cĂ´te , cotĂŠ and cĂ´tĂŠ . The code below sorts words in French sort:
$words = array('cote', 'cotĂŠ', 'cĂ´te', 'cĂ´tĂŠ'); print_r($words); $collator = new Collator('fr_FR'); // print info about locale echo 'French Collation ' . (($collator->getAttribute(Collator::FRENCH_COLLATION) == Collator::ON) ? 'On' : 'Off') . "\n"; echo $collator->getLocale(Locale::VALID_LOCALE) . "\n"; echo $collator->getLocale(Locale::ACTUAL_LOCALE) . "\n"; $collator->asort($words); print_r($words);
And the printed result is as follows:
Array ( [0] => cote [1] => cotĂŠ [2] => cĂ´te [3] => cĂ´tĂŠ ) French Collation On fr_FR fr Array ( [0] => cote [2] => cĂ´te [1] => cotĂŠ [3] => cĂ´tĂŠ )
In the same blog post, the author says:
[...] diacritics are evaluated from right to left, and not from left to right. Thus, cĂ´te precedes cotĂŠ , and not after it, as in languages ââsuch as English, which evaluate them from left to right. Since the word cĂ´te does not have SHARP on the "e" at the end of the word, but cotĂŠ . In English and most other languages, evaluation begins on the left, and therefore CIRCUMFLEX or the lack of an âoâ is the controlling factor when ordering.
So, if you have an array with the words Spain and the USA , they will have the same order in English and French.
You should also keep in mind that the asort method supports the association of array indices. See the difference:
asort: Array ( [0] => cote [2] => cĂ´te [1] => cotĂŠ [3] => cĂ´tĂŠ ) sort: Array ( [0] => cote [1] => cĂ´te [2] => cotĂŠ [3] => cĂ´tĂŠ )
About U_USING_DEFAULT_WARNING
According to this API documentation :
U_USING_DEFAULT_WARNING indicates that the default locale data was used; neither the requested locale nor any of its falling locations were found.
When I use the fr_FR locale, for example, I get U_USING_FALLBACK_WARNING, which indicates that the locale of the return was used, in this case the fr language.
Locale
It seems that your computer does not support the French language (or it does, but somehow PHP cannot use it, and then abandon the default language), although the locale -a command displays French packages, I have some suggestions, which you can try.
First specify all supported locales:
cat /usr/share/i18n/SUPPORTED
Now create the languages ââyou need:
sudo locale-gen fr_FR.UTF-8 sudo locale-gen fr_FR.ISO-8859-1 sudo dpkg-reconfigure locales
If this does not work, try installing the language-pack-fr and language-support-fr packages and generate the languages ââagain.
This problem is odd. I have a virtual machine with Ubuntu 11.04 and PHP 5.3.8, and it works fine in my Debian 6 too, and I have not installed any package or configured anything.