|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46165 strcoll() does not work with UTF-8 strings on Windows
Submitted: 2008-09-24 07:31 UTC Modified: 2008-12-08 09:48 UTC
Avg. Score:4.6 ± 0.6
Reproduced:12 of 12 (100.0%)
Same Version:6 (50.0%)
Same OS:11 (91.7%)
From: gehrig at ishd dot de Assigned: pajoye (profile)
Status: Not a bug Package: Strings related
PHP Version: 5.2.6 OS: win32 only
Private report: No CVE-ID: None
 [2008-09-24 07:31 UTC] gehrig at ishd dot de


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-10-27 14:10 UTC]
As a windows only bug assigned to the windows port maintainer.
 [2008-10-29 10:05 UTC]
POSIX locales, don't really deal with multi byte strings like UTF8 so well, not even on unices.
 [2008-10-29 10:11 UTC]
I'm not sure it is worth fixing, for many reasons. The first is to get it working on each system in a portable is a real pain (and as Derick pointed out, really not only on windows).

My opinion is that all these functions should be deprecated (or strongly recommend to do not be used for anything but ascii) in favour of the new unicode APIs (6.x or partially with intl).
 [2008-11-30 23:05 UTC]
Not a php issue, use intl, mbstring or wait php6.
 [2008-12-01 10:54 UTC] gehrig at ishd dot de
It actually IS a PHP issue as this bug describes some software defect in a PHP core function that is intended to deliver the functionality described here: sorting an array on a locale-aware basis using available system locales.

You can argue whether it's worth fixing the bug with the upcoming PHP 6 in the pipeline, but simply categorizing this as a non-PHP issue is not correct.
 [2008-12-01 11:08 UTC]
strcoll is not a PHP internal functions but is part of the CRT. PHP's strcoll is only a thin wrapper around it. We have no way to change its behavior or fix it.
 [2008-12-08 09:48 UTC] gehrig at ishd dot de
Having dug around to sort our this problem I found a notice on the MSDN setlocale, _wsetlocale page which clearly states that setlocale() does not work with multi-byte charsets on Windows:

The set of available languages, country/region codes, and code pages includes all those supported by the Win32 NLS API except code pages that require more than two bytes per character, such as UTF-7 and UTF-8. If you provide a code page like UTF-7 or UTF-8, setlocale will fail, returning NULL. The set of language and country/region codes supported by setlocale is listed in Language and Country/Region Strings. 

Therefore this bug is correctly identified as "bogus". The problem is the Windows CRT and not the PHP setlocale() or strcoll() implementation.
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC