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 * Copyright (c) 1996-2015, International Business Machines Corporation and others. 6*0e209d39SAndroid Build Coastguard Worker * All Rights Reserved. 7*0e209d39SAndroid Build Coastguard Worker ******************************************************************************* 8*0e209d39SAndroid Build Coastguard Worker */ 9*0e209d39SAndroid Build Coastguard Worker 10*0e209d39SAndroid Build Coastguard Worker #ifndef UCOL_H 11*0e209d39SAndroid Build Coastguard Worker #define UCOL_H 12*0e209d39SAndroid Build Coastguard Worker 13*0e209d39SAndroid Build Coastguard Worker #include "unicode/utypes.h" 14*0e209d39SAndroid Build Coastguard Worker 15*0e209d39SAndroid Build Coastguard Worker #if !UCONFIG_NO_COLLATION 16*0e209d39SAndroid Build Coastguard Worker 17*0e209d39SAndroid Build Coastguard Worker #include "unicode/parseerr.h" 18*0e209d39SAndroid Build Coastguard Worker #include "unicode/uloc.h" 19*0e209d39SAndroid Build Coastguard Worker #include "unicode/uscript.h" 20*0e209d39SAndroid Build Coastguard Worker 21*0e209d39SAndroid Build Coastguard Worker #if U_SHOW_CPLUSPLUS_API 22*0e209d39SAndroid Build Coastguard Worker #include "unicode/localpointer.h" 23*0e209d39SAndroid Build Coastguard Worker #endif // U_SHOW_CPLUSPLUS_API 24*0e209d39SAndroid Build Coastguard Worker 25*0e209d39SAndroid Build Coastguard Worker /** 26*0e209d39SAndroid Build Coastguard Worker * @addtogroup icu4c ICU4C 27*0e209d39SAndroid Build Coastguard Worker * @{ 28*0e209d39SAndroid Build Coastguard Worker * \file 29*0e209d39SAndroid Build Coastguard Worker * \brief C API: Collator 30*0e209d39SAndroid Build Coastguard Worker * 31*0e209d39SAndroid Build Coastguard Worker * <h2> Collator C API </h2> 32*0e209d39SAndroid Build Coastguard Worker * 33*0e209d39SAndroid Build Coastguard Worker * The C API for Collator performs locale-sensitive 34*0e209d39SAndroid Build Coastguard Worker * string comparison. You use this service to build 35*0e209d39SAndroid Build Coastguard Worker * searching and sorting routines for natural language text. 36*0e209d39SAndroid Build Coastguard Worker * <p> 37*0e209d39SAndroid Build Coastguard Worker * For more information about the collation service see 38*0e209d39SAndroid Build Coastguard Worker * <a href="https://unicode-org.github.io/icu/userguide/collation">the User Guide</a>. 39*0e209d39SAndroid Build Coastguard Worker * <p> 40*0e209d39SAndroid Build Coastguard Worker * Collation service provides correct sorting orders for most locales supported in ICU. 41*0e209d39SAndroid Build Coastguard Worker * If specific data for a locale is not available, the orders eventually falls back 42*0e209d39SAndroid Build Coastguard Worker * to the <a href="http://www.unicode.org/reports/tr35/tr35-collation.html#Root_Collation">CLDR root sort order</a>. 43*0e209d39SAndroid Build Coastguard Worker * <p> 44*0e209d39SAndroid Build Coastguard Worker * Sort ordering may be customized by providing your own set of rules. For more on 45*0e209d39SAndroid Build Coastguard Worker * this subject see the <a href="https://unicode-org.github.io/icu/userguide/collation/customization"> 46*0e209d39SAndroid Build Coastguard Worker * Collation Customization</a> section of the User Guide. 47*0e209d39SAndroid Build Coastguard Worker * <p> 48*0e209d39SAndroid Build Coastguard Worker * @see UCollationResult 49*0e209d39SAndroid Build Coastguard Worker * @see UNormalizationMode 50*0e209d39SAndroid Build Coastguard Worker * @see UCollationStrength 51*0e209d39SAndroid Build Coastguard Worker * @see UCollationElements 52*0e209d39SAndroid Build Coastguard Worker */ 53*0e209d39SAndroid Build Coastguard Worker 54*0e209d39SAndroid Build Coastguard Worker /** A collator. 55*0e209d39SAndroid Build Coastguard Worker * For usage in C programs. 56*0e209d39SAndroid Build Coastguard Worker */ 57*0e209d39SAndroid Build Coastguard Worker struct UCollator; 58*0e209d39SAndroid Build Coastguard Worker /** structure representing a collator object instance 59*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 60*0e209d39SAndroid Build Coastguard Worker */ 61*0e209d39SAndroid Build Coastguard Worker typedef struct UCollator UCollator; 62*0e209d39SAndroid Build Coastguard Worker 63*0e209d39SAndroid Build Coastguard Worker 64*0e209d39SAndroid Build Coastguard Worker /** 65*0e209d39SAndroid Build Coastguard Worker * UCOL_LESS is returned if source string is compared to be less than target 66*0e209d39SAndroid Build Coastguard Worker * string in the ucol_strcoll() method. 67*0e209d39SAndroid Build Coastguard Worker * UCOL_EQUAL is returned if source string is compared to be equal to target 68*0e209d39SAndroid Build Coastguard Worker * string in the ucol_strcoll() method. 69*0e209d39SAndroid Build Coastguard Worker * UCOL_GREATER is returned if source string is compared to be greater than 70*0e209d39SAndroid Build Coastguard Worker * target string in the ucol_strcoll() method. 71*0e209d39SAndroid Build Coastguard Worker * @see ucol_strcoll() 72*0e209d39SAndroid Build Coastguard Worker * <p> 73*0e209d39SAndroid Build Coastguard Worker * Possible values for a comparison result 74*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 75*0e209d39SAndroid Build Coastguard Worker */ 76*0e209d39SAndroid Build Coastguard Worker typedef enum UCollationResult : int32_t { 77*0e209d39SAndroid Build Coastguard Worker /** string a == string b */ 78*0e209d39SAndroid Build Coastguard Worker UCOL_EQUAL = 0, 79*0e209d39SAndroid Build Coastguard Worker /** string a > string b */ 80*0e209d39SAndroid Build Coastguard Worker UCOL_GREATER = 1, 81*0e209d39SAndroid Build Coastguard Worker /** string a < string b */ 82*0e209d39SAndroid Build Coastguard Worker UCOL_LESS = -1 83*0e209d39SAndroid Build Coastguard Worker } UCollationResult ; 84*0e209d39SAndroid Build Coastguard Worker 85*0e209d39SAndroid Build Coastguard Worker 86*0e209d39SAndroid Build Coastguard Worker /** Enum containing attribute values for controlling collation behavior. 87*0e209d39SAndroid Build Coastguard Worker * Here are all the allowable values. Not every attribute can take every value. The only 88*0e209d39SAndroid Build Coastguard Worker * universal value is UCOL_DEFAULT, which resets the attribute value to the predefined 89*0e209d39SAndroid Build Coastguard Worker * value for that locale 90*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 91*0e209d39SAndroid Build Coastguard Worker */ 92*0e209d39SAndroid Build Coastguard Worker typedef enum UColAttributeValue : int32_t { 93*0e209d39SAndroid Build Coastguard Worker /** accepted by most attributes */ 94*0e209d39SAndroid Build Coastguard Worker UCOL_DEFAULT = -1, 95*0e209d39SAndroid Build Coastguard Worker 96*0e209d39SAndroid Build Coastguard Worker /** Primary collation strength */ 97*0e209d39SAndroid Build Coastguard Worker UCOL_PRIMARY = 0, 98*0e209d39SAndroid Build Coastguard Worker /** Secondary collation strength */ 99*0e209d39SAndroid Build Coastguard Worker UCOL_SECONDARY = 1, 100*0e209d39SAndroid Build Coastguard Worker /** Tertiary collation strength */ 101*0e209d39SAndroid Build Coastguard Worker UCOL_TERTIARY = 2, 102*0e209d39SAndroid Build Coastguard Worker /** Default collation strength */ 103*0e209d39SAndroid Build Coastguard Worker UCOL_DEFAULT_STRENGTH = UCOL_TERTIARY, 104*0e209d39SAndroid Build Coastguard Worker UCOL_CE_STRENGTH_LIMIT, 105*0e209d39SAndroid Build Coastguard Worker /** Quaternary collation strength */ 106*0e209d39SAndroid Build Coastguard Worker UCOL_QUATERNARY=3, 107*0e209d39SAndroid Build Coastguard Worker /** Identical collation strength */ 108*0e209d39SAndroid Build Coastguard Worker UCOL_IDENTICAL=15, 109*0e209d39SAndroid Build Coastguard Worker UCOL_STRENGTH_LIMIT, 110*0e209d39SAndroid Build Coastguard Worker 111*0e209d39SAndroid Build Coastguard Worker /** Turn the feature off - works for UCOL_FRENCH_COLLATION, 112*0e209d39SAndroid Build Coastguard Worker UCOL_CASE_LEVEL, UCOL_HIRAGANA_QUATERNARY_MODE 113*0e209d39SAndroid Build Coastguard Worker & UCOL_DECOMPOSITION_MODE*/ 114*0e209d39SAndroid Build Coastguard Worker UCOL_OFF = 16, 115*0e209d39SAndroid Build Coastguard Worker /** Turn the feature on - works for UCOL_FRENCH_COLLATION, 116*0e209d39SAndroid Build Coastguard Worker UCOL_CASE_LEVEL, UCOL_HIRAGANA_QUATERNARY_MODE 117*0e209d39SAndroid Build Coastguard Worker & UCOL_DECOMPOSITION_MODE*/ 118*0e209d39SAndroid Build Coastguard Worker UCOL_ON = 17, 119*0e209d39SAndroid Build Coastguard Worker 120*0e209d39SAndroid Build Coastguard Worker /** Valid for UCOL_ALTERNATE_HANDLING. Alternate handling will be shifted */ 121*0e209d39SAndroid Build Coastguard Worker UCOL_SHIFTED = 20, 122*0e209d39SAndroid Build Coastguard Worker /** Valid for UCOL_ALTERNATE_HANDLING. Alternate handling will be non ignorable */ 123*0e209d39SAndroid Build Coastguard Worker UCOL_NON_IGNORABLE = 21, 124*0e209d39SAndroid Build Coastguard Worker 125*0e209d39SAndroid Build Coastguard Worker /** Valid for UCOL_CASE_FIRST - 126*0e209d39SAndroid Build Coastguard Worker lower case sorts before upper case */ 127*0e209d39SAndroid Build Coastguard Worker UCOL_LOWER_FIRST = 24, 128*0e209d39SAndroid Build Coastguard Worker /** upper case sorts before lower case */ 129*0e209d39SAndroid Build Coastguard Worker UCOL_UPPER_FIRST = 25, 130*0e209d39SAndroid Build Coastguard Worker 131*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API 132*0e209d39SAndroid Build Coastguard Worker /** 133*0e209d39SAndroid Build Coastguard Worker * One more than the highest normal UColAttributeValue value. 134*0e209d39SAndroid Build Coastguard Worker * \xrefitem deprecated "Deprecated" "Deprecated List" ICU 58 The numeric value may change over time, see ICU ticket #12420. 135*0e209d39SAndroid Build Coastguard Worker */ 136*0e209d39SAndroid Build Coastguard Worker UCOL_ATTRIBUTE_VALUE_COUNT 137*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_DEPRECATED_API */ 138*0e209d39SAndroid Build Coastguard Worker } UColAttributeValue; 139*0e209d39SAndroid Build Coastguard Worker 140*0e209d39SAndroid Build Coastguard Worker /** 141*0e209d39SAndroid Build Coastguard Worker * Enum containing the codes for reordering segments of the collation table that are not script 142*0e209d39SAndroid Build Coastguard Worker * codes. These reordering codes are to be used in conjunction with the script codes. 143*0e209d39SAndroid Build Coastguard Worker * @see ucol_getReorderCodes 144*0e209d39SAndroid Build Coastguard Worker * @see ucol_setReorderCodes 145*0e209d39SAndroid Build Coastguard Worker * @see ucol_getEquivalentReorderCodes 146*0e209d39SAndroid Build Coastguard Worker * @see UScriptCode 147*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 4.8 148*0e209d39SAndroid Build Coastguard Worker */ 149*0e209d39SAndroid Build Coastguard Worker typedef enum UColReorderCode : int32_t { 150*0e209d39SAndroid Build Coastguard Worker /** 151*0e209d39SAndroid Build Coastguard Worker * A special reordering code that is used to specify the default 152*0e209d39SAndroid Build Coastguard Worker * reordering codes for a locale. 153*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 4.8 154*0e209d39SAndroid Build Coastguard Worker */ 155*0e209d39SAndroid Build Coastguard Worker UCOL_REORDER_CODE_DEFAULT = -1, 156*0e209d39SAndroid Build Coastguard Worker /** 157*0e209d39SAndroid Build Coastguard Worker * A special reordering code that is used to specify no reordering codes. 158*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 4.8 159*0e209d39SAndroid Build Coastguard Worker */ 160*0e209d39SAndroid Build Coastguard Worker UCOL_REORDER_CODE_NONE = USCRIPT_UNKNOWN, 161*0e209d39SAndroid Build Coastguard Worker /** 162*0e209d39SAndroid Build Coastguard Worker * A special reordering code that is used to specify all other codes used for 163*0e209d39SAndroid Build Coastguard Worker * reordering except for the codes lised as UColReorderCode values and those 164*0e209d39SAndroid Build Coastguard Worker * listed explicitly in a reordering. 165*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 4.8 166*0e209d39SAndroid Build Coastguard Worker */ 167*0e209d39SAndroid Build Coastguard Worker UCOL_REORDER_CODE_OTHERS = USCRIPT_UNKNOWN, 168*0e209d39SAndroid Build Coastguard Worker /** 169*0e209d39SAndroid Build Coastguard Worker * Characters with the space property. 170*0e209d39SAndroid Build Coastguard Worker * This is equivalent to the rule value "space". 171*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 4.8 172*0e209d39SAndroid Build Coastguard Worker */ 173*0e209d39SAndroid Build Coastguard Worker UCOL_REORDER_CODE_SPACE = 0x1000, 174*0e209d39SAndroid Build Coastguard Worker /** 175*0e209d39SAndroid Build Coastguard Worker * The first entry in the enumeration of reordering groups. This is intended for use in 176*0e209d39SAndroid Build Coastguard Worker * range checking and enumeration of the reorder codes. 177*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 4.8 178*0e209d39SAndroid Build Coastguard Worker */ 179*0e209d39SAndroid Build Coastguard Worker UCOL_REORDER_CODE_FIRST = UCOL_REORDER_CODE_SPACE, 180*0e209d39SAndroid Build Coastguard Worker /** 181*0e209d39SAndroid Build Coastguard Worker * Characters with the punctuation property. 182*0e209d39SAndroid Build Coastguard Worker * This is equivalent to the rule value "punct". 183*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 4.8 184*0e209d39SAndroid Build Coastguard Worker */ 185*0e209d39SAndroid Build Coastguard Worker UCOL_REORDER_CODE_PUNCTUATION = 0x1001, 186*0e209d39SAndroid Build Coastguard Worker /** 187*0e209d39SAndroid Build Coastguard Worker * Characters with the symbol property. 188*0e209d39SAndroid Build Coastguard Worker * This is equivalent to the rule value "symbol". 189*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 4.8 190*0e209d39SAndroid Build Coastguard Worker */ 191*0e209d39SAndroid Build Coastguard Worker UCOL_REORDER_CODE_SYMBOL = 0x1002, 192*0e209d39SAndroid Build Coastguard Worker /** 193*0e209d39SAndroid Build Coastguard Worker * Characters with the currency property. 194*0e209d39SAndroid Build Coastguard Worker * This is equivalent to the rule value "currency". 195*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 4.8 196*0e209d39SAndroid Build Coastguard Worker */ 197*0e209d39SAndroid Build Coastguard Worker UCOL_REORDER_CODE_CURRENCY = 0x1003, 198*0e209d39SAndroid Build Coastguard Worker /** 199*0e209d39SAndroid Build Coastguard Worker * Characters with the digit property. 200*0e209d39SAndroid Build Coastguard Worker * This is equivalent to the rule value "digit". 201*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 4.8 202*0e209d39SAndroid Build Coastguard Worker */ 203*0e209d39SAndroid Build Coastguard Worker UCOL_REORDER_CODE_DIGIT = 0x1004, 204*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API 205*0e209d39SAndroid Build Coastguard Worker /** 206*0e209d39SAndroid Build Coastguard Worker * One more than the highest normal UColReorderCode value. 207*0e209d39SAndroid Build Coastguard Worker * \xrefitem deprecated "Deprecated" "Deprecated List" ICU 58 The numeric value may change over time, see ICU ticket #12420. 208*0e209d39SAndroid Build Coastguard Worker */ 209*0e209d39SAndroid Build Coastguard Worker UCOL_REORDER_CODE_LIMIT = 0x1005 210*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_DEPRECATED_API */ 211*0e209d39SAndroid Build Coastguard Worker } UColReorderCode; 212*0e209d39SAndroid Build Coastguard Worker 213*0e209d39SAndroid Build Coastguard Worker /** 214*0e209d39SAndroid Build Coastguard Worker * Base letter represents a primary difference. Set comparison 215*0e209d39SAndroid Build Coastguard Worker * level to UCOL_PRIMARY to ignore secondary and tertiary differences. 216*0e209d39SAndroid Build Coastguard Worker * Use this to set the strength of a Collator object. 217*0e209d39SAndroid Build Coastguard Worker * Example of primary difference, "abc" < "abd" 218*0e209d39SAndroid Build Coastguard Worker * 219*0e209d39SAndroid Build Coastguard Worker * Diacritical differences on the same base letter represent a secondary 220*0e209d39SAndroid Build Coastguard Worker * difference. Set comparison level to UCOL_SECONDARY to ignore tertiary 221*0e209d39SAndroid Build Coastguard Worker * differences. Use this to set the strength of a Collator object. 222*0e209d39SAndroid Build Coastguard Worker * Example of secondary difference, "ä" >> "a". 223*0e209d39SAndroid Build Coastguard Worker * 224*0e209d39SAndroid Build Coastguard Worker * Uppercase and lowercase versions of the same character represents a 225*0e209d39SAndroid Build Coastguard Worker * tertiary difference. Set comparison level to UCOL_TERTIARY to include 226*0e209d39SAndroid Build Coastguard Worker * all comparison differences. Use this to set the strength of a Collator 227*0e209d39SAndroid Build Coastguard Worker * object. 228*0e209d39SAndroid Build Coastguard Worker * Example of tertiary difference, "abc" <<< "ABC". 229*0e209d39SAndroid Build Coastguard Worker * 230*0e209d39SAndroid Build Coastguard Worker * Two characters are considered "identical" when they have the same 231*0e209d39SAndroid Build Coastguard Worker * unicode spellings. UCOL_IDENTICAL. 232*0e209d39SAndroid Build Coastguard Worker * For example, "ä" == "ä". 233*0e209d39SAndroid Build Coastguard Worker * 234*0e209d39SAndroid Build Coastguard Worker * UCollationStrength is also used to determine the strength of sort keys 235*0e209d39SAndroid Build Coastguard Worker * generated from UCollator objects 236*0e209d39SAndroid Build Coastguard Worker * These values can be now found in the UColAttributeValue enum. 237*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 238*0e209d39SAndroid Build Coastguard Worker **/ 239*0e209d39SAndroid Build Coastguard Worker typedef UColAttributeValue UCollationStrength; 240*0e209d39SAndroid Build Coastguard Worker 241*0e209d39SAndroid Build Coastguard Worker /** Attributes that collation service understands. All the attributes can take UCOL_DEFAULT 242*0e209d39SAndroid Build Coastguard Worker * value, as well as the values specific to each one. 243*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 244*0e209d39SAndroid Build Coastguard Worker */ 245*0e209d39SAndroid Build Coastguard Worker typedef enum UColAttribute : int32_t { 246*0e209d39SAndroid Build Coastguard Worker /** Attribute for direction of secondary weights - used in Canadian French. 247*0e209d39SAndroid Build Coastguard Worker * Acceptable values are UCOL_ON, which results in secondary weights 248*0e209d39SAndroid Build Coastguard Worker * being considered backwards and UCOL_OFF which treats secondary 249*0e209d39SAndroid Build Coastguard Worker * weights in the order they appear. 250*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 251*0e209d39SAndroid Build Coastguard Worker */ 252*0e209d39SAndroid Build Coastguard Worker UCOL_FRENCH_COLLATION, 253*0e209d39SAndroid Build Coastguard Worker /** Attribute for handling variable elements. 254*0e209d39SAndroid Build Coastguard Worker * Acceptable values are UCOL_NON_IGNORABLE 255*0e209d39SAndroid Build Coastguard Worker * which treats all the codepoints with non-ignorable 256*0e209d39SAndroid Build Coastguard Worker * primary weights in the same way, 257*0e209d39SAndroid Build Coastguard Worker * and UCOL_SHIFTED which causes codepoints with primary 258*0e209d39SAndroid Build Coastguard Worker * weights that are equal or below the variable top value 259*0e209d39SAndroid Build Coastguard Worker * to be ignored on primary level and moved to the quaternary 260*0e209d39SAndroid Build Coastguard Worker * level. The default setting in a Collator object depends on the 261*0e209d39SAndroid Build Coastguard Worker * locale data loaded from the resources. For most locales, the 262*0e209d39SAndroid Build Coastguard Worker * default is UCOL_NON_IGNORABLE, but for others, such as "th", 263*0e209d39SAndroid Build Coastguard Worker * the default could be UCOL_SHIFTED. 264*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 265*0e209d39SAndroid Build Coastguard Worker */ 266*0e209d39SAndroid Build Coastguard Worker UCOL_ALTERNATE_HANDLING, 267*0e209d39SAndroid Build Coastguard Worker /** Controls the ordering of upper and lower case letters. 268*0e209d39SAndroid Build Coastguard Worker * Acceptable values are UCOL_OFF, which orders 269*0e209d39SAndroid Build Coastguard Worker * upper and lower case letters in accordance to their tertiary 270*0e209d39SAndroid Build Coastguard Worker * weights, UCOL_UPPER_FIRST which forces upper case letters to 271*0e209d39SAndroid Build Coastguard Worker * sort before lower case letters, and UCOL_LOWER_FIRST which does 272*0e209d39SAndroid Build Coastguard Worker * the opposite. The default setting in a Collator object depends on the 273*0e209d39SAndroid Build Coastguard Worker * locale data loaded from the resources. For most locales, the 274*0e209d39SAndroid Build Coastguard Worker * default is UCOL_OFF, but for others, such as "da" or "mt", 275*0e209d39SAndroid Build Coastguard Worker * the default could be UCOL_UPPER. 276*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 277*0e209d39SAndroid Build Coastguard Worker */ 278*0e209d39SAndroid Build Coastguard Worker UCOL_CASE_FIRST, 279*0e209d39SAndroid Build Coastguard Worker /** Controls whether an extra case level (positioned before the third 280*0e209d39SAndroid Build Coastguard Worker * level) is generated or not. Acceptable values are UCOL_OFF, 281*0e209d39SAndroid Build Coastguard Worker * when case level is not generated, and UCOL_ON which causes the case 282*0e209d39SAndroid Build Coastguard Worker * level to be generated. Contents of the case level are affected by 283*0e209d39SAndroid Build Coastguard Worker * the value of UCOL_CASE_FIRST attribute. A simple way to ignore 284*0e209d39SAndroid Build Coastguard Worker * accent differences in a string is to set the strength to UCOL_PRIMARY 285*0e209d39SAndroid Build Coastguard Worker * and enable case level. The default setting in a Collator object depends 286*0e209d39SAndroid Build Coastguard Worker * on the locale data loaded from the resources. 287*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 288*0e209d39SAndroid Build Coastguard Worker */ 289*0e209d39SAndroid Build Coastguard Worker UCOL_CASE_LEVEL, 290*0e209d39SAndroid Build Coastguard Worker /** Controls whether the normalization check and necessary normalizations 291*0e209d39SAndroid Build Coastguard Worker * are performed. When set to UCOL_OFF no normalization check 292*0e209d39SAndroid Build Coastguard Worker * is performed. The correctness of the result is guaranteed only if the 293*0e209d39SAndroid Build Coastguard Worker * input data is in so-called FCD form (see users manual for more info). 294*0e209d39SAndroid Build Coastguard Worker * When set to UCOL_ON, an incremental check is performed to see whether 295*0e209d39SAndroid Build Coastguard Worker * the input data is in the FCD form. If the data is not in the FCD form, 296*0e209d39SAndroid Build Coastguard Worker * incremental NFD normalization is performed. The default setting in a 297*0e209d39SAndroid Build Coastguard Worker * Collator object depends on the locale data loaded from the resources. 298*0e209d39SAndroid Build Coastguard Worker * For many locales, the default is UCOL_OFF, but for others, such as "hi" 299*0e209d39SAndroid Build Coastguard Worker * "vi', or "bn", * the default could be UCOL_ON. 300*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 301*0e209d39SAndroid Build Coastguard Worker */ 302*0e209d39SAndroid Build Coastguard Worker UCOL_NORMALIZATION_MODE, 303*0e209d39SAndroid Build Coastguard Worker /** An alias for UCOL_NORMALIZATION_MODE attribute. 304*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 305*0e209d39SAndroid Build Coastguard Worker */ 306*0e209d39SAndroid Build Coastguard Worker UCOL_DECOMPOSITION_MODE = UCOL_NORMALIZATION_MODE, 307*0e209d39SAndroid Build Coastguard Worker /** The strength attribute. Can be either UCOL_PRIMARY, UCOL_SECONDARY, 308*0e209d39SAndroid Build Coastguard Worker * UCOL_TERTIARY, UCOL_QUATERNARY or UCOL_IDENTICAL. The usual strength 309*0e209d39SAndroid Build Coastguard Worker * for most locales (except Japanese) is tertiary. 310*0e209d39SAndroid Build Coastguard Worker * 311*0e209d39SAndroid Build Coastguard Worker * Quaternary strength 312*0e209d39SAndroid Build Coastguard Worker * is useful when combined with shifted setting for alternate handling 313*0e209d39SAndroid Build Coastguard Worker * attribute and for JIS X 4061 collation, when it is used to distinguish 314*0e209d39SAndroid Build Coastguard Worker * between Katakana and Hiragana. 315*0e209d39SAndroid Build Coastguard Worker * Otherwise, quaternary level 316*0e209d39SAndroid Build Coastguard Worker * is affected only by the number of non-ignorable code points in 317*0e209d39SAndroid Build Coastguard Worker * the string. 318*0e209d39SAndroid Build Coastguard Worker * 319*0e209d39SAndroid Build Coastguard Worker * Identical strength is rarely useful, as it amounts 320*0e209d39SAndroid Build Coastguard Worker * to codepoints of the NFD form of the string. 321*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 322*0e209d39SAndroid Build Coastguard Worker */ 323*0e209d39SAndroid Build Coastguard Worker UCOL_STRENGTH, 324*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API 325*0e209d39SAndroid Build Coastguard Worker /** When turned on, this attribute positions Hiragana before all 326*0e209d39SAndroid Build Coastguard Worker * non-ignorables on quaternary level This is a sneaky way to produce JIS 327*0e209d39SAndroid Build Coastguard Worker * sort order. 328*0e209d39SAndroid Build Coastguard Worker * 329*0e209d39SAndroid Build Coastguard Worker * This attribute was an implementation detail of the CLDR Japanese tailoring. 330*0e209d39SAndroid Build Coastguard Worker * Since ICU 50, this attribute is not settable any more via API functions. 331*0e209d39SAndroid Build Coastguard Worker * Since CLDR 25/ICU 53, explicit quaternary relations are used 332*0e209d39SAndroid Build Coastguard Worker * to achieve the same Japanese sort order. 333*0e209d39SAndroid Build Coastguard Worker * 334*0e209d39SAndroid Build Coastguard Worker * \xrefitem deprecated "Deprecated" "Deprecated List" ICU 50 Implementation detail, cannot be set via API, was removed from implementation. 335*0e209d39SAndroid Build Coastguard Worker */ 336*0e209d39SAndroid Build Coastguard Worker UCOL_HIRAGANA_QUATERNARY_MODE = UCOL_STRENGTH + 1, 337*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_DEPRECATED_API */ 338*0e209d39SAndroid Build Coastguard Worker /** 339*0e209d39SAndroid Build Coastguard Worker * When turned on, this attribute makes 340*0e209d39SAndroid Build Coastguard Worker * substrings of digits sort according to their numeric values. 341*0e209d39SAndroid Build Coastguard Worker * 342*0e209d39SAndroid Build Coastguard Worker * This is a way to get '100' to sort AFTER '2'. Note that the longest 343*0e209d39SAndroid Build Coastguard Worker * digit substring that can be treated as a single unit is 344*0e209d39SAndroid Build Coastguard Worker * 254 digits (not counting leading zeros). If a digit substring is 345*0e209d39SAndroid Build Coastguard Worker * longer than that, the digits beyond the limit will be treated as a 346*0e209d39SAndroid Build Coastguard Worker * separate digit substring. 347*0e209d39SAndroid Build Coastguard Worker * 348*0e209d39SAndroid Build Coastguard Worker * A "digit" in this sense is a code point with General_Category=Nd, 349*0e209d39SAndroid Build Coastguard Worker * which does not include circled numbers, roman numerals, etc. 350*0e209d39SAndroid Build Coastguard Worker * Only a contiguous digit substring is considered, that is, 351*0e209d39SAndroid Build Coastguard Worker * non-negative integers without separators. 352*0e209d39SAndroid Build Coastguard Worker * There is no support for plus/minus signs, decimals, exponents, etc. 353*0e209d39SAndroid Build Coastguard Worker * 354*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.8 355*0e209d39SAndroid Build Coastguard Worker */ 356*0e209d39SAndroid Build Coastguard Worker UCOL_NUMERIC_COLLATION = UCOL_STRENGTH + 2, 357*0e209d39SAndroid Build Coastguard Worker 358*0e209d39SAndroid Build Coastguard Worker /* Do not conditionalize the following with #ifndef U_HIDE_DEPRECATED_API, 359*0e209d39SAndroid Build Coastguard Worker * it is needed for layout of RuleBasedCollator object. */ 360*0e209d39SAndroid Build Coastguard Worker #ifndef U_FORCE_HIDE_DEPRECATED_API 361*0e209d39SAndroid Build Coastguard Worker /** 362*0e209d39SAndroid Build Coastguard Worker * One more than the highest normal UColAttribute value. 363*0e209d39SAndroid Build Coastguard Worker * \xrefitem deprecated "Deprecated" "Deprecated List" ICU 58 The numeric value may change over time, see ICU ticket #12420. 364*0e209d39SAndroid Build Coastguard Worker */ 365*0e209d39SAndroid Build Coastguard Worker UCOL_ATTRIBUTE_COUNT 366*0e209d39SAndroid Build Coastguard Worker #endif // U_FORCE_HIDE_DEPRECATED_API 367*0e209d39SAndroid Build Coastguard Worker } UColAttribute; 368*0e209d39SAndroid Build Coastguard Worker 369*0e209d39SAndroid Build Coastguard Worker 370*0e209d39SAndroid Build Coastguard Worker /** 371*0e209d39SAndroid Build Coastguard Worker * Open a UCollator for comparing strings. 372*0e209d39SAndroid Build Coastguard Worker * 373*0e209d39SAndroid Build Coastguard Worker * For some languages, multiple collation types are available; 374*0e209d39SAndroid Build Coastguard Worker * for example, "de@collation=phonebook". 375*0e209d39SAndroid Build Coastguard Worker * Starting with ICU 54, collation attributes can be specified via locale keywords as well, 376*0e209d39SAndroid Build Coastguard Worker * in the old locale extension syntax ("el@colCaseFirst=upper") 377*0e209d39SAndroid Build Coastguard Worker * or in language tag syntax ("el-u-kf-upper"). 378*0e209d39SAndroid Build Coastguard Worker * See <a href="https://unicode-org.github.io/icu/userguide/collation/api">User Guide: Collation API</a>. 379*0e209d39SAndroid Build Coastguard Worker * 380*0e209d39SAndroid Build Coastguard Worker * The UCollator pointer is used in all the calls to the Collation 381*0e209d39SAndroid Build Coastguard Worker * service. After finished, collator must be disposed of by calling 382*0e209d39SAndroid Build Coastguard Worker * {@link #ucol_close }. 383*0e209d39SAndroid Build Coastguard Worker * @param loc The locale containing the required collation rules. 384*0e209d39SAndroid Build Coastguard Worker * Special values for locales can be passed in - 385*0e209d39SAndroid Build Coastguard Worker * if NULL is passed for the locale, the default locale 386*0e209d39SAndroid Build Coastguard Worker * collation rules will be used. If empty string ("") or 387*0e209d39SAndroid Build Coastguard Worker * "root" are passed, the root collator will be returned. 388*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to a UErrorCode to receive any errors 389*0e209d39SAndroid Build Coastguard Worker * @return A pointer to a UCollator, or 0 if an error occurred. 390*0e209d39SAndroid Build Coastguard Worker * @see ucol_openRules 391*0e209d39SAndroid Build Coastguard Worker * @see ucol_clone 392*0e209d39SAndroid Build Coastguard Worker * @see ucol_close 393*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 394*0e209d39SAndroid Build Coastguard Worker */ 395*0e209d39SAndroid Build Coastguard Worker U_CAPI UCollator* U_EXPORT2 396*0e209d39SAndroid Build Coastguard Worker ucol_open(const char *loc, UErrorCode *status) __INTRODUCED_IN(__ANDROID_API_T__); 397*0e209d39SAndroid Build Coastguard Worker 398*0e209d39SAndroid Build Coastguard Worker 399*0e209d39SAndroid Build Coastguard Worker 400*0e209d39SAndroid Build Coastguard Worker /** 401*0e209d39SAndroid Build Coastguard Worker * Produce a UCollator instance according to the rules supplied. 402*0e209d39SAndroid Build Coastguard Worker * The rules are used to change the default ordering, defined in the 403*0e209d39SAndroid Build Coastguard Worker * UCA in a process called tailoring. The resulting UCollator pointer 404*0e209d39SAndroid Build Coastguard Worker * can be used in the same way as the one obtained by {@link #ucol_strcoll }. 405*0e209d39SAndroid Build Coastguard Worker * @param rules A string describing the collation rules. For the syntax 406*0e209d39SAndroid Build Coastguard Worker * of the rules please see users guide. 407*0e209d39SAndroid Build Coastguard Worker * @param rulesLength The length of rules, or -1 if null-terminated. 408*0e209d39SAndroid Build Coastguard Worker * @param normalizationMode The normalization mode: One of 409*0e209d39SAndroid Build Coastguard Worker * UCOL_OFF (expect the text to not need normalization), 410*0e209d39SAndroid Build Coastguard Worker * UCOL_ON (normalize), or 411*0e209d39SAndroid Build Coastguard Worker * UCOL_DEFAULT (set the mode according to the rules) 412*0e209d39SAndroid Build Coastguard Worker * @param strength The default collation strength; one of UCOL_PRIMARY, UCOL_SECONDARY, 413*0e209d39SAndroid Build Coastguard Worker * UCOL_TERTIARY, UCOL_IDENTICAL,UCOL_DEFAULT_STRENGTH - can be also set in the rules. 414*0e209d39SAndroid Build Coastguard Worker * @param parseError A pointer to UParseError to receive information about errors 415*0e209d39SAndroid Build Coastguard Worker * occurred during parsing. This argument can currently be set 416*0e209d39SAndroid Build Coastguard Worker * to NULL, but at users own risk. Please provide a real structure. 417*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to a UErrorCode to receive any errors 418*0e209d39SAndroid Build Coastguard Worker * @return A pointer to a UCollator. It is not guaranteed that NULL be returned in case 419*0e209d39SAndroid Build Coastguard Worker * of error - please use status argument to check for errors. 420*0e209d39SAndroid Build Coastguard Worker * @see ucol_open 421*0e209d39SAndroid Build Coastguard Worker * @see ucol_clone 422*0e209d39SAndroid Build Coastguard Worker * @see ucol_close 423*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 424*0e209d39SAndroid Build Coastguard Worker */ 425*0e209d39SAndroid Build Coastguard Worker U_CAPI UCollator* U_EXPORT2 426*0e209d39SAndroid Build Coastguard Worker ucol_openRules( const UChar *rules, 427*0e209d39SAndroid Build Coastguard Worker int32_t rulesLength, 428*0e209d39SAndroid Build Coastguard Worker UColAttributeValue normalizationMode, 429*0e209d39SAndroid Build Coastguard Worker UCollationStrength strength, 430*0e209d39SAndroid Build Coastguard Worker UParseError *parseError, 431*0e209d39SAndroid Build Coastguard Worker UErrorCode *status) __INTRODUCED_IN(__ANDROID_API_T__); 432*0e209d39SAndroid Build Coastguard Worker 433*0e209d39SAndroid Build Coastguard Worker 434*0e209d39SAndroid Build Coastguard Worker 435*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API 436*0e209d39SAndroid Build Coastguard Worker 437*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_DEPRECATED_API */ 438*0e209d39SAndroid Build Coastguard Worker 439*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API 440*0e209d39SAndroid Build Coastguard Worker 441*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_DEPRECATED_API */ 442*0e209d39SAndroid Build Coastguard Worker 443*0e209d39SAndroid Build Coastguard Worker 444*0e209d39SAndroid Build Coastguard Worker 445*0e209d39SAndroid Build Coastguard Worker /** 446*0e209d39SAndroid Build Coastguard Worker * Close a UCollator. 447*0e209d39SAndroid Build Coastguard Worker * Once closed, a UCollator should not be used. Every open collator should 448*0e209d39SAndroid Build Coastguard Worker * be closed. Otherwise, a memory leak will result. 449*0e209d39SAndroid Build Coastguard Worker * @param coll The UCollator to close. 450*0e209d39SAndroid Build Coastguard Worker * @see ucol_open 451*0e209d39SAndroid Build Coastguard Worker * @see ucol_openRules 452*0e209d39SAndroid Build Coastguard Worker * @see ucol_clone 453*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 454*0e209d39SAndroid Build Coastguard Worker */ 455*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 456*0e209d39SAndroid Build Coastguard Worker ucol_close(UCollator *coll) __INTRODUCED_IN(__ANDROID_API_T__); 457*0e209d39SAndroid Build Coastguard Worker 458*0e209d39SAndroid Build Coastguard Worker 459*0e209d39SAndroid Build Coastguard Worker 460*0e209d39SAndroid Build Coastguard Worker #if U_SHOW_CPLUSPLUS_API 461*0e209d39SAndroid Build Coastguard Worker 462*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_BEGIN 463*0e209d39SAndroid Build Coastguard Worker 464*0e209d39SAndroid Build Coastguard Worker /** 465*0e209d39SAndroid Build Coastguard Worker * \class LocalUCollatorPointer 466*0e209d39SAndroid Build Coastguard Worker * "Smart pointer" class, closes a UCollator via ucol_close(). 467*0e209d39SAndroid Build Coastguard Worker * For most methods see the LocalPointerBase base class. 468*0e209d39SAndroid Build Coastguard Worker * 469*0e209d39SAndroid Build Coastguard Worker * @see LocalPointerBase 470*0e209d39SAndroid Build Coastguard Worker * @see LocalPointer 471*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 4.4 472*0e209d39SAndroid Build Coastguard Worker */ 473*0e209d39SAndroid Build Coastguard Worker U_DEFINE_LOCAL_OPEN_POINTER(LocalUCollatorPointer, UCollator, ucol_close); 474*0e209d39SAndroid Build Coastguard Worker 475*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_END 476*0e209d39SAndroid Build Coastguard Worker 477*0e209d39SAndroid Build Coastguard Worker #endif 478*0e209d39SAndroid Build Coastguard Worker 479*0e209d39SAndroid Build Coastguard Worker /** 480*0e209d39SAndroid Build Coastguard Worker * Compare two strings. 481*0e209d39SAndroid Build Coastguard Worker * The strings will be compared using the options already specified. 482*0e209d39SAndroid Build Coastguard Worker * @param coll The UCollator containing the comparison rules. 483*0e209d39SAndroid Build Coastguard Worker * @param source The source string. 484*0e209d39SAndroid Build Coastguard Worker * @param sourceLength The length of source, or -1 if null-terminated. 485*0e209d39SAndroid Build Coastguard Worker * @param target The target string. 486*0e209d39SAndroid Build Coastguard Worker * @param targetLength The length of target, or -1 if null-terminated. 487*0e209d39SAndroid Build Coastguard Worker * @return The result of comparing the strings; one of UCOL_EQUAL, 488*0e209d39SAndroid Build Coastguard Worker * UCOL_GREATER, UCOL_LESS 489*0e209d39SAndroid Build Coastguard Worker * @see ucol_greater 490*0e209d39SAndroid Build Coastguard Worker * @see ucol_greaterOrEqual 491*0e209d39SAndroid Build Coastguard Worker * @see ucol_equal 492*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 493*0e209d39SAndroid Build Coastguard Worker */ 494*0e209d39SAndroid Build Coastguard Worker U_CAPI UCollationResult U_EXPORT2 495*0e209d39SAndroid Build Coastguard Worker ucol_strcoll( const UCollator *coll, 496*0e209d39SAndroid Build Coastguard Worker const UChar *source, 497*0e209d39SAndroid Build Coastguard Worker int32_t sourceLength, 498*0e209d39SAndroid Build Coastguard Worker const UChar *target, 499*0e209d39SAndroid Build Coastguard Worker int32_t targetLength) __INTRODUCED_IN(__ANDROID_API_T__); 500*0e209d39SAndroid Build Coastguard Worker 501*0e209d39SAndroid Build Coastguard Worker 502*0e209d39SAndroid Build Coastguard Worker 503*0e209d39SAndroid Build Coastguard Worker /** 504*0e209d39SAndroid Build Coastguard Worker * Compare two strings in UTF-8. 505*0e209d39SAndroid Build Coastguard Worker * The strings will be compared using the options already specified. 506*0e209d39SAndroid Build Coastguard Worker * Note: When input string contains malformed a UTF-8 byte sequence, 507*0e209d39SAndroid Build Coastguard Worker * this function treats these bytes as REPLACEMENT CHARACTER (U+FFFD). 508*0e209d39SAndroid Build Coastguard Worker * @param coll The UCollator containing the comparison rules. 509*0e209d39SAndroid Build Coastguard Worker * @param source The source UTF-8 string. 510*0e209d39SAndroid Build Coastguard Worker * @param sourceLength The length of source, or -1 if null-terminated. 511*0e209d39SAndroid Build Coastguard Worker * @param target The target UTF-8 string. 512*0e209d39SAndroid Build Coastguard Worker * @param targetLength The length of target, or -1 if null-terminated. 513*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to a UErrorCode to receive any errors 514*0e209d39SAndroid Build Coastguard Worker * @return The result of comparing the strings; one of UCOL_EQUAL, 515*0e209d39SAndroid Build Coastguard Worker * UCOL_GREATER, UCOL_LESS 516*0e209d39SAndroid Build Coastguard Worker * @see ucol_greater 517*0e209d39SAndroid Build Coastguard Worker * @see ucol_greaterOrEqual 518*0e209d39SAndroid Build Coastguard Worker * @see ucol_equal 519*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 50 520*0e209d39SAndroid Build Coastguard Worker */ 521*0e209d39SAndroid Build Coastguard Worker U_CAPI UCollationResult U_EXPORT2 522*0e209d39SAndroid Build Coastguard Worker ucol_strcollUTF8( 523*0e209d39SAndroid Build Coastguard Worker const UCollator *coll, 524*0e209d39SAndroid Build Coastguard Worker const char *source, 525*0e209d39SAndroid Build Coastguard Worker int32_t sourceLength, 526*0e209d39SAndroid Build Coastguard Worker const char *target, 527*0e209d39SAndroid Build Coastguard Worker int32_t targetLength, 528*0e209d39SAndroid Build Coastguard Worker UErrorCode *status) __INTRODUCED_IN(__ANDROID_API_T__); 529*0e209d39SAndroid Build Coastguard Worker 530*0e209d39SAndroid Build Coastguard Worker 531*0e209d39SAndroid Build Coastguard Worker 532*0e209d39SAndroid Build Coastguard Worker 533*0e209d39SAndroid Build Coastguard Worker 534*0e209d39SAndroid Build Coastguard Worker 535*0e209d39SAndroid Build Coastguard Worker 536*0e209d39SAndroid Build Coastguard Worker 537*0e209d39SAndroid Build Coastguard Worker 538*0e209d39SAndroid Build Coastguard Worker 539*0e209d39SAndroid Build Coastguard Worker 540*0e209d39SAndroid Build Coastguard Worker /** 541*0e209d39SAndroid Build Coastguard Worker * Get the collation strength used in a UCollator. 542*0e209d39SAndroid Build Coastguard Worker * The strength influences how strings are compared. 543*0e209d39SAndroid Build Coastguard Worker * @param coll The UCollator to query. 544*0e209d39SAndroid Build Coastguard Worker * @return The collation strength; one of UCOL_PRIMARY, UCOL_SECONDARY, 545*0e209d39SAndroid Build Coastguard Worker * UCOL_TERTIARY, UCOL_QUATERNARY, UCOL_IDENTICAL 546*0e209d39SAndroid Build Coastguard Worker * @see ucol_setStrength 547*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 548*0e209d39SAndroid Build Coastguard Worker */ 549*0e209d39SAndroid Build Coastguard Worker U_CAPI UCollationStrength U_EXPORT2 550*0e209d39SAndroid Build Coastguard Worker ucol_getStrength(const UCollator *coll) __INTRODUCED_IN(__ANDROID_API_T__); 551*0e209d39SAndroid Build Coastguard Worker 552*0e209d39SAndroid Build Coastguard Worker 553*0e209d39SAndroid Build Coastguard Worker 554*0e209d39SAndroid Build Coastguard Worker /** 555*0e209d39SAndroid Build Coastguard Worker * Set the collation strength used in a UCollator. 556*0e209d39SAndroid Build Coastguard Worker * The strength influences how strings are compared. 557*0e209d39SAndroid Build Coastguard Worker * @param coll The UCollator to set. 558*0e209d39SAndroid Build Coastguard Worker * @param strength The desired collation strength; one of UCOL_PRIMARY, 559*0e209d39SAndroid Build Coastguard Worker * UCOL_SECONDARY, UCOL_TERTIARY, UCOL_QUATERNARY, UCOL_IDENTICAL, UCOL_DEFAULT 560*0e209d39SAndroid Build Coastguard Worker * @see ucol_getStrength 561*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 562*0e209d39SAndroid Build Coastguard Worker */ 563*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 564*0e209d39SAndroid Build Coastguard Worker ucol_setStrength(UCollator *coll, 565*0e209d39SAndroid Build Coastguard Worker UCollationStrength strength) __INTRODUCED_IN(__ANDROID_API_T__); 566*0e209d39SAndroid Build Coastguard Worker 567*0e209d39SAndroid Build Coastguard Worker 568*0e209d39SAndroid Build Coastguard Worker 569*0e209d39SAndroid Build Coastguard Worker /** 570*0e209d39SAndroid Build Coastguard Worker * Retrieves the reordering codes for this collator. 571*0e209d39SAndroid Build Coastguard Worker * These reordering codes are a combination of UScript codes and UColReorderCode entries. 572*0e209d39SAndroid Build Coastguard Worker * @param coll The UCollator to query. 573*0e209d39SAndroid Build Coastguard Worker * @param dest The array to fill with the script ordering. 574*0e209d39SAndroid Build Coastguard Worker * @param destCapacity The length of dest. If it is 0, then dest may be NULL and the function 575*0e209d39SAndroid Build Coastguard Worker * will only return the length of the result without writing any codes (pre-flighting). 576*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Must be a valid pointer to an error code value, which must not indicate a 577*0e209d39SAndroid Build Coastguard Worker * failure before the function call. 578*0e209d39SAndroid Build Coastguard Worker * @return The number of reordering codes written to the dest array. 579*0e209d39SAndroid Build Coastguard Worker * @see ucol_setReorderCodes 580*0e209d39SAndroid Build Coastguard Worker * @see ucol_getEquivalentReorderCodes 581*0e209d39SAndroid Build Coastguard Worker * @see UScriptCode 582*0e209d39SAndroid Build Coastguard Worker * @see UColReorderCode 583*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 4.8 584*0e209d39SAndroid Build Coastguard Worker */ 585*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 586*0e209d39SAndroid Build Coastguard Worker ucol_getReorderCodes(const UCollator* coll, 587*0e209d39SAndroid Build Coastguard Worker int32_t* dest, 588*0e209d39SAndroid Build Coastguard Worker int32_t destCapacity, 589*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode) __INTRODUCED_IN(__ANDROID_API_T__); 590*0e209d39SAndroid Build Coastguard Worker 591*0e209d39SAndroid Build Coastguard Worker 592*0e209d39SAndroid Build Coastguard Worker /** 593*0e209d39SAndroid Build Coastguard Worker * Sets the reordering codes for this collator. 594*0e209d39SAndroid Build Coastguard Worker * Collation reordering allows scripts and some other groups of characters 595*0e209d39SAndroid Build Coastguard Worker * to be moved relative to each other. This reordering is done on top of 596*0e209d39SAndroid Build Coastguard Worker * the DUCET/CLDR standard collation order. Reordering can specify groups to be placed 597*0e209d39SAndroid Build Coastguard Worker * at the start and/or the end of the collation order. These groups are specified using 598*0e209d39SAndroid Build Coastguard Worker * UScript codes and UColReorderCode entries. 599*0e209d39SAndroid Build Coastguard Worker * 600*0e209d39SAndroid Build Coastguard Worker * <p>By default, reordering codes specified for the start of the order are placed in the 601*0e209d39SAndroid Build Coastguard Worker * order given after several special non-script blocks. These special groups of characters 602*0e209d39SAndroid Build Coastguard Worker * are space, punctuation, symbol, currency, and digit. These special groups are represented with 603*0e209d39SAndroid Build Coastguard Worker * UColReorderCode entries. Script groups can be intermingled with 604*0e209d39SAndroid Build Coastguard Worker * these special non-script groups if those special groups are explicitly specified in the reordering. 605*0e209d39SAndroid Build Coastguard Worker * 606*0e209d39SAndroid Build Coastguard Worker * <p>The special code OTHERS stands for any script that is not explicitly 607*0e209d39SAndroid Build Coastguard Worker * mentioned in the list of reordering codes given. Anything that is after OTHERS 608*0e209d39SAndroid Build Coastguard Worker * will go at the very end of the reordering in the order given. 609*0e209d39SAndroid Build Coastguard Worker * 610*0e209d39SAndroid Build Coastguard Worker * <p>The special reorder code DEFAULT will reset the reordering for this collator 611*0e209d39SAndroid Build Coastguard Worker * to the default for this collator. The default reordering may be the DUCET/CLDR order or may be a reordering that 612*0e209d39SAndroid Build Coastguard Worker * was specified when this collator was created from resource data or from rules. The 613*0e209d39SAndroid Build Coastguard Worker * DEFAULT code <b>must</b> be the sole code supplied when it is used. 614*0e209d39SAndroid Build Coastguard Worker * If not, then U_ILLEGAL_ARGUMENT_ERROR will be set. 615*0e209d39SAndroid Build Coastguard Worker * 616*0e209d39SAndroid Build Coastguard Worker * <p>The special reorder code NONE will remove any reordering for this collator. 617*0e209d39SAndroid Build Coastguard Worker * The result of setting no reordering will be to have the DUCET/CLDR ordering used. The 618*0e209d39SAndroid Build Coastguard Worker * NONE code <b>must</b> be the sole code supplied when it is used. 619*0e209d39SAndroid Build Coastguard Worker * 620*0e209d39SAndroid Build Coastguard Worker * @param coll The UCollator to set. 621*0e209d39SAndroid Build Coastguard Worker * @param reorderCodes An array of script codes in the new order. This can be NULL if the 622*0e209d39SAndroid Build Coastguard Worker * length is also set to 0. An empty array will clear any reordering codes on the collator. 623*0e209d39SAndroid Build Coastguard Worker * @param reorderCodesLength The length of reorderCodes. 624*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Must be a valid pointer to an error code value, which must not indicate a 625*0e209d39SAndroid Build Coastguard Worker * failure before the function call. 626*0e209d39SAndroid Build Coastguard Worker * @see ucol_getReorderCodes 627*0e209d39SAndroid Build Coastguard Worker * @see ucol_getEquivalentReorderCodes 628*0e209d39SAndroid Build Coastguard Worker * @see UScriptCode 629*0e209d39SAndroid Build Coastguard Worker * @see UColReorderCode 630*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 4.8 631*0e209d39SAndroid Build Coastguard Worker */ 632*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 633*0e209d39SAndroid Build Coastguard Worker ucol_setReorderCodes(UCollator* coll, 634*0e209d39SAndroid Build Coastguard Worker const int32_t* reorderCodes, 635*0e209d39SAndroid Build Coastguard Worker int32_t reorderCodesLength, 636*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode) __INTRODUCED_IN(__ANDROID_API_T__); 637*0e209d39SAndroid Build Coastguard Worker 638*0e209d39SAndroid Build Coastguard Worker 639*0e209d39SAndroid Build Coastguard Worker 640*0e209d39SAndroid Build Coastguard Worker /** 641*0e209d39SAndroid Build Coastguard Worker * Retrieves the reorder codes that are grouped with the given reorder code. Some reorder 642*0e209d39SAndroid Build Coastguard Worker * codes will be grouped and must reorder together. 643*0e209d39SAndroid Build Coastguard Worker * Beginning with ICU 55, scripts only reorder together if they are primary-equal, 644*0e209d39SAndroid Build Coastguard Worker * for example Hiragana and Katakana. 645*0e209d39SAndroid Build Coastguard Worker * 646*0e209d39SAndroid Build Coastguard Worker * @param reorderCode The reorder code to determine equivalence for. 647*0e209d39SAndroid Build Coastguard Worker * @param dest The array to fill with the script ordering. 648*0e209d39SAndroid Build Coastguard Worker * @param destCapacity The length of dest. If it is 0, then dest may be NULL and the function 649*0e209d39SAndroid Build Coastguard Worker * will only return the length of the result without writing any codes (pre-flighting). 650*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Must be a valid pointer to an error code value, which must not indicate 651*0e209d39SAndroid Build Coastguard Worker * a failure before the function call. 652*0e209d39SAndroid Build Coastguard Worker * @return The number of reordering codes written to the dest array. 653*0e209d39SAndroid Build Coastguard Worker * @see ucol_setReorderCodes 654*0e209d39SAndroid Build Coastguard Worker * @see ucol_getReorderCodes 655*0e209d39SAndroid Build Coastguard Worker * @see UScriptCode 656*0e209d39SAndroid Build Coastguard Worker * @see UColReorderCode 657*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 4.8 658*0e209d39SAndroid Build Coastguard Worker */ 659*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 660*0e209d39SAndroid Build Coastguard Worker ucol_getEquivalentReorderCodes(int32_t reorderCode, 661*0e209d39SAndroid Build Coastguard Worker int32_t* dest, 662*0e209d39SAndroid Build Coastguard Worker int32_t destCapacity, 663*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode) __INTRODUCED_IN(__ANDROID_API_T__); 664*0e209d39SAndroid Build Coastguard Worker 665*0e209d39SAndroid Build Coastguard Worker 666*0e209d39SAndroid Build Coastguard Worker 667*0e209d39SAndroid Build Coastguard Worker /** 668*0e209d39SAndroid Build Coastguard Worker * Get the display name for a UCollator. 669*0e209d39SAndroid Build Coastguard Worker * The display name is suitable for presentation to a user. 670*0e209d39SAndroid Build Coastguard Worker * @param objLoc The locale of the collator in question. 671*0e209d39SAndroid Build Coastguard Worker * @param dispLoc The locale for display. 672*0e209d39SAndroid Build Coastguard Worker * @param result A pointer to a buffer to receive the attribute. 673*0e209d39SAndroid Build Coastguard Worker * @param resultLength The maximum size of result. 674*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to a UErrorCode to receive any errors 675*0e209d39SAndroid Build Coastguard Worker * @return The total buffer size needed; if greater than resultLength, 676*0e209d39SAndroid Build Coastguard Worker * the output was truncated. 677*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 678*0e209d39SAndroid Build Coastguard Worker */ 679*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 680*0e209d39SAndroid Build Coastguard Worker ucol_getDisplayName( const char *objLoc, 681*0e209d39SAndroid Build Coastguard Worker const char *dispLoc, 682*0e209d39SAndroid Build Coastguard Worker UChar *result, 683*0e209d39SAndroid Build Coastguard Worker int32_t resultLength, 684*0e209d39SAndroid Build Coastguard Worker UErrorCode *status) __INTRODUCED_IN(__ANDROID_API_T__); 685*0e209d39SAndroid Build Coastguard Worker 686*0e209d39SAndroid Build Coastguard Worker 687*0e209d39SAndroid Build Coastguard Worker 688*0e209d39SAndroid Build Coastguard Worker /** 689*0e209d39SAndroid Build Coastguard Worker * Get a locale for which collation rules are available. 690*0e209d39SAndroid Build Coastguard Worker * A UCollator in a locale returned by this function will perform the correct 691*0e209d39SAndroid Build Coastguard Worker * collation for the locale. 692*0e209d39SAndroid Build Coastguard Worker * @param localeIndex The index of the desired locale. 693*0e209d39SAndroid Build Coastguard Worker * @return A locale for which collation rules are available, or 0 if none. 694*0e209d39SAndroid Build Coastguard Worker * @see ucol_countAvailable 695*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 696*0e209d39SAndroid Build Coastguard Worker */ 697*0e209d39SAndroid Build Coastguard Worker U_CAPI const char* U_EXPORT2 698*0e209d39SAndroid Build Coastguard Worker ucol_getAvailable(int32_t localeIndex) __INTRODUCED_IN(__ANDROID_API_T__); 699*0e209d39SAndroid Build Coastguard Worker 700*0e209d39SAndroid Build Coastguard Worker 701*0e209d39SAndroid Build Coastguard Worker 702*0e209d39SAndroid Build Coastguard Worker /** 703*0e209d39SAndroid Build Coastguard Worker * Determine how many locales have collation rules available. 704*0e209d39SAndroid Build Coastguard Worker * This function is most useful as determining the loop ending condition for 705*0e209d39SAndroid Build Coastguard Worker * calls to {@link #ucol_getAvailable }. 706*0e209d39SAndroid Build Coastguard Worker * @return The number of locales for which collation rules are available. 707*0e209d39SAndroid Build Coastguard Worker * @see ucol_getAvailable 708*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 709*0e209d39SAndroid Build Coastguard Worker */ 710*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 711*0e209d39SAndroid Build Coastguard Worker ucol_countAvailable(void) __INTRODUCED_IN(__ANDROID_API_T__); 712*0e209d39SAndroid Build Coastguard Worker 713*0e209d39SAndroid Build Coastguard Worker 714*0e209d39SAndroid Build Coastguard Worker 715*0e209d39SAndroid Build Coastguard Worker #if !UCONFIG_NO_SERVICE 716*0e209d39SAndroid Build Coastguard Worker /** 717*0e209d39SAndroid Build Coastguard Worker * Create a string enumerator of all locales for which a valid 718*0e209d39SAndroid Build Coastguard Worker * collator may be opened. 719*0e209d39SAndroid Build Coastguard Worker * @param status input-output error code 720*0e209d39SAndroid Build Coastguard Worker * @return a string enumeration over locale strings. The caller is 721*0e209d39SAndroid Build Coastguard Worker * responsible for closing the result. 722*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 3.0 723*0e209d39SAndroid Build Coastguard Worker */ 724*0e209d39SAndroid Build Coastguard Worker U_CAPI UEnumeration* U_EXPORT2 725*0e209d39SAndroid Build Coastguard Worker ucol_openAvailableLocales(UErrorCode *status) __INTRODUCED_IN(__ANDROID_API_T__); 726*0e209d39SAndroid Build Coastguard Worker 727*0e209d39SAndroid Build Coastguard Worker 728*0e209d39SAndroid Build Coastguard Worker #endif 729*0e209d39SAndroid Build Coastguard Worker 730*0e209d39SAndroid Build Coastguard Worker /** 731*0e209d39SAndroid Build Coastguard Worker * Create a string enumerator of all possible keywords that are relevant to 732*0e209d39SAndroid Build Coastguard Worker * collation. At this point, the only recognized keyword for this 733*0e209d39SAndroid Build Coastguard Worker * service is "collation". 734*0e209d39SAndroid Build Coastguard Worker * @param status input-output error code 735*0e209d39SAndroid Build Coastguard Worker * @return a string enumeration over locale strings. The caller is 736*0e209d39SAndroid Build Coastguard Worker * responsible for closing the result. 737*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 3.0 738*0e209d39SAndroid Build Coastguard Worker */ 739*0e209d39SAndroid Build Coastguard Worker U_CAPI UEnumeration* U_EXPORT2 740*0e209d39SAndroid Build Coastguard Worker ucol_getKeywords(UErrorCode *status) __INTRODUCED_IN(__ANDROID_API_T__); 741*0e209d39SAndroid Build Coastguard Worker 742*0e209d39SAndroid Build Coastguard Worker 743*0e209d39SAndroid Build Coastguard Worker 744*0e209d39SAndroid Build Coastguard Worker /** 745*0e209d39SAndroid Build Coastguard Worker * Given a keyword, create a string enumeration of all values 746*0e209d39SAndroid Build Coastguard Worker * for that keyword that are currently in use. 747*0e209d39SAndroid Build Coastguard Worker * @param keyword a particular keyword as enumerated by 748*0e209d39SAndroid Build Coastguard Worker * ucol_getKeywords. If any other keyword is passed in, *status is set 749*0e209d39SAndroid Build Coastguard Worker * to U_ILLEGAL_ARGUMENT_ERROR. 750*0e209d39SAndroid Build Coastguard Worker * @param status input-output error code 751*0e209d39SAndroid Build Coastguard Worker * @return a string enumeration over collation keyword values, or NULL 752*0e209d39SAndroid Build Coastguard Worker * upon error. The caller is responsible for closing the result. 753*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 3.0 754*0e209d39SAndroid Build Coastguard Worker */ 755*0e209d39SAndroid Build Coastguard Worker U_CAPI UEnumeration* U_EXPORT2 756*0e209d39SAndroid Build Coastguard Worker ucol_getKeywordValues(const char *keyword, UErrorCode *status) __INTRODUCED_IN(__ANDROID_API_T__); 757*0e209d39SAndroid Build Coastguard Worker 758*0e209d39SAndroid Build Coastguard Worker 759*0e209d39SAndroid Build Coastguard Worker 760*0e209d39SAndroid Build Coastguard Worker /** 761*0e209d39SAndroid Build Coastguard Worker * Given a key and a locale, returns an array of string values in a preferred 762*0e209d39SAndroid Build Coastguard Worker * order that would make a difference. These are all and only those values where 763*0e209d39SAndroid Build Coastguard Worker * the open (creation) of the service with the locale formed from the input locale 764*0e209d39SAndroid Build Coastguard Worker * plus input keyword and that value has different behavior than creation with the 765*0e209d39SAndroid Build Coastguard Worker * input locale alone. 766*0e209d39SAndroid Build Coastguard Worker * @param key one of the keys supported by this service. For now, only 767*0e209d39SAndroid Build Coastguard Worker * "collation" is supported. 768*0e209d39SAndroid Build Coastguard Worker * @param locale the locale 769*0e209d39SAndroid Build Coastguard Worker * @param commonlyUsed if set to true it will return only commonly used values 770*0e209d39SAndroid Build Coastguard Worker * with the given locale in preferred order. Otherwise, 771*0e209d39SAndroid Build Coastguard Worker * it will return all the available values for the locale. 772*0e209d39SAndroid Build Coastguard Worker * @param status error status 773*0e209d39SAndroid Build Coastguard Worker * @return a string enumeration over keyword values for the given key and the locale. 774*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 4.2 775*0e209d39SAndroid Build Coastguard Worker */ 776*0e209d39SAndroid Build Coastguard Worker U_CAPI UEnumeration* U_EXPORT2 777*0e209d39SAndroid Build Coastguard Worker ucol_getKeywordValuesForLocale(const char* key, 778*0e209d39SAndroid Build Coastguard Worker const char* locale, 779*0e209d39SAndroid Build Coastguard Worker UBool commonlyUsed, 780*0e209d39SAndroid Build Coastguard Worker UErrorCode* status) __INTRODUCED_IN(__ANDROID_API_T__); 781*0e209d39SAndroid Build Coastguard Worker 782*0e209d39SAndroid Build Coastguard Worker 783*0e209d39SAndroid Build Coastguard Worker 784*0e209d39SAndroid Build Coastguard Worker /** 785*0e209d39SAndroid Build Coastguard Worker * Return the functionally equivalent locale for the specified 786*0e209d39SAndroid Build Coastguard Worker * input locale, with respect to given keyword, for the 787*0e209d39SAndroid Build Coastguard Worker * collation service. If two different input locale + keyword 788*0e209d39SAndroid Build Coastguard Worker * combinations produce the same result locale, then collators 789*0e209d39SAndroid Build Coastguard Worker * instantiated for these two different input locales will behave 790*0e209d39SAndroid Build Coastguard Worker * equivalently. The converse is not always true; two collators 791*0e209d39SAndroid Build Coastguard Worker * may in fact be equivalent, but return different results, due to 792*0e209d39SAndroid Build Coastguard Worker * internal details. The return result has no other meaning than 793*0e209d39SAndroid Build Coastguard Worker * that stated above, and implies nothing as to the relationship 794*0e209d39SAndroid Build Coastguard Worker * between the two locales. This is intended for use by 795*0e209d39SAndroid Build Coastguard Worker * applications who wish to cache collators, or otherwise reuse 796*0e209d39SAndroid Build Coastguard Worker * collators when possible. The functional equivalent may change 797*0e209d39SAndroid Build Coastguard Worker * over time. For more information, please see the <a 798*0e209d39SAndroid Build Coastguard Worker * href="https://unicode-org.github.io/icu/userguide/locale#locales-and-services"> 799*0e209d39SAndroid Build Coastguard Worker * Locales and Services</a> section of the ICU User Guide. 800*0e209d39SAndroid Build Coastguard Worker * @param result fillin for the functionally equivalent result locale 801*0e209d39SAndroid Build Coastguard Worker * @param resultCapacity capacity of the fillin buffer 802*0e209d39SAndroid Build Coastguard Worker * @param keyword a particular keyword as enumerated by 803*0e209d39SAndroid Build Coastguard Worker * ucol_getKeywords. 804*0e209d39SAndroid Build Coastguard Worker * @param locale the specified input locale 805*0e209d39SAndroid Build Coastguard Worker * @param isAvailable if non-NULL, pointer to a fillin parameter that 806*0e209d39SAndroid Build Coastguard Worker * on return indicates whether the specified input locale was 'available' 807*0e209d39SAndroid Build Coastguard Worker * to the collation service. A locale is defined as 'available' if it 808*0e209d39SAndroid Build Coastguard Worker * physically exists within the collation locale data. 809*0e209d39SAndroid Build Coastguard Worker * @param status pointer to input-output error code 810*0e209d39SAndroid Build Coastguard Worker * @return the actual buffer size needed for the locale. If greater 811*0e209d39SAndroid Build Coastguard Worker * than resultCapacity, the returned full name will be truncated and 812*0e209d39SAndroid Build Coastguard Worker * an error code will be returned. 813*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 3.0 814*0e209d39SAndroid Build Coastguard Worker */ 815*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 816*0e209d39SAndroid Build Coastguard Worker ucol_getFunctionalEquivalent(char* result, int32_t resultCapacity, 817*0e209d39SAndroid Build Coastguard Worker const char* keyword, const char* locale, 818*0e209d39SAndroid Build Coastguard Worker UBool* isAvailable, UErrorCode* status) __INTRODUCED_IN(__ANDROID_API_T__); 819*0e209d39SAndroid Build Coastguard Worker 820*0e209d39SAndroid Build Coastguard Worker 821*0e209d39SAndroid Build Coastguard Worker 822*0e209d39SAndroid Build Coastguard Worker 823*0e209d39SAndroid Build Coastguard Worker 824*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API 825*0e209d39SAndroid Build Coastguard Worker 826*0e209d39SAndroid Build Coastguard Worker 827*0e209d39SAndroid Build Coastguard Worker 828*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_DEPRECATED_API */ 829*0e209d39SAndroid Build Coastguard Worker 830*0e209d39SAndroid Build Coastguard Worker 831*0e209d39SAndroid Build Coastguard Worker /** 832*0e209d39SAndroid Build Coastguard Worker * Get a sort key for a string from a UCollator. 833*0e209d39SAndroid Build Coastguard Worker * Sort keys may be compared using <TT>strcmp</TT>. 834*0e209d39SAndroid Build Coastguard Worker * 835*0e209d39SAndroid Build Coastguard Worker * Note that sort keys are often less efficient than simply doing comparison. 836*0e209d39SAndroid Build Coastguard Worker * For more details, see the ICU User Guide. 837*0e209d39SAndroid Build Coastguard Worker * 838*0e209d39SAndroid Build Coastguard Worker * Like ICU functions that write to an output buffer, the buffer contents 839*0e209d39SAndroid Build Coastguard Worker * is undefined if the buffer capacity (resultLength parameter) is too small. 840*0e209d39SAndroid Build Coastguard Worker * Unlike ICU functions that write a string to an output buffer, 841*0e209d39SAndroid Build Coastguard Worker * the terminating zero byte is counted in the sort key length. 842*0e209d39SAndroid Build Coastguard Worker * @param coll The UCollator containing the collation rules. 843*0e209d39SAndroid Build Coastguard Worker * @param source The string to transform. 844*0e209d39SAndroid Build Coastguard Worker * @param sourceLength The length of source, or -1 if null-terminated. 845*0e209d39SAndroid Build Coastguard Worker * @param result A pointer to a buffer to receive the attribute. 846*0e209d39SAndroid Build Coastguard Worker * @param resultLength The maximum size of result. 847*0e209d39SAndroid Build Coastguard Worker * @return The size needed to fully store the sort key. 848*0e209d39SAndroid Build Coastguard Worker * If there was an internal error generating the sort key, 849*0e209d39SAndroid Build Coastguard Worker * a zero value is returned. 850*0e209d39SAndroid Build Coastguard Worker * @see ucol_keyHashCode 851*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 852*0e209d39SAndroid Build Coastguard Worker */ 853*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 854*0e209d39SAndroid Build Coastguard Worker ucol_getSortKey(const UCollator *coll, 855*0e209d39SAndroid Build Coastguard Worker const UChar *source, 856*0e209d39SAndroid Build Coastguard Worker int32_t sourceLength, 857*0e209d39SAndroid Build Coastguard Worker uint8_t *result, 858*0e209d39SAndroid Build Coastguard Worker int32_t resultLength) __INTRODUCED_IN(__ANDROID_API_T__); 859*0e209d39SAndroid Build Coastguard Worker 860*0e209d39SAndroid Build Coastguard Worker 861*0e209d39SAndroid Build Coastguard Worker 862*0e209d39SAndroid Build Coastguard Worker 863*0e209d39SAndroid Build Coastguard Worker 864*0e209d39SAndroid Build Coastguard Worker 865*0e209d39SAndroid Build Coastguard Worker /** enum that is taken by ucol_getBound API 866*0e209d39SAndroid Build Coastguard Worker * See below for explanation 867*0e209d39SAndroid Build Coastguard Worker * do not change the values assigned to the 868*0e209d39SAndroid Build Coastguard Worker * members of this enum. Underlying code 869*0e209d39SAndroid Build Coastguard Worker * depends on them having these numbers 870*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 871*0e209d39SAndroid Build Coastguard Worker */ 872*0e209d39SAndroid Build Coastguard Worker typedef enum UColBoundMode : int32_t { 873*0e209d39SAndroid Build Coastguard Worker /** lower bound */ 874*0e209d39SAndroid Build Coastguard Worker UCOL_BOUND_LOWER = 0, 875*0e209d39SAndroid Build Coastguard Worker /** upper bound that will match strings of exact size */ 876*0e209d39SAndroid Build Coastguard Worker UCOL_BOUND_UPPER = 1, 877*0e209d39SAndroid Build Coastguard Worker /** upper bound that will match all the strings that have the same initial substring as the given string */ 878*0e209d39SAndroid Build Coastguard Worker UCOL_BOUND_UPPER_LONG = 2, 879*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API 880*0e209d39SAndroid Build Coastguard Worker /** 881*0e209d39SAndroid Build Coastguard Worker * One more than the highest normal UColBoundMode value. 882*0e209d39SAndroid Build Coastguard Worker * \xrefitem deprecated "Deprecated" "Deprecated List" ICU 58 The numeric value may change over time, see ICU ticket #12420. 883*0e209d39SAndroid Build Coastguard Worker */ 884*0e209d39SAndroid Build Coastguard Worker UCOL_BOUND_VALUE_COUNT 885*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_DEPRECATED_API */ 886*0e209d39SAndroid Build Coastguard Worker } UColBoundMode; 887*0e209d39SAndroid Build Coastguard Worker 888*0e209d39SAndroid Build Coastguard Worker 889*0e209d39SAndroid Build Coastguard Worker 890*0e209d39SAndroid Build Coastguard Worker 891*0e209d39SAndroid Build Coastguard Worker 892*0e209d39SAndroid Build Coastguard Worker 893*0e209d39SAndroid Build Coastguard Worker 894*0e209d39SAndroid Build Coastguard Worker /** 895*0e209d39SAndroid Build Coastguard Worker * Merges two sort keys. The levels are merged with their corresponding counterparts 896*0e209d39SAndroid Build Coastguard Worker * (primaries with primaries, secondaries with secondaries etc.). Between the values 897*0e209d39SAndroid Build Coastguard Worker * from the same level a separator is inserted. 898*0e209d39SAndroid Build Coastguard Worker * 899*0e209d39SAndroid Build Coastguard Worker * This is useful, for example, for combining sort keys from first and last names 900*0e209d39SAndroid Build Coastguard Worker * to sort such pairs. 901*0e209d39SAndroid Build Coastguard Worker * See http://www.unicode.org/reports/tr10/#Merging_Sort_Keys 902*0e209d39SAndroid Build Coastguard Worker * 903*0e209d39SAndroid Build Coastguard Worker * The recommended way to achieve "merged" sorting is by 904*0e209d39SAndroid Build Coastguard Worker * concatenating strings with U+FFFE between them. 905*0e209d39SAndroid Build Coastguard Worker * The concatenation has the same sort order as the merged sort keys, 906*0e209d39SAndroid Build Coastguard Worker * but merge(getSortKey(str1), getSortKey(str2)) may differ from getSortKey(str1 + '\\uFFFE' + str2). 907*0e209d39SAndroid Build Coastguard Worker * Using strings with U+FFFE may yield shorter sort keys. 908*0e209d39SAndroid Build Coastguard Worker * 909*0e209d39SAndroid Build Coastguard Worker * For details about Sort Key Features see 910*0e209d39SAndroid Build Coastguard Worker * https://unicode-org.github.io/icu/userguide/collation/api#sort-key-features 911*0e209d39SAndroid Build Coastguard Worker * 912*0e209d39SAndroid Build Coastguard Worker * It is possible to merge multiple sort keys by consecutively merging 913*0e209d39SAndroid Build Coastguard Worker * another one with the intermediate result. 914*0e209d39SAndroid Build Coastguard Worker * 915*0e209d39SAndroid Build Coastguard Worker * The length of the merge result is the sum of the lengths of the input sort keys. 916*0e209d39SAndroid Build Coastguard Worker * 917*0e209d39SAndroid Build Coastguard Worker * Example (uncompressed): 918*0e209d39SAndroid Build Coastguard Worker * <pre>191B1D 01 050505 01 910505 00 919*0e209d39SAndroid Build Coastguard Worker * 1F2123 01 050505 01 910505 00</pre> 920*0e209d39SAndroid Build Coastguard Worker * will be merged as 921*0e209d39SAndroid Build Coastguard Worker * <pre>191B1D 02 1F2123 01 050505 02 050505 01 910505 02 910505 00</pre> 922*0e209d39SAndroid Build Coastguard Worker * 923*0e209d39SAndroid Build Coastguard Worker * If the destination buffer is not big enough, then its contents are undefined. 924*0e209d39SAndroid Build Coastguard Worker * If any of source lengths are zero or any of the source pointers are NULL/undefined, 925*0e209d39SAndroid Build Coastguard Worker * the result is of size zero. 926*0e209d39SAndroid Build Coastguard Worker * 927*0e209d39SAndroid Build Coastguard Worker * @param src1 the first sort key 928*0e209d39SAndroid Build Coastguard Worker * @param src1Length the length of the first sort key, including the zero byte at the end; 929*0e209d39SAndroid Build Coastguard Worker * can be -1 if the function is to find the length 930*0e209d39SAndroid Build Coastguard Worker * @param src2 the second sort key 931*0e209d39SAndroid Build Coastguard Worker * @param src2Length the length of the second sort key, including the zero byte at the end; 932*0e209d39SAndroid Build Coastguard Worker * can be -1 if the function is to find the length 933*0e209d39SAndroid Build Coastguard Worker * @param dest the buffer where the merged sort key is written, 934*0e209d39SAndroid Build Coastguard Worker * can be NULL if destCapacity==0 935*0e209d39SAndroid Build Coastguard Worker * @param destCapacity the number of bytes in the dest buffer 936*0e209d39SAndroid Build Coastguard Worker * @return the length of the merged sort key, src1Length+src2Length; 937*0e209d39SAndroid Build Coastguard Worker * can be larger than destCapacity, or 0 if an error occurs (only for illegal arguments), 938*0e209d39SAndroid Build Coastguard Worker * in which cases the contents of dest is undefined 939*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 940*0e209d39SAndroid Build Coastguard Worker */ 941*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 942*0e209d39SAndroid Build Coastguard Worker ucol_mergeSortkeys(const uint8_t *src1, int32_t src1Length, 943*0e209d39SAndroid Build Coastguard Worker const uint8_t *src2, int32_t src2Length, 944*0e209d39SAndroid Build Coastguard Worker uint8_t *dest, int32_t destCapacity) __INTRODUCED_IN(__ANDROID_API_T__); 945*0e209d39SAndroid Build Coastguard Worker 946*0e209d39SAndroid Build Coastguard Worker 947*0e209d39SAndroid Build Coastguard Worker 948*0e209d39SAndroid Build Coastguard Worker /** 949*0e209d39SAndroid Build Coastguard Worker * Universal attribute setter 950*0e209d39SAndroid Build Coastguard Worker * @param coll collator which attributes are to be changed 951*0e209d39SAndroid Build Coastguard Worker * @param attr attribute type 952*0e209d39SAndroid Build Coastguard Worker * @param value attribute value 953*0e209d39SAndroid Build Coastguard Worker * @param status to indicate whether the operation went on smoothly or there were errors 954*0e209d39SAndroid Build Coastguard Worker * @see UColAttribute 955*0e209d39SAndroid Build Coastguard Worker * @see UColAttributeValue 956*0e209d39SAndroid Build Coastguard Worker * @see ucol_getAttribute 957*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 958*0e209d39SAndroid Build Coastguard Worker */ 959*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 960*0e209d39SAndroid Build Coastguard Worker ucol_setAttribute(UCollator *coll, UColAttribute attr, UColAttributeValue value, UErrorCode *status) __INTRODUCED_IN(__ANDROID_API_T__); 961*0e209d39SAndroid Build Coastguard Worker 962*0e209d39SAndroid Build Coastguard Worker 963*0e209d39SAndroid Build Coastguard Worker 964*0e209d39SAndroid Build Coastguard Worker /** 965*0e209d39SAndroid Build Coastguard Worker * Universal attribute getter 966*0e209d39SAndroid Build Coastguard Worker * @param coll collator which attributes are to be changed 967*0e209d39SAndroid Build Coastguard Worker * @param attr attribute type 968*0e209d39SAndroid Build Coastguard Worker * @return attribute value 969*0e209d39SAndroid Build Coastguard Worker * @param status to indicate whether the operation went on smoothly or there were errors 970*0e209d39SAndroid Build Coastguard Worker * @see UColAttribute 971*0e209d39SAndroid Build Coastguard Worker * @see UColAttributeValue 972*0e209d39SAndroid Build Coastguard Worker * @see ucol_setAttribute 973*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 2.0 974*0e209d39SAndroid Build Coastguard Worker */ 975*0e209d39SAndroid Build Coastguard Worker U_CAPI UColAttributeValue U_EXPORT2 976*0e209d39SAndroid Build Coastguard Worker ucol_getAttribute(const UCollator *coll, UColAttribute attr, UErrorCode *status) __INTRODUCED_IN(__ANDROID_API_T__); 977*0e209d39SAndroid Build Coastguard Worker 978*0e209d39SAndroid Build Coastguard Worker 979*0e209d39SAndroid Build Coastguard Worker 980*0e209d39SAndroid Build Coastguard Worker /** 981*0e209d39SAndroid Build Coastguard Worker * Sets the variable top to the top of the specified reordering group. 982*0e209d39SAndroid Build Coastguard Worker * The variable top determines the highest-sorting character 983*0e209d39SAndroid Build Coastguard Worker * which is affected by UCOL_ALTERNATE_HANDLING. 984*0e209d39SAndroid Build Coastguard Worker * If that attribute is set to UCOL_NON_IGNORABLE, then the variable top has no effect. 985*0e209d39SAndroid Build Coastguard Worker * @param coll the collator 986*0e209d39SAndroid Build Coastguard Worker * @param group one of UCOL_REORDER_CODE_SPACE, UCOL_REORDER_CODE_PUNCTUATION, 987*0e209d39SAndroid Build Coastguard Worker * UCOL_REORDER_CODE_SYMBOL, UCOL_REORDER_CODE_CURRENCY; 988*0e209d39SAndroid Build Coastguard Worker * or UCOL_REORDER_CODE_DEFAULT to restore the default max variable group 989*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Standard ICU error code. Its input value must 990*0e209d39SAndroid Build Coastguard Worker * pass the U_SUCCESS() test, or else the function returns 991*0e209d39SAndroid Build Coastguard Worker * immediately. Check for U_FAILURE() on output or use with 992*0e209d39SAndroid Build Coastguard Worker * function chaining. (See User Guide for details.) 993*0e209d39SAndroid Build Coastguard Worker * @see ucol_getMaxVariable 994*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 53 995*0e209d39SAndroid Build Coastguard Worker */ 996*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 997*0e209d39SAndroid Build Coastguard Worker ucol_setMaxVariable(UCollator *coll, UColReorderCode group, UErrorCode *pErrorCode) __INTRODUCED_IN(__ANDROID_API_T__); 998*0e209d39SAndroid Build Coastguard Worker 999*0e209d39SAndroid Build Coastguard Worker 1000*0e209d39SAndroid Build Coastguard Worker 1001*0e209d39SAndroid Build Coastguard Worker /** 1002*0e209d39SAndroid Build Coastguard Worker * Returns the maximum reordering group whose characters are affected by UCOL_ALTERNATE_HANDLING. 1003*0e209d39SAndroid Build Coastguard Worker * @param coll the collator 1004*0e209d39SAndroid Build Coastguard Worker * @return the maximum variable reordering group. 1005*0e209d39SAndroid Build Coastguard Worker * @see ucol_setMaxVariable 1006*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 53 1007*0e209d39SAndroid Build Coastguard Worker */ 1008*0e209d39SAndroid Build Coastguard Worker U_CAPI UColReorderCode U_EXPORT2 1009*0e209d39SAndroid Build Coastguard Worker ucol_getMaxVariable(const UCollator *coll) __INTRODUCED_IN(__ANDROID_API_T__); 1010*0e209d39SAndroid Build Coastguard Worker 1011*0e209d39SAndroid Build Coastguard Worker 1012*0e209d39SAndroid Build Coastguard Worker 1013*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API 1014*0e209d39SAndroid Build Coastguard Worker 1015*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_DEPRECATED_API */ 1016*0e209d39SAndroid Build Coastguard Worker 1017*0e209d39SAndroid Build Coastguard Worker 1018*0e209d39SAndroid Build Coastguard Worker 1019*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API 1020*0e209d39SAndroid Build Coastguard Worker 1021*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_DEPRECATED_API */ 1022*0e209d39SAndroid Build Coastguard Worker 1023*0e209d39SAndroid Build Coastguard Worker /** 1024*0e209d39SAndroid Build Coastguard Worker * Thread safe cloning operation. The result is a clone of a given collator. 1025*0e209d39SAndroid Build Coastguard Worker * @param coll collator to be cloned 1026*0e209d39SAndroid Build Coastguard Worker * @param status to indicate whether the operation went on smoothly or there were errors 1027*0e209d39SAndroid Build Coastguard Worker * @return pointer to the new clone 1028*0e209d39SAndroid Build Coastguard Worker * @see ucol_open 1029*0e209d39SAndroid Build Coastguard Worker * @see ucol_openRules 1030*0e209d39SAndroid Build Coastguard Worker * @see ucol_close 1031*0e209d39SAndroid Build Coastguard Worker * \xrefitem stable "Stable" "Stable List" ICU 71 1032*0e209d39SAndroid Build Coastguard Worker */ 1033*0e209d39SAndroid Build Coastguard Worker U_CAPI UCollator* U_EXPORT2 ucol_clone(const UCollator *coll, UErrorCode *status) __INTRODUCED_IN(__ANDROID_API_T__); 1034*0e209d39SAndroid Build Coastguard Worker 1035*0e209d39SAndroid Build Coastguard Worker 1036*0e209d39SAndroid Build Coastguard Worker 1037*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API 1038*0e209d39SAndroid Build Coastguard Worker 1039*0e209d39SAndroid Build Coastguard Worker 1040*0e209d39SAndroid Build Coastguard Worker 1041*0e209d39SAndroid Build Coastguard Worker 1042*0e209d39SAndroid Build Coastguard Worker /** default memory size for the new clone. 1043*0e209d39SAndroid Build Coastguard Worker * \xrefitem deprecated "Deprecated" "Deprecated List" ICU 52. Do not rely on ucol_safeClone() cloning into any provided buffer. 1044*0e209d39SAndroid Build Coastguard Worker */ 1045*0e209d39SAndroid Build Coastguard Worker #define U_COL_SAFECLONE_BUFFERSIZE 1 1046*0e209d39SAndroid Build Coastguard Worker 1047*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_DEPRECATED_API */ 1048*0e209d39SAndroid Build Coastguard Worker 1049*0e209d39SAndroid Build Coastguard Worker 1050*0e209d39SAndroid Build Coastguard Worker 1051*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API 1052*0e209d39SAndroid Build Coastguard Worker 1053*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_DEPRECATED_API */ 1054*0e209d39SAndroid Build Coastguard Worker 1055*0e209d39SAndroid Build Coastguard Worker 1056*0e209d39SAndroid Build Coastguard Worker 1057*0e209d39SAndroid Build Coastguard Worker 1058*0e209d39SAndroid Build Coastguard Worker 1059*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_INTERNAL_API 1060*0e209d39SAndroid Build Coastguard Worker 1061*0e209d39SAndroid Build Coastguard Worker 1062*0e209d39SAndroid Build Coastguard Worker 1063*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_INTERNAL_API */ 1064*0e209d39SAndroid Build Coastguard Worker 1065*0e209d39SAndroid Build Coastguard Worker 1066*0e209d39SAndroid Build Coastguard Worker 1067*0e209d39SAndroid Build Coastguard Worker 1068*0e209d39SAndroid Build Coastguard Worker 1069*0e209d39SAndroid Build Coastguard Worker 1070*0e209d39SAndroid Build Coastguard Worker #endif /* #if !UCONFIG_NO_COLLATION */ 1071*0e209d39SAndroid Build Coastguard Worker 1072*0e209d39SAndroid Build Coastguard Worker #endif 1073*0e209d39SAndroid Build Coastguard Worker 1074*0e209d39SAndroid Build Coastguard Worker /** @} */ // addtogroup 1075