#include #include #include #include #include #define REPEAT 1 //#define LOCALE "de_DE.UTF-8" #define LOCALE "de_DE" #define COLLATE 1 int main () { int i, j, repeat; setlocale (LC_ALL, LOCALE); for (repeat = 1; repeat <= REPEAT; repeat++) { for (i = 1; i < 30000; i++) for (j = i - 1; j <= i + 1; j++) { char string1[20]; char string2[20]; int diff; sprintf (string1, "%010d", i); sprintf (string2, "%010d", j); #if COLLATE if (ulc_casecoll (string1, strlen (string1), string2, strlen (string2), uc_locale_language (), NULL, &diff) < 0) #else if (ulc_casecmp (string1, strlen (string1), string2, strlen (string2), uc_locale_language (), NULL, &diff) < 0) #endif abort (); if (diff != i - j) abort (); } } return 0; } /* Compile: gcc -m32 -Wall test-u8_casecoll.c -I /arch/x86-linux/gnu-inst-libunistring/0.9.3/include -L /arch/x86-linux/gnu-inst-libunistring/0.9.3/lib -lunistring -g Run: valgrind --tool=callgrind ./a.out Analyze: kcachegrind callgrind.out.* */ /* u8_casecmp de_DE.UTF-8 3.4 sec ulc_casecmp de_DE.UTF-8 4.0 sec ulc_casecmp de_DE 6.8 sec u8_casecoll de_DE.UTF-8 5.6 sec ulc_casecoll de_DE.UTF-8 5.7 sec ulc_casecoll de_DE 11.2 sec */