Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-06-30 08:56:29

0001 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
0002 /* Unicode character case mappings.
0003    Copyright (C) 2002, 2009-2024 Free Software Foundation, Inc.
0004 
0005    This file is free software: you can redistribute it and/or modify
0006    it under the terms of the GNU Lesser General Public License as
0007    published by the Free Software Foundation; either version 2.1 of the
0008    License, or (at your option) any later version.
0009 
0010    This file is distributed in the hope that it will be useful,
0011    but WITHOUT ANY WARRANTY; without even the implied warranty of
0012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013    GNU Lesser General Public License for more details.
0014 
0015    You should have received a copy of the GNU Lesser General Public License
0016    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
0017 
0018 #ifndef _UNICASE_H
0019 #define _UNICASE_H
0020 
0021 #include "unitypes.h"
0022 
0023 /* Get bool.  */
0024 #include <unistring/stdbool.h>
0025 
0026 /* Get size_t.  */
0027 #include <stddef.h>
0028 
0029 /* Get uninorm_t.  */
0030 #include "uninorm.h"
0031 
0032 #if 1
0033 # include <unistring/woe32dll.h>
0034 #else
0035 # define LIBUNISTRING_DLL_VARIABLE
0036 #endif
0037 
0038 #ifdef __cplusplus
0039 extern "C" {
0040 #endif
0041 
0042 /* ========================================================================= */
0043 
0044 /* Character case mappings.
0045    These mappings are locale and context independent.
0046    WARNING! These functions are not sufficient for languages such as German.
0047    Better use the functions below that treat an entire string at once and are
0048    language aware.  */
0049 
0050 /* Return the uppercase mapping of a Unicode character.  */
0051 extern ucs4_t
0052        uc_toupper (ucs4_t uc)
0053        _UC_ATTRIBUTE_CONST;
0054 
0055 /* Return the lowercase mapping of a Unicode character.  */
0056 extern ucs4_t
0057        uc_tolower (ucs4_t uc)
0058        _UC_ATTRIBUTE_CONST;
0059 
0060 /* Return the titlecase mapping of a Unicode character.  */
0061 extern ucs4_t
0062        uc_totitle (ucs4_t uc)
0063        _UC_ATTRIBUTE_CONST;
0064 
0065 /* ========================================================================= */
0066 
0067 /* String case mappings.  */
0068 
0069 /* These functions are locale dependent.  The iso639_language argument
0070    identifies the language (e.g. "tr" for Turkish).  NULL means to use
0071    locale independent case mappings.  */
0072 
0073 /* Return the ISO 639 language code of the current locale.
0074    Return "" if it is unknown, or in the "C" locale.  */
0075 extern const char *
0076        uc_locale_language (void)
0077        _UC_ATTRIBUTE_PURE;
0078 
0079 /* Conventions:
0080 
0081    All functions prefixed with u8_ operate on UTF-8 encoded strings.
0082    Their unit is an uint8_t (1 byte).
0083 
0084    All functions prefixed with u16_ operate on UTF-16 encoded strings.
0085    Their unit is an uint16_t (a 2-byte word).
0086 
0087    All functions prefixed with u32_ operate on UCS-4 encoded strings.
0088    Their unit is an uint32_t (a 4-byte word).
0089 
0090    All argument pairs (s, n) denote a Unicode string s[0..n-1] with exactly
0091    n units.
0092 
0093    Functions returning a string result take a (resultbuf, lengthp) argument
0094    pair.  If resultbuf is not NULL and the result fits into *lengthp units,
0095    it is put in resultbuf, and resultbuf is returned.  Otherwise, a freshly
0096    allocated string is returned.  In both cases, *lengthp is set to the
0097    length (number of units) of the returned string.  In case of error,
0098    NULL is returned and errno is set.  */
0099 
0100 /* Return the uppercase mapping of a string.
0101    The nf argument identifies the normalization form to apply after the
0102    case-mapping.  It can also be NULL, for no normalization.  */
0103 extern uint8_t *
0104        u8_toupper (const uint8_t *s, size_t n, const char *iso639_language,
0105                    uninorm_t nf,
0106                    uint8_t *_UC_RESTRICT resultbuf, size_t *lengthp);
0107 extern uint16_t *
0108        u16_toupper (const uint16_t *s, size_t n, const char *iso639_language,
0109                     uninorm_t nf,
0110                     uint16_t *_UC_RESTRICT resultbuf, size_t *lengthp);
0111 extern uint32_t *
0112        u32_toupper (const uint32_t *s, size_t n, const char *iso639_language,
0113                     uninorm_t nf,
0114                     uint32_t *_UC_RESTRICT resultbuf, size_t *lengthp);
0115 
0116 /* Return the lowercase mapping of a string.
0117    The nf argument identifies the normalization form to apply after the
0118    case-mapping.  It can also be NULL, for no normalization.  */
0119 extern uint8_t *
0120        u8_tolower (const uint8_t *s, size_t n, const char *iso639_language,
0121                    uninorm_t nf,
0122                    uint8_t *_UC_RESTRICT resultbuf, size_t *lengthp);
0123 extern uint16_t *
0124        u16_tolower (const uint16_t *s, size_t n, const char *iso639_language,
0125                     uninorm_t nf,
0126                     uint16_t *_UC_RESTRICT resultbuf, size_t *lengthp);
0127 extern uint32_t *
0128        u32_tolower (const uint32_t *s, size_t n, const char *iso639_language,
0129                     uninorm_t nf,
0130                     uint32_t *_UC_RESTRICT resultbuf, size_t *lengthp);
0131 
0132 /* Return the titlecase mapping of a string.
0133    The nf argument identifies the normalization form to apply after the
0134    case-mapping.  It can also be NULL, for no normalization.  */
0135 extern uint8_t *
0136        u8_totitle (const uint8_t *s, size_t n, const char *iso639_language,
0137                    uninorm_t nf,
0138                    uint8_t *_UC_RESTRICT resultbuf, size_t *lengthp);
0139 extern uint16_t *
0140        u16_totitle (const uint16_t *s, size_t n, const char *iso639_language,
0141                     uninorm_t nf,
0142                     uint16_t *_UC_RESTRICT resultbuf, size_t *lengthp);
0143 extern uint32_t *
0144        u32_totitle (const uint32_t *s, size_t n, const char *iso639_language,
0145                     uninorm_t nf,
0146                     uint32_t *_UC_RESTRICT resultbuf, size_t *lengthp);
0147 
0148 /* The case-mapping context given by a prefix string.  */
0149 typedef struct casing_prefix_context
0150         {
0151           /* These fields are private, undocumented.  */
0152           uint32_t last_char_except_ignorable;
0153           uint32_t last_char_normal_or_above;
0154         }
0155         casing_prefix_context_t;
0156 /* The case-mapping context of the empty prefix string.  */
0157 extern LIBUNISTRING_DLL_VARIABLE const casing_prefix_context_t unicase_empty_prefix_context;
0158 /* Return the case-mapping context of a given prefix string.  */
0159 extern casing_prefix_context_t
0160        u8_casing_prefix_context (const uint8_t *s, size_t n);
0161 extern casing_prefix_context_t
0162        u16_casing_prefix_context (const uint16_t *s, size_t n);
0163 extern casing_prefix_context_t
0164        u32_casing_prefix_context (const uint32_t *s, size_t n);
0165 /* Return the case-mapping context of the prefix concat(A, S), given the
0166    case-mapping context of the prefix A.  */
0167 extern casing_prefix_context_t
0168        u8_casing_prefixes_context (const uint8_t *s, size_t n,
0169                                    casing_prefix_context_t a_context);
0170 extern casing_prefix_context_t
0171        u16_casing_prefixes_context (const uint16_t *s, size_t n,
0172                                     casing_prefix_context_t a_context);
0173 extern casing_prefix_context_t
0174        u32_casing_prefixes_context (const uint32_t *s, size_t n,
0175                                     casing_prefix_context_t a_context);
0176 
0177 /* The case-mapping context given by a suffix string.  */
0178 typedef struct casing_suffix_context
0179         {
0180           /* These fields are private, undocumented.  */
0181           uint32_t first_char_except_ignorable;
0182           uint32_t bits;
0183         }
0184         casing_suffix_context_t;
0185 /* The case-mapping context of the empty suffix string.  */
0186 extern LIBUNISTRING_DLL_VARIABLE const casing_suffix_context_t unicase_empty_suffix_context;
0187 /* Return the case-mapping context of a given suffix string.  */
0188 extern casing_suffix_context_t
0189        u8_casing_suffix_context (const uint8_t *s, size_t n);
0190 extern casing_suffix_context_t
0191        u16_casing_suffix_context (const uint16_t *s, size_t n);
0192 extern casing_suffix_context_t
0193        u32_casing_suffix_context (const uint32_t *s, size_t n);
0194 /* Return the case-mapping context of the suffix concat(S, A), given the
0195    case-mapping context of the suffix A.  */
0196 extern casing_suffix_context_t
0197        u8_casing_suffixes_context (const uint8_t *s, size_t n,
0198                                    casing_suffix_context_t a_context);
0199 extern casing_suffix_context_t
0200        u16_casing_suffixes_context (const uint16_t *s, size_t n,
0201                                     casing_suffix_context_t a_context);
0202 extern casing_suffix_context_t
0203        u32_casing_suffixes_context (const uint32_t *s, size_t n,
0204                                     casing_suffix_context_t a_context);
0205 
0206 /* Return the uppercase mapping of a string that is surrounded by a prefix
0207    and a suffix.  */
0208 extern uint8_t *
0209        u8_ct_toupper (const uint8_t *s, size_t n,
0210                       casing_prefix_context_t prefix_context,
0211                       casing_suffix_context_t suffix_context,
0212                       const char *iso639_language,
0213                       uninorm_t nf,
0214                       uint8_t *_UC_RESTRICT resultbuf, size_t *lengthp);
0215 extern uint16_t *
0216        u16_ct_toupper (const uint16_t *s, size_t n,
0217                       casing_prefix_context_t prefix_context,
0218                       casing_suffix_context_t suffix_context,
0219                       const char *iso639_language,
0220                       uninorm_t nf,
0221                       uint16_t *_UC_RESTRICT resultbuf, size_t *lengthp);
0222 extern uint32_t *
0223        u32_ct_toupper (const uint32_t *s, size_t n,
0224                       casing_prefix_context_t prefix_context,
0225                       casing_suffix_context_t suffix_context,
0226                       const char *iso639_language,
0227                       uninorm_t nf,
0228                       uint32_t *_UC_RESTRICT resultbuf, size_t *lengthp);
0229 
0230 /* Return the lowercase mapping of a string that is surrounded by a prefix
0231    and a suffix.  */
0232 extern uint8_t *
0233        u8_ct_tolower (const uint8_t *s, size_t n,
0234                       casing_prefix_context_t prefix_context,
0235                       casing_suffix_context_t suffix_context,
0236                       const char *iso639_language,
0237                       uninorm_t nf,
0238                       uint8_t *_UC_RESTRICT resultbuf, size_t *lengthp);
0239 extern uint16_t *
0240        u16_ct_tolower (const uint16_t *s, size_t n,
0241                       casing_prefix_context_t prefix_context,
0242                       casing_suffix_context_t suffix_context,
0243                       const char *iso639_language,
0244                       uninorm_t nf,
0245                       uint16_t *_UC_RESTRICT resultbuf, size_t *lengthp);
0246 extern uint32_t *
0247        u32_ct_tolower (const uint32_t *s, size_t n,
0248                       casing_prefix_context_t prefix_context,
0249                       casing_suffix_context_t suffix_context,
0250                       const char *iso639_language,
0251                       uninorm_t nf,
0252                       uint32_t *_UC_RESTRICT resultbuf, size_t *lengthp);
0253 
0254 /* Return the titlecase mapping of a string that is surrounded by a prefix
0255    and a suffix.  */
0256 extern uint8_t *
0257        u8_ct_totitle (const uint8_t *s, size_t n,
0258                       casing_prefix_context_t prefix_context,
0259                       casing_suffix_context_t suffix_context,
0260                       const char *iso639_language,
0261                       uninorm_t nf,
0262                       uint8_t *_UC_RESTRICT resultbuf, size_t *lengthp);
0263 extern uint16_t *
0264        u16_ct_totitle (const uint16_t *s, size_t n,
0265                       casing_prefix_context_t prefix_context,
0266                       casing_suffix_context_t suffix_context,
0267                       const char *iso639_language,
0268                       uninorm_t nf,
0269                       uint16_t *_UC_RESTRICT resultbuf, size_t *lengthp);
0270 extern uint32_t *
0271        u32_ct_totitle (const uint32_t *s, size_t n,
0272                       casing_prefix_context_t prefix_context,
0273                       casing_suffix_context_t suffix_context,
0274                       const char *iso639_language,
0275                       uninorm_t nf,
0276                       uint32_t *_UC_RESTRICT resultbuf, size_t *lengthp);
0277 
0278 /* Return the case folded string.
0279    Comparing uN_casefold (S1) and uN_casefold (S2) with uN_cmp2() is equivalent
0280    to comparing S1 and S2 with uN_casecmp().
0281    The nf argument identifies the normalization form to apply after the
0282    case-mapping.  It can also be NULL, for no normalization.  */
0283 extern uint8_t *
0284        u8_casefold (const uint8_t *s, size_t n, const char *iso639_language,
0285                     uninorm_t nf,
0286                     uint8_t *_UC_RESTRICT resultbuf, size_t *lengthp);
0287 extern uint16_t *
0288        u16_casefold (const uint16_t *s, size_t n, const char *iso639_language,
0289                      uninorm_t nf,
0290                      uint16_t *_UC_RESTRICT resultbuf, size_t *lengthp);
0291 extern uint32_t *
0292        u32_casefold (const uint32_t *s, size_t n, const char *iso639_language,
0293                      uninorm_t nf,
0294                      uint32_t *_UC_RESTRICT resultbuf, size_t *lengthp);
0295 /* Likewise, for a string that is surrounded by a prefix and a suffix.  */
0296 extern uint8_t *
0297        u8_ct_casefold (const uint8_t *s, size_t n,
0298                        casing_prefix_context_t prefix_context,
0299                        casing_suffix_context_t suffix_context,
0300                        const char *iso639_language,
0301                        uninorm_t nf,
0302                        uint8_t *_UC_RESTRICT resultbuf, size_t *lengthp);
0303 extern uint16_t *
0304        u16_ct_casefold (const uint16_t *s, size_t n,
0305                         casing_prefix_context_t prefix_context,
0306                         casing_suffix_context_t suffix_context,
0307                         const char *iso639_language,
0308                         uninorm_t nf,
0309                         uint16_t *_UC_RESTRICT resultbuf, size_t *lengthp);
0310 extern uint32_t *
0311        u32_ct_casefold (const uint32_t *s, size_t n,
0312                         casing_prefix_context_t prefix_context,
0313                         casing_suffix_context_t suffix_context,
0314                         const char *iso639_language,
0315                         uninorm_t nf,
0316                         uint32_t *_UC_RESTRICT resultbuf, size_t *lengthp);
0317 
0318 /* Compare S1 and S2, ignoring differences in case and normalization.
0319    The nf argument identifies the normalization form to apply after the
0320    case-mapping.  It can also be NULL, for no normalization.
0321    If successful, set *RESULTP to -1 if S1 < S2, 0 if S1 = S2, 1 if S1 > S2, and
0322    return 0.  Upon failure, return -1 with errno set.  */
0323 extern int
0324        u8_casecmp (const uint8_t *s1, size_t n1,
0325                    const uint8_t *s2, size_t n2,
0326                    const char *iso639_language, uninorm_t nf, int *resultp);
0327 extern int
0328        u16_casecmp (const uint16_t *s1, size_t n1,
0329                     const uint16_t *s2, size_t n2,
0330                     const char *iso639_language, uninorm_t nf, int *resultp);
0331 extern int
0332        u32_casecmp (const uint32_t *s1, size_t n1,
0333                     const uint32_t *s2, size_t n2,
0334                     const char *iso639_language, uninorm_t nf, int *resultp);
0335 extern int
0336        ulc_casecmp (const char *s1, size_t n1,
0337                     const char *s2, size_t n2,
0338                     const char *iso639_language, uninorm_t nf, int *resultp);
0339 
0340 /* Convert the string S of length N to a NUL-terminated byte sequence, in such
0341    a way that comparing uN_casexfrm (S1) and uN_casexfrm (S2) with the gnulib
0342    function memcmp2() is equivalent to comparing S1 and S2 with uN_casecoll().
0343    NF must be either UNINORM_NFC, UNINORM_NFKC, or NULL for no normalization.  */
0344 extern char *
0345        u8_casexfrm (const uint8_t *s, size_t n, const char *iso639_language,
0346                     uninorm_t nf,
0347                     char *_UC_RESTRICT resultbuf, size_t *lengthp);
0348 extern char *
0349        u16_casexfrm (const uint16_t *s, size_t n, const char *iso639_language,
0350                      uninorm_t nf,
0351                      char *_UC_RESTRICT resultbuf, size_t *lengthp);
0352 extern char *
0353        u32_casexfrm (const uint32_t *s, size_t n, const char *iso639_language,
0354                      uninorm_t nf,
0355                      char *_UC_RESTRICT resultbuf, size_t *lengthp);
0356 extern char *
0357        ulc_casexfrm (const char *s, size_t n, const char *iso639_language,
0358                      uninorm_t nf,
0359                      char *_UC_RESTRICT resultbuf, size_t *lengthp);
0360 
0361 /* Compare S1 and S2, ignoring differences in case and normalization, using the
0362    collation rules of the current locale.
0363    The nf argument identifies the normalization form to apply after the
0364    case-mapping.  It must be either UNINORM_NFC or UNINORM_NFKC.  It can also
0365    be NULL, for no normalization.
0366    If successful, set *RESULTP to -1 if S1 < S2, 0 if S1 = S2, 1 if S1 > S2, and
0367    return 0.  Upon failure, return -1 with errno set.  */
0368 extern int
0369        u8_casecoll (const uint8_t *s1, size_t n1,
0370                     const uint8_t *s2, size_t n2,
0371                     const char *iso639_language, uninorm_t nf, int *resultp);
0372 extern int
0373        u16_casecoll (const uint16_t *s1, size_t n1,
0374                      const uint16_t *s2, size_t n2,
0375                      const char *iso639_language, uninorm_t nf, int *resultp);
0376 extern int
0377        u32_casecoll (const uint32_t *s1, size_t n1,
0378                      const uint32_t *s2, size_t n2,
0379                      const char *iso639_language, uninorm_t nf, int *resultp);
0380 extern int
0381        ulc_casecoll (const char *s1, size_t n1,
0382                      const char *s2, size_t n2,
0383                      const char *iso639_language, uninorm_t nf, int *resultp);
0384 
0385 
0386 /* Set *RESULTP to true if mapping NFD(S) to upper case is a no-op, or to false
0387    otherwise, and return 0.  Upon failure, return -1 with errno set.  */
0388 extern int
0389        u8_is_uppercase (const uint8_t *s, size_t n,
0390                         const char *iso639_language,
0391                         bool *resultp);
0392 extern int
0393        u16_is_uppercase (const uint16_t *s, size_t n,
0394                          const char *iso639_language,
0395                          bool *resultp);
0396 extern int
0397        u32_is_uppercase (const uint32_t *s, size_t n,
0398                          const char *iso639_language,
0399                          bool *resultp);
0400 
0401 /* Set *RESULTP to true if mapping NFD(S) to lower case is a no-op, or to false
0402    otherwise, and return 0.  Upon failure, return -1 with errno set.  */
0403 extern int
0404        u8_is_lowercase (const uint8_t *s, size_t n,
0405                         const char *iso639_language,
0406                         bool *resultp);
0407 extern int
0408        u16_is_lowercase (const uint16_t *s, size_t n,
0409                          const char *iso639_language,
0410                          bool *resultp);
0411 extern int
0412        u32_is_lowercase (const uint32_t *s, size_t n,
0413                          const char *iso639_language,
0414                          bool *resultp);
0415 
0416 /* Set *RESULTP to true if mapping NFD(S) to title case is a no-op, or to false
0417    otherwise, and return 0.  Upon failure, return -1 with errno set.  */
0418 extern int
0419        u8_is_titlecase (const uint8_t *s, size_t n,
0420                         const char *iso639_language,
0421                         bool *resultp);
0422 extern int
0423        u16_is_titlecase (const uint16_t *s, size_t n,
0424                          const char *iso639_language,
0425                          bool *resultp);
0426 extern int
0427        u32_is_titlecase (const uint32_t *s, size_t n,
0428                          const char *iso639_language,
0429                          bool *resultp);
0430 
0431 /* Set *RESULTP to true if applying case folding to NFD(S) is a no-op, or to
0432    false otherwise, and return 0.  Upon failure, return -1 with errno set.  */
0433 extern int
0434        u8_is_casefolded (const uint8_t *s, size_t n,
0435                          const char *iso639_language,
0436                          bool *resultp);
0437 extern int
0438        u16_is_casefolded (const uint16_t *s, size_t n,
0439                           const char *iso639_language,
0440                           bool *resultp);
0441 extern int
0442        u32_is_casefolded (const uint32_t *s, size_t n,
0443                           const char *iso639_language,
0444                           bool *resultp);
0445 
0446 /* Set *RESULTP to true if case matters for S, that is, if mapping NFD(S) to
0447    either upper case or lower case or title case is not a no-op.
0448    Set *RESULTP to false if NFD(S) maps to itself under the upper case mapping,
0449    under the lower case mapping, and under the title case mapping; in other
0450    words, when NFD(S) consists entirely of caseless characters.
0451    Upon failure, return -1 with errno set.  */
0452 extern int
0453        u8_is_cased (const uint8_t *s, size_t n,
0454                     const char *iso639_language,
0455                     bool *resultp);
0456 extern int
0457        u16_is_cased (const uint16_t *s, size_t n,
0458                      const char *iso639_language,
0459                      bool *resultp);
0460 extern int
0461        u32_is_cased (const uint32_t *s, size_t n,
0462                      const char *iso639_language,
0463                      bool *resultp);
0464 
0465 
0466 /* ========================================================================= */
0467 
0468 #ifdef __cplusplus
0469 }
0470 #endif
0471 
0472 #endif /* _UNICASE_H */