5 #include <locale/localeinfo.h>
10 int32_t table_size
, idx
, i
, found
;
11 const int32_t *symb_table
;
12 const unsigned char *extra
;
15 union locale_data_value u
;
17 ca
= setlocale (LC_ALL
, "da_DK.ISO-8859-1");
20 printf ("cannot set locale: %m\n");
23 printf ("current locale : %s\n", ca
);
25 u
.string
= nl_langinfo (_NL_COLLATE_NRULES
);
33 u
.string
= nl_langinfo (_NL_COLLATE_SYMB_HASH_SIZEMB
);
35 symb_table
= (const int32_t *) nl_langinfo (_NL_COLLATE_SYMB_TABLEMB
);
36 extra
= (const unsigned char *) nl_langinfo (_NL_COLLATE_SYMB_EXTRAMB
);
39 for (i
= 0; i
< table_size
; ++i
)
41 if (symb_table
[2 * i
] != 0)
44 idx
= symb_table
[2 * i
+ 1];
45 strncpy (elem
, (const char *) (extra
+ idx
+ 1), extra
[idx
]);
46 elem
[extra
[idx
]] = '\0';
47 printf ("Found a collating element: %s\n", elem
);
53 printf ("No collating element!\n");
58 printf ("expected 4 collating elements, found %d\n", found
);