4 #include <locale/localeinfo.h>
9 int32_t table_size
, idx
, i
, found
;
10 const int32_t *symb_table
;
11 const unsigned char *extra
;
14 union locale_data_value u
;
16 ca
= setlocale (LC_ALL
, "da_DK.ISO-8859-1");
19 printf ("cannot set locale: %m\n");
22 printf ("current locale : %s\n", ca
);
24 u
.string
= nl_langinfo (_NL_COLLATE_NRULES
);
32 u
.string
= nl_langinfo (_NL_COLLATE_SYMB_HASH_SIZEMB
);
34 symb_table
= (const int32_t *) nl_langinfo (_NL_COLLATE_SYMB_TABLEMB
);
35 extra
= (const unsigned char *) nl_langinfo (_NL_COLLATE_SYMB_EXTRAMB
);
38 for (i
= 0; i
< table_size
; ++i
)
40 if (symb_table
[2 * i
] != 0)
43 idx
= symb_table
[2 * i
+ 1];
44 strncpy (elem
, extra
+ idx
+ 1, extra
[idx
]);
45 elem
[extra
[idx
]] = '\0';
46 printf ("Found a collating element: %s\n", elem
);
52 printf ("No collating element!\n");
57 printf ("expected 4 collating elements, found %d\n", found
);