This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Bug in collation functions?
- From: Ken Brown <kbrown at cornell dot edu>
- To: cygwin <cygwin at cygwin dot com>
- Date: Wed, 28 Oct 2015 18:14:07 -0400
- Subject: Bug in collation functions?
- Authentication-results: sourceware.org; auth=none
It's my understanding that collation is supposed to take whitespace and
punctuation into account in the POSIX locale but not in other locales.
This doesn't seem to be the case on Cygwin. Here's a test case using
wcscoll, but the same problem occurs with strcoll.
$ cat wcscoll_test.c
#include <wchar.h>
#include <stdio.h>
#include <locale.h>
void
compare (const wchar_t *a, const wchar_t *b, const char *loc)
{
setlocale (LC_COLLATE, loc);
char res = wcscoll (a, b) < 0 ? '<' : '>';
printf ("\"%ls\" %c \"%ls\" in %s locale\n", a, res, b, loc);
}
int
main ()
{
compare (L"11", L"1.1", "POSIX");
compare (L"11", L"1.1", "en_US.UTF-8");
compare (L"11", L"1 2", "POSIX");
compare (L"11", L"1 2", "en_US.UTF-8");
}
$ gcc wcscoll_test.c -o wcscoll_test
$ ./wcscoll_test
"11" > "1.1" in POSIX locale
"11" > "1.1" in en_US.UTF-8 locale
"11" > "1 2" in POSIX locale
"11" > "1 2" in en_US.UTF-8 locale
On Linux, the output from the same program is
"11" > "1.1" in POSIX locale
"11" < "1.1" in en_US.UTF-8 locale
"11" > "1 2" in POSIX locale
"11" < "1 2" in en_US.UTF-8 locale
Ken
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple