1 /* Unicode character case mappings.
2 Copyright (C) 2002, 2009 Free Software Foundation, Inc.
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.
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.
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/>. */
29 /* ========================================================================= */
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
37 /* Return the uppercase mapping of a Unicode character. */
39 uc_toupper (ucs4_t uc);
41 /* Return the lowercase mapping of a Unicode character. */
43 uc_tolower (ucs4_t uc);
45 /* Return the titlecase mapping of a Unicode character. */
47 uc_totitle (ucs4_t uc);
49 /* ========================================================================= */
51 /* String case mappings. */
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. */
57 /* Return the ISO 639 language code of the current locale.
58 Return "" if it is unknown, or in the "C" locale. */
60 uc_locale_language (void);
62 /* Return the uppercase mapping of a string. */
64 u8_toupper (const uint8_t *s, size_t n, const char *iso639_language, uint8_t *resultbuf, size_t *lengthp);
66 u16_toupper (const uint16_t *s, size_t n, const char *iso639_language, uint16_t *resultbuf, size_t *lengthp);
68 u32_toupper (const uint32_t *s, size_t n, const char *iso639_language, uint32_t *resultbuf, size_t *lengthp);
70 /* Return the lowercase mapping of a string. */
72 u8_tolower (const uint8_t *s, size_t n, const char *iso639_language, uint8_t *resultbuf, size_t *lengthp);
74 u16_tolower (const uint16_t *s, size_t n, const char *iso639_language, uint16_t *resultbuf, size_t *lengthp);
76 u32_tolower (const uint32_t *s, size_t n, const char *iso639_language, uint32_t *resultbuf, size_t *lengthp);
78 /* Return the titlecase mapping of a string. */
80 u8_totitle (const uint8_t *s, size_t n, const char *iso639_language, uint8_t *resultbuf, size_t *lengthp);
82 u16_totitle (const uint16_t *s, size_t n, const char *iso639_language, uint16_t *resultbuf, size_t *lengthp);
84 u32_totitle (const uint32_t *s, size_t n, const char *iso639_language, uint32_t *resultbuf, size_t *lengthp);
86 /* Return the case folded string. */
88 u8_casefold (const uint8_t *s, size_t n, uint8_t *resultbuf, size_t *lengthp);
90 u16_casefold (const uint16_t *s, size_t n, uint16_t *resultbuf, size_t *lengthp);
92 u32_casefold (const uint32_t *s, size_t n, uint32_t *resultbuf, size_t *lengthp);
94 /* Compare S1 and S2, ignoring case.
95 Return -1 if S1 < S2, 0 if S1 = S2, 1 if S1 > S2. */
97 u8_casecmp (const uint8_t *s1, size_t n1, const uint8_t *s2, size_t n2);
99 u16_casecmp (const uint16_t *s1, size_t n1, const uint16_t *s2, size_t n2);
101 u32_casecmp (const uint32_t *s1, size_t n1, const uint32_t *s2, size_t n2);
103 /* Compare S1 and S2 using the collation rules of the current locale,
105 Return -1 if S1 < S2, 0 if S1 = S2, 1 if S1 > S2.
106 Upon failure, set errno and return any value. */
108 u8_casecoll (const uint8_t *s1, size_t n1, const uint8_t *s2, size_t n2);
110 u16_casecoll (const uint16_t *s1, size_t n1, const uint16_t *s2, size_t n2);
112 u32_casecoll (const uint32_t *s1, size_t n1, const uint32_t *s2, size_t n2);
114 /* ========================================================================= */
120 #endif /* _UNICASE_H */