|
Last change
on this file since 2196 was 2036, checked in by bird, 21 years ago |
|
Initial revision
|
-
Property cvs2svn:cvs-rev
set to
1.1
-
Property svn:eol-style
set to
native
-
Property svn:executable
set to
*
-
Property svn:keywords
set to
Author Date Id Revision
|
|
File size:
1.3 KB
|
| Line | |
|---|
| 1 | #include <stdio.h>
|
|---|
| 2 | #include <string.h>
|
|---|
| 3 | #include <locale.h>
|
|---|
| 4 | #include <locale/localeinfo.h>
|
|---|
| 5 |
|
|---|
| 6 | int
|
|---|
| 7 | main (void)
|
|---|
| 8 | {
|
|---|
| 9 | int32_t table_size, idx, i, found;
|
|---|
| 10 | const int32_t *symb_table;
|
|---|
| 11 | const unsigned char *extra;
|
|---|
| 12 | uint32_t nrules;
|
|---|
| 13 | char *ca;
|
|---|
| 14 | union locale_data_value u;
|
|---|
| 15 |
|
|---|
| 16 | ca = setlocale (LC_ALL, "da_DK.ISO-8859-1");
|
|---|
| 17 | if (ca == NULL)
|
|---|
| 18 | {
|
|---|
| 19 | printf ("cannot set locale: %m\n");
|
|---|
| 20 | return 1;
|
|---|
| 21 | }
|
|---|
| 22 | printf ("current locale : %s\n", ca);
|
|---|
| 23 |
|
|---|
| 24 | u.string = nl_langinfo (_NL_COLLATE_NRULES);
|
|---|
| 25 | nrules = u.word;
|
|---|
| 26 | if (nrules == 0)
|
|---|
| 27 | {
|
|---|
| 28 | printf("No rule\n");
|
|---|
| 29 | return 1;
|
|---|
| 30 | }
|
|---|
| 31 |
|
|---|
| 32 | u.string = nl_langinfo (_NL_COLLATE_SYMB_HASH_SIZEMB);
|
|---|
| 33 | table_size = u.word;
|
|---|
| 34 | symb_table = (const int32_t *) nl_langinfo (_NL_COLLATE_SYMB_TABLEMB);
|
|---|
| 35 | extra = (const unsigned char *) nl_langinfo (_NL_COLLATE_SYMB_EXTRAMB);
|
|---|
| 36 |
|
|---|
| 37 | found = 0;
|
|---|
| 38 | for (i = 0; i < table_size; ++i)
|
|---|
| 39 | {
|
|---|
| 40 | if (symb_table[2 * i] != 0)
|
|---|
| 41 | {
|
|---|
| 42 | char elem[256];
|
|---|
| 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);
|
|---|
| 47 | ++found;
|
|---|
| 48 | }
|
|---|
| 49 | }
|
|---|
| 50 | if (found == 0)
|
|---|
| 51 | {
|
|---|
| 52 | printf ("No collating element!\n");
|
|---|
| 53 | return 1;
|
|---|
| 54 | }
|
|---|
| 55 | else if (found != 4)
|
|---|
| 56 | {
|
|---|
| 57 | printf ("expected 4 collating elements, found %d\n", found);
|
|---|
| 58 | return 1;
|
|---|
| 59 | }
|
|---|
| 60 |
|
|---|
| 61 | return 0;
|
|---|
| 62 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.