32- Linux en_US.utf8. Perl, C:
#include <locale.h>
#include <string.h>
#include <stdio.h>
void transformed(const char* str)
{
char dest[256];
const char* c;
strxfrm(dest, str, sizeof(dest));
printf("%18s =", str);
for (c = dest; *c; ++c) printf(" %02x", *c);
puts("");
}
void test_strings(const char* s1, const char* s2)
{
int c = strcoll(s1, s2);
printf("%s is %s %s\n", s1, ((c < 0) ? "<" : ((c == 0) ? "=" : ">")), s2);
}
int main(int argc, char* argv[])
{
puts("with C locale:");
test_strings("aaa2000@yahoo.com", "aaa_2000@yahoo.com");
test_strings("aaa2000", "aaa_2000");
setlocale(LC_ALL, "");
puts("\nwith your locale:");
test_strings("aaa2000@yahoo.com", "aaa_2000@yahoo.com");
test_strings("aaa2000", "aaa_2000");
puts("");
transformed("aaa2000@yahoo.com");
transformed("aaa_2000@yahoo.com");
transformed("aaa2000");
transformed("aaa_2000");
return 0;
}
LANG=en_US.utf8 :
with C locale:
aaa2000@yahoo.com is < aaa_2000@yahoo.com
aaa2000 is < aaa_2000
with your locale:
aaa2000@yahoo.com is > aaa_2000@yahoo.com
aaa2000 is < aaa_2000
aaa2000@yahoo.com = 0c 0c 0c 04 02 02 02 24 0c 13 1a 1a 0e 1a 18 01 08 08 08 08 08 08 08 08 08 08 08 08 08 08 08 01 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 01 08 5d 06 44
aaa_2000@yahoo.com = 0c 0c 0c 04 02 02 02 24 0c 13 1a 1a 0e 1a 18 01 08 08 08 08 08 08 08 08 08 08 08 08 08 08 08 01 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02 01 04 36 05 5d 06 44
aaa2000 = 0c 0c 0c 04 02 02 02 01 08 08 08 08 08 08 08 01 02 02 02 02 02 02 02
aaa_2000 = 0c 0c 0c 04 02 02 02 01 08 08 08 08 08 08 08 01 02 02 02 02 02 02 02 01 04 36
strxfrm ( Perl POSIX) , . byte-for-byte, , , .
, . , , en_US. , C .