| 1 |
/* locale information |
| 2 |
|
| 3 |
Copyright 2016-2025 Free Software Foundation, Inc. |
| 4 |
|
| 5 |
This program is free software; you can redistribute it and/or modify |
| 6 |
it under the terms of the GNU General Public License as published by |
| 7 |
the Free Software Foundation, either version 3, or (at your option) |
| 8 |
any later version. |
| 9 |
|
| 10 |
This program is distributed in the hope that it will be useful, |
| 11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
GNU General Public License for more details. |
| 14 |
|
| 15 |
You should have received a copy of the GNU General Public License |
| 16 |
along with this program. If not, see <https://www.gnu.org/licenses/>. */ |
| 17 |
|
| 18 |
/* Written by Paul Eggert. */ |
| 19 |
|
| 20 |
#include <limits.h> |
| 21 |
#include <wchar.h> |
| 22 |
#if GAWK |
| 23 |
/* Use ISO C 99 API. */ |
| 24 |
# define char32_t wchar_t |
| 25 |
#else |
| 26 |
/* Use ISO C 11 + gnulib API. */ |
| 27 |
# include <uchar.h> |
| 28 |
#endif |
| 29 |
|
| 30 |
#ifdef __cplusplus |
| 31 |
extern "C" { |
| 32 |
#endif |
| 33 |
|
| 34 |
|
| 35 |
struct localeinfo |
| 36 |
{ |
| 37 |
/* MB_CUR_MAX > 1. */ |
| 38 |
bool multibyte; |
| 39 |
|
| 40 |
/* The locale is simple, like the C locale. These locales can be |
| 41 |
processed more efficiently, as they are single-byte, their native |
| 42 |
character set is in collating-sequence order, and they do not |
| 43 |
have multi-character collating elements. */ |
| 44 |
bool simple; |
| 45 |
|
| 46 |
/* The locale uses UTF-8. */ |
| 47 |
bool using_utf8; |
| 48 |
|
| 49 |
/* An array indexed by byte values B that contains 1 if B is a |
| 50 |
single-byte character, -1 if B is an encoding error, and -2 if B |
| 51 |
is the leading byte of a multibyte character that contains more |
| 52 |
than one byte. */ |
| 53 |
signed char sbclen[UCHAR_MAX + 1]; |
| 54 |
|
| 55 |
/* An array indexed by byte values B that contains the corresponding |
| 56 |
32-bit wide character (if any) for B if sbclen[B] == 1. WEOF means |
| 57 |
the byte is not a valid single-byte character, i.e., sbclen[B] == -1 |
| 58 |
or -2. */ |
| 59 |
wint_t sbctowc[UCHAR_MAX + 1]; |
| 60 |
}; |
| 61 |
|
| 62 |
extern void init_localeinfo (struct localeinfo *); |
| 63 |
|
| 64 |
/* Maximum number of characters that can be the case-folded |
| 65 |
counterparts of a single character, not counting the character |
| 66 |
itself. This is a generous upper bound. */ |
| 67 |
enum { CASE_FOLDED_BUFSIZE = 32 }; |
| 68 |
|
| 69 |
extern int case_folded_counterparts (wint_t, char32_t[CASE_FOLDED_BUFSIZE]); |
| 70 |
|
| 71 |
|
| 72 |
#ifdef __cplusplus |
| 73 |
} |
| 74 |
#endif |