This is the mail archive of the libc-locales@sourceware.org mailing list for the GNU libc locales project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug localedata/20664] Unexpected collation in en_US.UTF-8, different to ICU CLDR


https://sourceware.org/bugzilla/show_bug.cgi?id=20664

--- Comment #3 from mathew <meta at pobox dot com> ---
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <locale.h>

int main() {
  char *str[4], *temp;
  int i, j, n, c;

  setlocale(LC_ALL, "en_US.UTF-8");

  str[0] = "+00";
  str[1] = "-0c";
  str[2] = "+02";
  str[3] = "-02";

  n = 4;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n - 1; j++) {
      c = strcoll(str[j], str[j + 1]) > 0;
      printf("i = %d j = %d strcoll %s %s = %d\n", i, j, str[i], str[j], c);
      if (c > 0) {
        temp = str[j];
        str[j] = str[j+1];
        str[j+1] = temp;
      }
    }
  }

  printf("\nSorted List:\n");
  for (i = 0; i < n; i++) {
    puts(str[i]);
  }

  return (0);
}

% ./a.out 
i = 0 j = 0 strcoll +00 +00 = 0
i = 0 j = 1 strcoll +00 -0c = 1
i = 0 j = 2 strcoll +00 -0c = 1
i = 1 j = 0 strcoll +02 +00 = 0
i = 1 j = 1 strcoll +02 +02 = 1
i = 1 j = 2 strcoll -02 +02 = 0
i = 2 j = 0 strcoll +02 +00 = 0
i = 2 j = 1 strcoll +02 -02 = 0
i = 2 j = 2 strcoll +02 +02 = 0
i = 3 j = 0 strcoll -0c +00 = 0
i = 3 j = 1 strcoll -0c -02 = 0
i = 3 j = 2 strcoll -0c +02 = 0

Sorted List:
+00
-02
+02
-0c

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]