1*0e209d39SAndroid Build Coastguard Worker // © 2016 and later: Unicode, Inc. and others. 2*0e209d39SAndroid Build Coastguard Worker // License & terms of use: http://www.unicode.org/copyright.html 3*0e209d39SAndroid Build Coastguard Worker /* 4*0e209d39SAndroid Build Coastguard Worker ******************************************************************************* 5*0e209d39SAndroid Build Coastguard Worker * 6*0e209d39SAndroid Build Coastguard Worker * Copyright (C) 2005-2012, International Business Machines 7*0e209d39SAndroid Build Coastguard Worker * Corporation and others. All Rights Reserved. 8*0e209d39SAndroid Build Coastguard Worker * 9*0e209d39SAndroid Build Coastguard Worker ******************************************************************************* 10*0e209d39SAndroid Build Coastguard Worker * file name: ucasemap.h 11*0e209d39SAndroid Build Coastguard Worker * encoding: UTF-8 12*0e209d39SAndroid Build Coastguard Worker * tab size: 8 (not used) 13*0e209d39SAndroid Build Coastguard Worker * indentation:4 14*0e209d39SAndroid Build Coastguard Worker * 15*0e209d39SAndroid Build Coastguard Worker * created on: 2005may06 16*0e209d39SAndroid Build Coastguard Worker * created by: Markus W. Scherer 17*0e209d39SAndroid Build Coastguard Worker * 18*0e209d39SAndroid Build Coastguard Worker * Case mapping service object and functions using it. 19*0e209d39SAndroid Build Coastguard Worker */ 20*0e209d39SAndroid Build Coastguard Worker 21*0e209d39SAndroid Build Coastguard Worker #ifndef __UCASEMAP_H__ 22*0e209d39SAndroid Build Coastguard Worker #define __UCASEMAP_H__ 23*0e209d39SAndroid Build Coastguard Worker 24*0e209d39SAndroid Build Coastguard Worker #include "unicode/utypes.h" 25*0e209d39SAndroid Build Coastguard Worker #include "unicode/stringoptions.h" 26*0e209d39SAndroid Build Coastguard Worker #include "unicode/ustring.h" 27*0e209d39SAndroid Build Coastguard Worker 28*0e209d39SAndroid Build Coastguard Worker #if U_SHOW_CPLUSPLUS_API 29*0e209d39SAndroid Build Coastguard Worker #include "unicode/localpointer.h" 30*0e209d39SAndroid Build Coastguard Worker #endif // U_SHOW_CPLUSPLUS_API 31*0e209d39SAndroid Build Coastguard Worker 32*0e209d39SAndroid Build Coastguard Worker /** 33*0e209d39SAndroid Build Coastguard Worker * \file 34*0e209d39SAndroid Build Coastguard Worker * \brief C API: Unicode case mapping functions using a UCaseMap service object. 35*0e209d39SAndroid Build Coastguard Worker * 36*0e209d39SAndroid Build Coastguard Worker * The service object takes care of memory allocations, data loading, and setup 37*0e209d39SAndroid Build Coastguard Worker * for the attributes, as usual. 38*0e209d39SAndroid Build Coastguard Worker * 39*0e209d39SAndroid Build Coastguard Worker * Currently, the functionality provided here does not overlap with uchar.h 40*0e209d39SAndroid Build Coastguard Worker * and ustring.h, except for ucasemap_toTitle(). 41*0e209d39SAndroid Build Coastguard Worker * 42*0e209d39SAndroid Build Coastguard Worker * ucasemap_utf8XYZ() functions operate directly on UTF-8 strings. 43*0e209d39SAndroid Build Coastguard Worker */ 44*0e209d39SAndroid Build Coastguard Worker 45*0e209d39SAndroid Build Coastguard Worker /** 46*0e209d39SAndroid Build Coastguard Worker * UCaseMap is an opaque service object for newer ICU case mapping functions. 47*0e209d39SAndroid Build Coastguard Worker * Older functions did not use a service object. 48*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.4 49*0e209d39SAndroid Build Coastguard Worker */ 50*0e209d39SAndroid Build Coastguard Worker struct UCaseMap; 51*0e209d39SAndroid Build Coastguard Worker typedef struct UCaseMap UCaseMap; /**< C typedef for struct UCaseMap. @stable ICU 3.4 */ 52*0e209d39SAndroid Build Coastguard Worker 53*0e209d39SAndroid Build Coastguard Worker /** 54*0e209d39SAndroid Build Coastguard Worker * Open a UCaseMap service object for a locale and a set of options. 55*0e209d39SAndroid Build Coastguard Worker * The locale ID and options are preprocessed so that functions using the 56*0e209d39SAndroid Build Coastguard Worker * service object need not process them in each call. 57*0e209d39SAndroid Build Coastguard Worker * 58*0e209d39SAndroid Build Coastguard Worker * @param locale ICU locale ID, used for language-dependent 59*0e209d39SAndroid Build Coastguard Worker * upper-/lower-/title-casing according to the Unicode standard. 60*0e209d39SAndroid Build Coastguard Worker * Usual semantics: ""=root, NULL=default locale, etc. 61*0e209d39SAndroid Build Coastguard Worker * @param options Options bit set, used for case folding and string comparisons. 62*0e209d39SAndroid Build Coastguard Worker * Same flags as for u_foldCase(), u_strFoldCase(), 63*0e209d39SAndroid Build Coastguard Worker * u_strCaseCompare(), etc. 64*0e209d39SAndroid Build Coastguard Worker * Use 0 or U_FOLD_CASE_DEFAULT for default behavior. 65*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Must be a valid pointer to an error code value, 66*0e209d39SAndroid Build Coastguard Worker * which must not indicate a failure before the function call. 67*0e209d39SAndroid Build Coastguard Worker * @return Pointer to a UCaseMap service object, if successful. 68*0e209d39SAndroid Build Coastguard Worker * 69*0e209d39SAndroid Build Coastguard Worker * @see U_FOLD_CASE_DEFAULT 70*0e209d39SAndroid Build Coastguard Worker * @see U_FOLD_CASE_EXCLUDE_SPECIAL_I 71*0e209d39SAndroid Build Coastguard Worker * @see U_TITLECASE_NO_LOWERCASE 72*0e209d39SAndroid Build Coastguard Worker * @see U_TITLECASE_NO_BREAK_ADJUSTMENT 73*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.4 74*0e209d39SAndroid Build Coastguard Worker */ 75*0e209d39SAndroid Build Coastguard Worker U_CAPI UCaseMap * U_EXPORT2 76*0e209d39SAndroid Build Coastguard Worker ucasemap_open(const char *locale, uint32_t options, UErrorCode *pErrorCode); 77*0e209d39SAndroid Build Coastguard Worker 78*0e209d39SAndroid Build Coastguard Worker /** 79*0e209d39SAndroid Build Coastguard Worker * Close a UCaseMap service object. 80*0e209d39SAndroid Build Coastguard Worker * @param csm Object to be closed. 81*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.4 82*0e209d39SAndroid Build Coastguard Worker */ 83*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 84*0e209d39SAndroid Build Coastguard Worker ucasemap_close(UCaseMap *csm); 85*0e209d39SAndroid Build Coastguard Worker 86*0e209d39SAndroid Build Coastguard Worker #if U_SHOW_CPLUSPLUS_API 87*0e209d39SAndroid Build Coastguard Worker 88*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_BEGIN 89*0e209d39SAndroid Build Coastguard Worker 90*0e209d39SAndroid Build Coastguard Worker /** 91*0e209d39SAndroid Build Coastguard Worker * \class LocalUCaseMapPointer 92*0e209d39SAndroid Build Coastguard Worker * "Smart pointer" class, closes a UCaseMap via ucasemap_close(). 93*0e209d39SAndroid Build Coastguard Worker * For most methods see the LocalPointerBase base class. 94*0e209d39SAndroid Build Coastguard Worker * 95*0e209d39SAndroid Build Coastguard Worker * @see LocalPointerBase 96*0e209d39SAndroid Build Coastguard Worker * @see LocalPointer 97*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.4 98*0e209d39SAndroid Build Coastguard Worker */ 99*0e209d39SAndroid Build Coastguard Worker U_DEFINE_LOCAL_OPEN_POINTER(LocalUCaseMapPointer, UCaseMap, ucasemap_close); 100*0e209d39SAndroid Build Coastguard Worker 101*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_END 102*0e209d39SAndroid Build Coastguard Worker 103*0e209d39SAndroid Build Coastguard Worker #endif 104*0e209d39SAndroid Build Coastguard Worker 105*0e209d39SAndroid Build Coastguard Worker /** 106*0e209d39SAndroid Build Coastguard Worker * Get the locale ID that is used for language-dependent case mappings. 107*0e209d39SAndroid Build Coastguard Worker * @param csm UCaseMap service object. 108*0e209d39SAndroid Build Coastguard Worker * @return locale ID 109*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.4 110*0e209d39SAndroid Build Coastguard Worker */ 111*0e209d39SAndroid Build Coastguard Worker U_CAPI const char * U_EXPORT2 112*0e209d39SAndroid Build Coastguard Worker ucasemap_getLocale(const UCaseMap *csm); 113*0e209d39SAndroid Build Coastguard Worker 114*0e209d39SAndroid Build Coastguard Worker /** 115*0e209d39SAndroid Build Coastguard Worker * Get the options bit set that is used for case folding and string comparisons. 116*0e209d39SAndroid Build Coastguard Worker * @param csm UCaseMap service object. 117*0e209d39SAndroid Build Coastguard Worker * @return options bit set 118*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.4 119*0e209d39SAndroid Build Coastguard Worker */ 120*0e209d39SAndroid Build Coastguard Worker U_CAPI uint32_t U_EXPORT2 121*0e209d39SAndroid Build Coastguard Worker ucasemap_getOptions(const UCaseMap *csm); 122*0e209d39SAndroid Build Coastguard Worker 123*0e209d39SAndroid Build Coastguard Worker /** 124*0e209d39SAndroid Build Coastguard Worker * Set the locale ID that is used for language-dependent case mappings. 125*0e209d39SAndroid Build Coastguard Worker * 126*0e209d39SAndroid Build Coastguard Worker * @param csm UCaseMap service object. 127*0e209d39SAndroid Build Coastguard Worker * @param locale Locale ID, see ucasemap_open(). 128*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Must be a valid pointer to an error code value, 129*0e209d39SAndroid Build Coastguard Worker * which must not indicate a failure before the function call. 130*0e209d39SAndroid Build Coastguard Worker * 131*0e209d39SAndroid Build Coastguard Worker * @see ucasemap_open 132*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.4 133*0e209d39SAndroid Build Coastguard Worker */ 134*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 135*0e209d39SAndroid Build Coastguard Worker ucasemap_setLocale(UCaseMap *csm, const char *locale, UErrorCode *pErrorCode); 136*0e209d39SAndroid Build Coastguard Worker 137*0e209d39SAndroid Build Coastguard Worker /** 138*0e209d39SAndroid Build Coastguard Worker * Set the options bit set that is used for case folding and string comparisons. 139*0e209d39SAndroid Build Coastguard Worker * 140*0e209d39SAndroid Build Coastguard Worker * @param csm UCaseMap service object. 141*0e209d39SAndroid Build Coastguard Worker * @param options Options bit set, see ucasemap_open(). 142*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Must be a valid pointer to an error code value, 143*0e209d39SAndroid Build Coastguard Worker * which must not indicate a failure before the function call. 144*0e209d39SAndroid Build Coastguard Worker * 145*0e209d39SAndroid Build Coastguard Worker * @see ucasemap_open 146*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.4 147*0e209d39SAndroid Build Coastguard Worker */ 148*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 149*0e209d39SAndroid Build Coastguard Worker ucasemap_setOptions(UCaseMap *csm, uint32_t options, UErrorCode *pErrorCode); 150*0e209d39SAndroid Build Coastguard Worker 151*0e209d39SAndroid Build Coastguard Worker #if !UCONFIG_NO_BREAK_ITERATION 152*0e209d39SAndroid Build Coastguard Worker 153*0e209d39SAndroid Build Coastguard Worker /** 154*0e209d39SAndroid Build Coastguard Worker * Get the break iterator that is used for titlecasing. 155*0e209d39SAndroid Build Coastguard Worker * Do not modify the returned break iterator. 156*0e209d39SAndroid Build Coastguard Worker * @param csm UCaseMap service object. 157*0e209d39SAndroid Build Coastguard Worker * @return titlecasing break iterator 158*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 159*0e209d39SAndroid Build Coastguard Worker */ 160*0e209d39SAndroid Build Coastguard Worker U_CAPI const UBreakIterator * U_EXPORT2 161*0e209d39SAndroid Build Coastguard Worker ucasemap_getBreakIterator(const UCaseMap *csm); 162*0e209d39SAndroid Build Coastguard Worker 163*0e209d39SAndroid Build Coastguard Worker /** 164*0e209d39SAndroid Build Coastguard Worker * Set the break iterator that is used for titlecasing. 165*0e209d39SAndroid Build Coastguard Worker * The UCaseMap service object releases a previously set break iterator 166*0e209d39SAndroid Build Coastguard Worker * and "adopts" this new one, taking ownership of it. 167*0e209d39SAndroid Build Coastguard Worker * It will be released in a subsequent call to ucasemap_setBreakIterator() 168*0e209d39SAndroid Build Coastguard Worker * or ucasemap_close(). 169*0e209d39SAndroid Build Coastguard Worker * 170*0e209d39SAndroid Build Coastguard Worker * Break iterator operations are not thread-safe. Therefore, titlecasing 171*0e209d39SAndroid Build Coastguard Worker * functions use non-const UCaseMap objects. It is not possible to titlecase 172*0e209d39SAndroid Build Coastguard Worker * strings concurrently using the same UCaseMap. 173*0e209d39SAndroid Build Coastguard Worker * 174*0e209d39SAndroid Build Coastguard Worker * @param csm UCaseMap service object. 175*0e209d39SAndroid Build Coastguard Worker * @param iterToAdopt Break iterator to be adopted for titlecasing. 176*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Must be a valid pointer to an error code value, 177*0e209d39SAndroid Build Coastguard Worker * which must not indicate a failure before the function call. 178*0e209d39SAndroid Build Coastguard Worker * 179*0e209d39SAndroid Build Coastguard Worker * @see ucasemap_toTitle 180*0e209d39SAndroid Build Coastguard Worker * @see ucasemap_utf8ToTitle 181*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 182*0e209d39SAndroid Build Coastguard Worker */ 183*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 184*0e209d39SAndroid Build Coastguard Worker ucasemap_setBreakIterator(UCaseMap *csm, UBreakIterator *iterToAdopt, UErrorCode *pErrorCode); 185*0e209d39SAndroid Build Coastguard Worker 186*0e209d39SAndroid Build Coastguard Worker /** 187*0e209d39SAndroid Build Coastguard Worker * Titlecase a UTF-16 string. This function is almost a duplicate of u_strToTitle(), 188*0e209d39SAndroid Build Coastguard Worker * except that it takes ucasemap_setOptions() into account and has performance 189*0e209d39SAndroid Build Coastguard Worker * advantages from being able to use a UCaseMap object for multiple case mapping 190*0e209d39SAndroid Build Coastguard Worker * operations, saving setup time. 191*0e209d39SAndroid Build Coastguard Worker * 192*0e209d39SAndroid Build Coastguard Worker * Casing is locale-dependent and context-sensitive. 193*0e209d39SAndroid Build Coastguard Worker * Titlecasing uses a break iterator to find the first characters of words 194*0e209d39SAndroid Build Coastguard Worker * that are to be titlecased. It titlecases those characters and lowercases 195*0e209d39SAndroid Build Coastguard Worker * all others. (This can be modified with ucasemap_setOptions().) 196*0e209d39SAndroid Build Coastguard Worker * 197*0e209d39SAndroid Build Coastguard Worker * Note: This function takes a non-const UCaseMap pointer because it will 198*0e209d39SAndroid Build Coastguard Worker * open a default break iterator if no break iterator was set yet, 199*0e209d39SAndroid Build Coastguard Worker * and effectively call ucasemap_setBreakIterator(); 200*0e209d39SAndroid Build Coastguard Worker * also because the break iterator is stateful and will be modified during 201*0e209d39SAndroid Build Coastguard Worker * the iteration. 202*0e209d39SAndroid Build Coastguard Worker * 203*0e209d39SAndroid Build Coastguard Worker * The titlecase break iterator can be provided to customize for arbitrary 204*0e209d39SAndroid Build Coastguard Worker * styles, using rules and dictionaries beyond the standard iterators. 205*0e209d39SAndroid Build Coastguard Worker * The standard titlecase iterator for the root locale implements the 206*0e209d39SAndroid Build Coastguard Worker * algorithm of Unicode TR 21. 207*0e209d39SAndroid Build Coastguard Worker * 208*0e209d39SAndroid Build Coastguard Worker * This function uses only the setText(), first() and next() methods of the 209*0e209d39SAndroid Build Coastguard Worker * provided break iterator. 210*0e209d39SAndroid Build Coastguard Worker * 211*0e209d39SAndroid Build Coastguard Worker * The result may be longer or shorter than the original. 212*0e209d39SAndroid Build Coastguard Worker * The source string and the destination buffer must not overlap. 213*0e209d39SAndroid Build Coastguard Worker * 214*0e209d39SAndroid Build Coastguard Worker * @param csm UCaseMap service object. This pointer is non-const! 215*0e209d39SAndroid Build Coastguard Worker * See the note above for details. 216*0e209d39SAndroid Build Coastguard Worker * @param dest A buffer for the result string. The result will be NUL-terminated if 217*0e209d39SAndroid Build Coastguard Worker * the buffer is large enough. 218*0e209d39SAndroid Build Coastguard Worker * The contents is undefined in case of failure. 219*0e209d39SAndroid Build Coastguard Worker * @param destCapacity The size of the buffer (number of UChars). If it is 0, then 220*0e209d39SAndroid Build Coastguard Worker * dest may be NULL and the function will only return the length of the result 221*0e209d39SAndroid Build Coastguard Worker * without writing any of the result string. 222*0e209d39SAndroid Build Coastguard Worker * @param src The original string. 223*0e209d39SAndroid Build Coastguard Worker * @param srcLength The length of the original string. If -1, then src must be NUL-terminated. 224*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Must be a valid pointer to an error code value, 225*0e209d39SAndroid Build Coastguard Worker * which must not indicate a failure before the function call. 226*0e209d39SAndroid Build Coastguard Worker * @return The length of the result string, if successful - or in case of a buffer overflow, 227*0e209d39SAndroid Build Coastguard Worker * in which case it will be greater than destCapacity. 228*0e209d39SAndroid Build Coastguard Worker * 229*0e209d39SAndroid Build Coastguard Worker * @see u_strToTitle 230*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 231*0e209d39SAndroid Build Coastguard Worker */ 232*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 233*0e209d39SAndroid Build Coastguard Worker ucasemap_toTitle(UCaseMap *csm, 234*0e209d39SAndroid Build Coastguard Worker UChar *dest, int32_t destCapacity, 235*0e209d39SAndroid Build Coastguard Worker const UChar *src, int32_t srcLength, 236*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode); 237*0e209d39SAndroid Build Coastguard Worker 238*0e209d39SAndroid Build Coastguard Worker #endif // UCONFIG_NO_BREAK_ITERATION 239*0e209d39SAndroid Build Coastguard Worker 240*0e209d39SAndroid Build Coastguard Worker /** 241*0e209d39SAndroid Build Coastguard Worker * Lowercase the characters in a UTF-8 string. 242*0e209d39SAndroid Build Coastguard Worker * Casing is locale-dependent and context-sensitive. 243*0e209d39SAndroid Build Coastguard Worker * The result may be longer or shorter than the original. 244*0e209d39SAndroid Build Coastguard Worker * The source string and the destination buffer must not overlap. 245*0e209d39SAndroid Build Coastguard Worker * 246*0e209d39SAndroid Build Coastguard Worker * @param csm UCaseMap service object. 247*0e209d39SAndroid Build Coastguard Worker * @param dest A buffer for the result string. The result will be NUL-terminated if 248*0e209d39SAndroid Build Coastguard Worker * the buffer is large enough. 249*0e209d39SAndroid Build Coastguard Worker * The contents is undefined in case of failure. 250*0e209d39SAndroid Build Coastguard Worker * @param destCapacity The size of the buffer (number of bytes). If it is 0, then 251*0e209d39SAndroid Build Coastguard Worker * dest may be NULL and the function will only return the length of the result 252*0e209d39SAndroid Build Coastguard Worker * without writing any of the result string. 253*0e209d39SAndroid Build Coastguard Worker * @param src The original string. 254*0e209d39SAndroid Build Coastguard Worker * @param srcLength The length of the original string. If -1, then src must be NUL-terminated. 255*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Must be a valid pointer to an error code value, 256*0e209d39SAndroid Build Coastguard Worker * which must not indicate a failure before the function call. 257*0e209d39SAndroid Build Coastguard Worker * @return The length of the result string, if successful - or in case of a buffer overflow, 258*0e209d39SAndroid Build Coastguard Worker * in which case it will be greater than destCapacity. 259*0e209d39SAndroid Build Coastguard Worker * 260*0e209d39SAndroid Build Coastguard Worker * @see u_strToLower 261*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.4 262*0e209d39SAndroid Build Coastguard Worker */ 263*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 264*0e209d39SAndroid Build Coastguard Worker ucasemap_utf8ToLower(const UCaseMap *csm, 265*0e209d39SAndroid Build Coastguard Worker char *dest, int32_t destCapacity, 266*0e209d39SAndroid Build Coastguard Worker const char *src, int32_t srcLength, 267*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode); 268*0e209d39SAndroid Build Coastguard Worker 269*0e209d39SAndroid Build Coastguard Worker /** 270*0e209d39SAndroid Build Coastguard Worker * Uppercase the characters in a UTF-8 string. 271*0e209d39SAndroid Build Coastguard Worker * Casing is locale-dependent and context-sensitive. 272*0e209d39SAndroid Build Coastguard Worker * The result may be longer or shorter than the original. 273*0e209d39SAndroid Build Coastguard Worker * The source string and the destination buffer must not overlap. 274*0e209d39SAndroid Build Coastguard Worker * 275*0e209d39SAndroid Build Coastguard Worker * @param csm UCaseMap service object. 276*0e209d39SAndroid Build Coastguard Worker * @param dest A buffer for the result string. The result will be NUL-terminated if 277*0e209d39SAndroid Build Coastguard Worker * the buffer is large enough. 278*0e209d39SAndroid Build Coastguard Worker * The contents is undefined in case of failure. 279*0e209d39SAndroid Build Coastguard Worker * @param destCapacity The size of the buffer (number of bytes). If it is 0, then 280*0e209d39SAndroid Build Coastguard Worker * dest may be NULL and the function will only return the length of the result 281*0e209d39SAndroid Build Coastguard Worker * without writing any of the result string. 282*0e209d39SAndroid Build Coastguard Worker * @param src The original string. 283*0e209d39SAndroid Build Coastguard Worker * @param srcLength The length of the original string. If -1, then src must be NUL-terminated. 284*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Must be a valid pointer to an error code value, 285*0e209d39SAndroid Build Coastguard Worker * which must not indicate a failure before the function call. 286*0e209d39SAndroid Build Coastguard Worker * @return The length of the result string, if successful - or in case of a buffer overflow, 287*0e209d39SAndroid Build Coastguard Worker * in which case it will be greater than destCapacity. 288*0e209d39SAndroid Build Coastguard Worker * 289*0e209d39SAndroid Build Coastguard Worker * @see u_strToUpper 290*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.4 291*0e209d39SAndroid Build Coastguard Worker */ 292*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 293*0e209d39SAndroid Build Coastguard Worker ucasemap_utf8ToUpper(const UCaseMap *csm, 294*0e209d39SAndroid Build Coastguard Worker char *dest, int32_t destCapacity, 295*0e209d39SAndroid Build Coastguard Worker const char *src, int32_t srcLength, 296*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode); 297*0e209d39SAndroid Build Coastguard Worker 298*0e209d39SAndroid Build Coastguard Worker #if !UCONFIG_NO_BREAK_ITERATION 299*0e209d39SAndroid Build Coastguard Worker 300*0e209d39SAndroid Build Coastguard Worker /** 301*0e209d39SAndroid Build Coastguard Worker * Titlecase a UTF-8 string. 302*0e209d39SAndroid Build Coastguard Worker * Casing is locale-dependent and context-sensitive. 303*0e209d39SAndroid Build Coastguard Worker * Titlecasing uses a break iterator to find the first characters of words 304*0e209d39SAndroid Build Coastguard Worker * that are to be titlecased. It titlecases those characters and lowercases 305*0e209d39SAndroid Build Coastguard Worker * all others. (This can be modified with ucasemap_setOptions().) 306*0e209d39SAndroid Build Coastguard Worker * 307*0e209d39SAndroid Build Coastguard Worker * Note: This function takes a non-const UCaseMap pointer because it will 308*0e209d39SAndroid Build Coastguard Worker * open a default break iterator if no break iterator was set yet, 309*0e209d39SAndroid Build Coastguard Worker * and effectively call ucasemap_setBreakIterator(); 310*0e209d39SAndroid Build Coastguard Worker * also because the break iterator is stateful and will be modified during 311*0e209d39SAndroid Build Coastguard Worker * the iteration. 312*0e209d39SAndroid Build Coastguard Worker * 313*0e209d39SAndroid Build Coastguard Worker * The titlecase break iterator can be provided to customize for arbitrary 314*0e209d39SAndroid Build Coastguard Worker * styles, using rules and dictionaries beyond the standard iterators. 315*0e209d39SAndroid Build Coastguard Worker * The standard titlecase iterator for the root locale implements the 316*0e209d39SAndroid Build Coastguard Worker * algorithm of Unicode TR 21. 317*0e209d39SAndroid Build Coastguard Worker * 318*0e209d39SAndroid Build Coastguard Worker * This function uses only the setUText(), first(), next() and close() methods of the 319*0e209d39SAndroid Build Coastguard Worker * provided break iterator. 320*0e209d39SAndroid Build Coastguard Worker * 321*0e209d39SAndroid Build Coastguard Worker * The result may be longer or shorter than the original. 322*0e209d39SAndroid Build Coastguard Worker * The source string and the destination buffer must not overlap. 323*0e209d39SAndroid Build Coastguard Worker * 324*0e209d39SAndroid Build Coastguard Worker * @param csm UCaseMap service object. This pointer is non-const! 325*0e209d39SAndroid Build Coastguard Worker * See the note above for details. 326*0e209d39SAndroid Build Coastguard Worker * @param dest A buffer for the result string. The result will be NUL-terminated if 327*0e209d39SAndroid Build Coastguard Worker * the buffer is large enough. 328*0e209d39SAndroid Build Coastguard Worker * The contents is undefined in case of failure. 329*0e209d39SAndroid Build Coastguard Worker * @param destCapacity The size of the buffer (number of bytes). If it is 0, then 330*0e209d39SAndroid Build Coastguard Worker * dest may be NULL and the function will only return the length of the result 331*0e209d39SAndroid Build Coastguard Worker * without writing any of the result string. 332*0e209d39SAndroid Build Coastguard Worker * @param src The original string. 333*0e209d39SAndroid Build Coastguard Worker * @param srcLength The length of the original string. If -1, then src must be NUL-terminated. 334*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Must be a valid pointer to an error code value, 335*0e209d39SAndroid Build Coastguard Worker * which must not indicate a failure before the function call. 336*0e209d39SAndroid Build Coastguard Worker * @return The length of the result string, if successful - or in case of a buffer overflow, 337*0e209d39SAndroid Build Coastguard Worker * in which case it will be greater than destCapacity. 338*0e209d39SAndroid Build Coastguard Worker * 339*0e209d39SAndroid Build Coastguard Worker * @see u_strToTitle 340*0e209d39SAndroid Build Coastguard Worker * @see U_TITLECASE_NO_LOWERCASE 341*0e209d39SAndroid Build Coastguard Worker * @see U_TITLECASE_NO_BREAK_ADJUSTMENT 342*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 343*0e209d39SAndroid Build Coastguard Worker */ 344*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 345*0e209d39SAndroid Build Coastguard Worker ucasemap_utf8ToTitle(UCaseMap *csm, 346*0e209d39SAndroid Build Coastguard Worker char *dest, int32_t destCapacity, 347*0e209d39SAndroid Build Coastguard Worker const char *src, int32_t srcLength, 348*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode); 349*0e209d39SAndroid Build Coastguard Worker 350*0e209d39SAndroid Build Coastguard Worker #endif 351*0e209d39SAndroid Build Coastguard Worker 352*0e209d39SAndroid Build Coastguard Worker /** 353*0e209d39SAndroid Build Coastguard Worker * Case-folds the characters in a UTF-8 string. 354*0e209d39SAndroid Build Coastguard Worker * 355*0e209d39SAndroid Build Coastguard Worker * Case-folding is locale-independent and not context-sensitive, 356*0e209d39SAndroid Build Coastguard Worker * but there is an option for whether to include or exclude mappings for dotted I 357*0e209d39SAndroid Build Coastguard Worker * and dotless i that are marked with 'T' in CaseFolding.txt. 358*0e209d39SAndroid Build Coastguard Worker * 359*0e209d39SAndroid Build Coastguard Worker * The result may be longer or shorter than the original. 360*0e209d39SAndroid Build Coastguard Worker * The source string and the destination buffer must not overlap. 361*0e209d39SAndroid Build Coastguard Worker * 362*0e209d39SAndroid Build Coastguard Worker * @param csm UCaseMap service object. 363*0e209d39SAndroid Build Coastguard Worker * @param dest A buffer for the result string. The result will be NUL-terminated if 364*0e209d39SAndroid Build Coastguard Worker * the buffer is large enough. 365*0e209d39SAndroid Build Coastguard Worker * The contents is undefined in case of failure. 366*0e209d39SAndroid Build Coastguard Worker * @param destCapacity The size of the buffer (number of bytes). If it is 0, then 367*0e209d39SAndroid Build Coastguard Worker * dest may be NULL and the function will only return the length of the result 368*0e209d39SAndroid Build Coastguard Worker * without writing any of the result string. 369*0e209d39SAndroid Build Coastguard Worker * @param src The original string. 370*0e209d39SAndroid Build Coastguard Worker * @param srcLength The length of the original string. If -1, then src must be NUL-terminated. 371*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Must be a valid pointer to an error code value, 372*0e209d39SAndroid Build Coastguard Worker * which must not indicate a failure before the function call. 373*0e209d39SAndroid Build Coastguard Worker * @return The length of the result string, if successful - or in case of a buffer overflow, 374*0e209d39SAndroid Build Coastguard Worker * in which case it will be greater than destCapacity. 375*0e209d39SAndroid Build Coastguard Worker * 376*0e209d39SAndroid Build Coastguard Worker * @see u_strFoldCase 377*0e209d39SAndroid Build Coastguard Worker * @see ucasemap_setOptions 378*0e209d39SAndroid Build Coastguard Worker * @see U_FOLD_CASE_DEFAULT 379*0e209d39SAndroid Build Coastguard Worker * @see U_FOLD_CASE_EXCLUDE_SPECIAL_I 380*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.8 381*0e209d39SAndroid Build Coastguard Worker */ 382*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 383*0e209d39SAndroid Build Coastguard Worker ucasemap_utf8FoldCase(const UCaseMap *csm, 384*0e209d39SAndroid Build Coastguard Worker char *dest, int32_t destCapacity, 385*0e209d39SAndroid Build Coastguard Worker const char *src, int32_t srcLength, 386*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode); 387*0e209d39SAndroid Build Coastguard Worker 388*0e209d39SAndroid Build Coastguard Worker #endif 389