strtod: avoid C99 decl-after-statement
[gnulib.git] / lib / unicase.h
1 /* Unicode character case mappings.
2    Copyright (C) 2002, 2009 Free Software Foundation, Inc.
3
4    This program is free software: you can redistribute it and/or modify it
5    under the terms of the GNU Lesser General Public License as published
6    by the Free Software Foundation; either version 3 of the License, or
7    (at your option) any later version.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Lesser General Public License for more details.
13
14    You should have received a copy of the GNU Lesser General Public License
15    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
16
17 #ifndef _UNICASE_H
18 #define _UNICASE_H
19
20 #include "unitypes.h"
21
22 /* Get size_t.  */
23 #include <stddef.h>
24
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28
29 /* ========================================================================= */
30
31 /* Character case mappings.
32    These mappings are locale and context independent.
33    WARNING! These functions are not sufficient for languages such as German.
34    Better use the functions below that treat an entire string at once and are
35    language aware.  */
36
37 /* Return the uppercase mapping of a Unicode character.  */
38 extern ucs4_t
39        uc_toupper (ucs4_t uc);
40
41 /* Return the lowercase mapping of a Unicode character.  */
42 extern ucs4_t
43        uc_tolower (ucs4_t uc);
44
45 /* Return the titlecase mapping of a Unicode character.  */
46 extern ucs4_t
47        uc_totitle (ucs4_t uc);
48
49 /* ========================================================================= */
50
51 /* String case mappings.  */
52
53 /* These functions are locale dependent.  The iso639_language argument
54    identifies the language (e.g. "tr" for Turkish).  NULL means to use
55    locale independent case mappings.  */
56
57 /* Return the ISO 639 language code of the current locale.
58    Return "" if it is unknown, or in the "C" locale.  */
59 extern const char *
60        uc_locale_language (void);
61
62 /* Return the uppercase mapping of a string.  */
63 extern uint8_t *
64        u8_toupper (const uint8_t *s, size_t n, const char *iso639_language, uint8_t *resultbuf, size_t *lengthp);
65 extern uint16_t *
66        u16_toupper (const uint16_t *s, size_t n, const char *iso639_language, uint16_t *resultbuf, size_t *lengthp);
67 extern uint32_t *
68        u32_toupper (const uint32_t *s, size_t n, const char *iso639_language, uint32_t *resultbuf, size_t *lengthp);
69
70 /* Return the lowercase mapping of a string.  */
71 extern uint8_t *
72        u8_tolower (const uint8_t *s, size_t n, const char *iso639_language, uint8_t *resultbuf, size_t *lengthp);
73 extern uint16_t *
74        u16_tolower (const uint16_t *s, size_t n, const char *iso639_language, uint16_t *resultbuf, size_t *lengthp);
75 extern uint32_t *
76        u32_tolower (const uint32_t *s, size_t n, const char *iso639_language, uint32_t *resultbuf, size_t *lengthp);
77
78 /* Return the titlecase mapping of a string.  */
79 extern uint8_t *
80        u8_totitle (const uint8_t *s, size_t n, const char *iso639_language, uint8_t *resultbuf, size_t *lengthp);
81 extern uint16_t *
82        u16_totitle (const uint16_t *s, size_t n, const char *iso639_language, uint16_t *resultbuf, size_t *lengthp);
83 extern uint32_t *
84        u32_totitle (const uint32_t *s, size_t n, const char *iso639_language, uint32_t *resultbuf, size_t *lengthp);
85
86 /* Return the case folded string.  */
87 extern uint8_t *
88        u8_casefold (const uint8_t *s, size_t n, uint8_t *resultbuf, size_t *lengthp);
89 extern uint16_t *
90        u16_casefold (const uint16_t *s, size_t n, uint16_t *resultbuf, size_t *lengthp);
91 extern uint32_t *
92        u32_casefold (const uint32_t *s, size_t n, uint32_t *resultbuf, size_t *lengthp);
93
94 /* Compare S1 and S2, ignoring case.
95    Return -1 if S1 < S2, 0 if S1 = S2, 1 if S1 > S2.  */
96 extern int
97        u8_casecmp (const uint8_t *s1, size_t n1, const uint8_t *s2, size_t n2);
98 extern int
99        u16_casecmp (const uint16_t *s1, size_t n1, const uint16_t *s2, size_t n2);
100 extern int
101        u32_casecmp (const uint32_t *s1, size_t n1, const uint32_t *s2, size_t n2);
102
103 /* Compare S1 and S2 using the collation rules of the current locale,
104    ignoring case.
105    Return -1 if S1 < S2, 0 if S1 = S2, 1 if S1 > S2.
106    Upon failure, set errno and return any value.  */
107 extern int
108        u8_casecoll (const uint8_t *s1, size_t n1, const uint8_t *s2, size_t n2);
109 extern int
110        u16_casecoll (const uint16_t *s1, size_t n1, const uint16_t *s2, size_t n2);
111 extern int
112        u32_casecoll (const uint32_t *s1, size_t n1, const uint32_t *s2, size_t n2);
113
114 /* ========================================================================= */
115
116 #ifdef __cplusplus
117 }
118 #endif
119
120 #endif /* _UNICASE_H */