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/unorm.h" 18*0e209d39SAndroid Build Coastguard Worker #include "unicode/parseerr.h" 19*0e209d39SAndroid Build Coastguard Worker #include "unicode/uloc.h" 20*0e209d39SAndroid Build Coastguard Worker #include "unicode/uset.h" 21*0e209d39SAndroid Build Coastguard Worker #include "unicode/uscript.h" 22*0e209d39SAndroid Build Coastguard Worker 23*0e209d39SAndroid Build Coastguard Worker #if U_SHOW_CPLUSPLUS_API 24*0e209d39SAndroid Build Coastguard Worker #include "unicode/localpointer.h" 25*0e209d39SAndroid Build Coastguard Worker #endif // U_SHOW_CPLUSPLUS_API 26*0e209d39SAndroid Build Coastguard Worker 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 * @stable 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 * @stable ICU 2.0 75*0e209d39SAndroid Build Coastguard Worker */ 76*0e209d39SAndroid Build Coastguard Worker typedef enum { 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 * @stable ICU 2.0 91*0e209d39SAndroid Build Coastguard Worker */ 92*0e209d39SAndroid Build Coastguard Worker typedef enum { 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 * @deprecated 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 * @stable ICU 4.8 148*0e209d39SAndroid Build Coastguard Worker */ 149*0e209d39SAndroid Build Coastguard Worker typedef enum { 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 * @stable 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 * @stable 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 * @stable 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 * @stable 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 * @stable 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 * @stable 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 * @stable 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 * @stable 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 * @stable 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 * @deprecated 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 * @stable 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 * @stable ICU 2.0 244*0e209d39SAndroid Build Coastguard Worker */ 245*0e209d39SAndroid Build Coastguard Worker typedef enum { 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 * @stable 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 * @stable 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 * @stable 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 * @stable 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 * @stable 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 * @stable 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 * @stable 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 * @deprecated 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 * @stable 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 * @deprecated 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 /** Options for retrieving the rule string 370*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 371*0e209d39SAndroid Build Coastguard Worker */ 372*0e209d39SAndroid Build Coastguard Worker typedef enum { 373*0e209d39SAndroid Build Coastguard Worker /** 374*0e209d39SAndroid Build Coastguard Worker * Retrieves the tailoring rules only. 375*0e209d39SAndroid Build Coastguard Worker * Same as calling the version of getRules() without UColRuleOption. 376*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 377*0e209d39SAndroid Build Coastguard Worker */ 378*0e209d39SAndroid Build Coastguard Worker UCOL_TAILORING_ONLY, 379*0e209d39SAndroid Build Coastguard Worker /** 380*0e209d39SAndroid Build Coastguard Worker * Retrieves the "UCA rules" concatenated with the tailoring rules. 381*0e209d39SAndroid Build Coastguard Worker * The "UCA rules" are an <i>approximation</i> of the root collator's sort order. 382*0e209d39SAndroid Build Coastguard Worker * They are almost never used or useful at runtime and can be removed from the data. 383*0e209d39SAndroid Build Coastguard Worker * See https://unicode-org.github.io/icu/userguide/collation/customization#building-on-existing-locales 384*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 385*0e209d39SAndroid Build Coastguard Worker */ 386*0e209d39SAndroid Build Coastguard Worker UCOL_FULL_RULES 387*0e209d39SAndroid Build Coastguard Worker } UColRuleOption ; 388*0e209d39SAndroid Build Coastguard Worker 389*0e209d39SAndroid Build Coastguard Worker /** 390*0e209d39SAndroid Build Coastguard Worker * Open a UCollator for comparing strings. 391*0e209d39SAndroid Build Coastguard Worker * 392*0e209d39SAndroid Build Coastguard Worker * For some languages, multiple collation types are available; 393*0e209d39SAndroid Build Coastguard Worker * for example, "de@collation=phonebook". 394*0e209d39SAndroid Build Coastguard Worker * Starting with ICU 54, collation attributes can be specified via locale keywords as well, 395*0e209d39SAndroid Build Coastguard Worker * in the old locale extension syntax ("el@colCaseFirst=upper") 396*0e209d39SAndroid Build Coastguard Worker * or in language tag syntax ("el-u-kf-upper"). 397*0e209d39SAndroid Build Coastguard Worker * See <a href="https://unicode-org.github.io/icu/userguide/collation/api">User Guide: Collation API</a>. 398*0e209d39SAndroid Build Coastguard Worker * 399*0e209d39SAndroid Build Coastguard Worker * The UCollator pointer is used in all the calls to the Collation 400*0e209d39SAndroid Build Coastguard Worker * service. After finished, collator must be disposed of by calling 401*0e209d39SAndroid Build Coastguard Worker * {@link #ucol_close }. 402*0e209d39SAndroid Build Coastguard Worker * @param loc The locale containing the required collation rules. 403*0e209d39SAndroid Build Coastguard Worker * Special values for locales can be passed in - 404*0e209d39SAndroid Build Coastguard Worker * if NULL is passed for the locale, the default locale 405*0e209d39SAndroid Build Coastguard Worker * collation rules will be used. If empty string ("") or 406*0e209d39SAndroid Build Coastguard Worker * "root" are passed, the root collator will be returned. 407*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to a UErrorCode to receive any errors 408*0e209d39SAndroid Build Coastguard Worker * @return A pointer to a UCollator, or 0 if an error occurred. 409*0e209d39SAndroid Build Coastguard Worker * @see ucol_openRules 410*0e209d39SAndroid Build Coastguard Worker * @see ucol_clone 411*0e209d39SAndroid Build Coastguard Worker * @see ucol_close 412*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 413*0e209d39SAndroid Build Coastguard Worker */ 414*0e209d39SAndroid Build Coastguard Worker U_CAPI UCollator* U_EXPORT2 415*0e209d39SAndroid Build Coastguard Worker ucol_open(const char *loc, UErrorCode *status); 416*0e209d39SAndroid Build Coastguard Worker 417*0e209d39SAndroid Build Coastguard Worker /** 418*0e209d39SAndroid Build Coastguard Worker * Produce a UCollator instance according to the rules supplied. 419*0e209d39SAndroid Build Coastguard Worker * The rules are used to change the default ordering, defined in the 420*0e209d39SAndroid Build Coastguard Worker * UCA in a process called tailoring. The resulting UCollator pointer 421*0e209d39SAndroid Build Coastguard Worker * can be used in the same way as the one obtained by {@link #ucol_strcoll }. 422*0e209d39SAndroid Build Coastguard Worker * @param rules A string describing the collation rules. For the syntax 423*0e209d39SAndroid Build Coastguard Worker * of the rules please see users guide. 424*0e209d39SAndroid Build Coastguard Worker * @param rulesLength The length of rules, or -1 if null-terminated. 425*0e209d39SAndroid Build Coastguard Worker * @param normalizationMode The normalization mode: One of 426*0e209d39SAndroid Build Coastguard Worker * UCOL_OFF (expect the text to not need normalization), 427*0e209d39SAndroid Build Coastguard Worker * UCOL_ON (normalize), or 428*0e209d39SAndroid Build Coastguard Worker * UCOL_DEFAULT (set the mode according to the rules) 429*0e209d39SAndroid Build Coastguard Worker * @param strength The default collation strength; one of UCOL_PRIMARY, UCOL_SECONDARY, 430*0e209d39SAndroid Build Coastguard Worker * UCOL_TERTIARY, UCOL_IDENTICAL,UCOL_DEFAULT_STRENGTH - can be also set in the rules. 431*0e209d39SAndroid Build Coastguard Worker * @param parseError A pointer to UParseError to receive information about errors 432*0e209d39SAndroid Build Coastguard Worker * occurred during parsing. This argument can currently be set 433*0e209d39SAndroid Build Coastguard Worker * to NULL, but at users own risk. Please provide a real structure. 434*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to a UErrorCode to receive any errors 435*0e209d39SAndroid Build Coastguard Worker * @return A pointer to a UCollator. It is not guaranteed that NULL be returned in case 436*0e209d39SAndroid Build Coastguard Worker * of error - please use status argument to check for errors. 437*0e209d39SAndroid Build Coastguard Worker * @see ucol_open 438*0e209d39SAndroid Build Coastguard Worker * @see ucol_clone 439*0e209d39SAndroid Build Coastguard Worker * @see ucol_close 440*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 441*0e209d39SAndroid Build Coastguard Worker */ 442*0e209d39SAndroid Build Coastguard Worker U_CAPI UCollator* U_EXPORT2 443*0e209d39SAndroid Build Coastguard Worker ucol_openRules( const UChar *rules, 444*0e209d39SAndroid Build Coastguard Worker int32_t rulesLength, 445*0e209d39SAndroid Build Coastguard Worker UColAttributeValue normalizationMode, 446*0e209d39SAndroid Build Coastguard Worker UCollationStrength strength, 447*0e209d39SAndroid Build Coastguard Worker UParseError *parseError, 448*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 449*0e209d39SAndroid Build Coastguard Worker 450*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API 451*0e209d39SAndroid Build Coastguard Worker /** 452*0e209d39SAndroid Build Coastguard Worker * Open a collator defined by a short form string. 453*0e209d39SAndroid Build Coastguard Worker * The structure and the syntax of the string is defined in the "Naming collators" 454*0e209d39SAndroid Build Coastguard Worker * section of the users guide: 455*0e209d39SAndroid Build Coastguard Worker * https://unicode-org.github.io/icu/userguide/collation/concepts#collator-naming-scheme 456*0e209d39SAndroid Build Coastguard Worker * Attributes are overridden by the subsequent attributes. So, for "S2_S3", final 457*0e209d39SAndroid Build Coastguard Worker * strength will be 3. 3066bis locale overrides individual locale parts. 458*0e209d39SAndroid Build Coastguard Worker * The call to this function is equivalent to a call to ucol_open, followed by a 459*0e209d39SAndroid Build Coastguard Worker * series of calls to ucol_setAttribute and ucol_setVariableTop. 460*0e209d39SAndroid Build Coastguard Worker * @param definition A short string containing a locale and a set of attributes. 461*0e209d39SAndroid Build Coastguard Worker * Attributes not explicitly mentioned are left at the default 462*0e209d39SAndroid Build Coastguard Worker * state for a locale. 463*0e209d39SAndroid Build Coastguard Worker * @param parseError if not NULL, structure that will get filled with error's pre 464*0e209d39SAndroid Build Coastguard Worker * and post context in case of error. 465*0e209d39SAndroid Build Coastguard Worker * @param forceDefaults if false, the settings that are the same as the collator 466*0e209d39SAndroid Build Coastguard Worker * default settings will not be applied (for example, setting 467*0e209d39SAndroid Build Coastguard Worker * French secondary on a French collator would not be executed). 468*0e209d39SAndroid Build Coastguard Worker * If true, all the settings will be applied regardless of the 469*0e209d39SAndroid Build Coastguard Worker * collator default value. If the definition 470*0e209d39SAndroid Build Coastguard Worker * strings are to be cached, should be set to false. 471*0e209d39SAndroid Build Coastguard Worker * @param status Error code. Apart from regular error conditions connected to 472*0e209d39SAndroid Build Coastguard Worker * instantiating collators (like out of memory or similar), this 473*0e209d39SAndroid Build Coastguard Worker * API will return an error if an invalid attribute or attribute/value 474*0e209d39SAndroid Build Coastguard Worker * combination is specified. 475*0e209d39SAndroid Build Coastguard Worker * @return A pointer to a UCollator or 0 if an error occurred (including an 476*0e209d39SAndroid Build Coastguard Worker * invalid attribute). 477*0e209d39SAndroid Build Coastguard Worker * @see ucol_open 478*0e209d39SAndroid Build Coastguard Worker * @see ucol_setAttribute 479*0e209d39SAndroid Build Coastguard Worker * @see ucol_setVariableTop 480*0e209d39SAndroid Build Coastguard Worker * @see ucol_getShortDefinitionString 481*0e209d39SAndroid Build Coastguard Worker * @see ucol_normalizeShortDefinitionString 482*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 54 Use ucol_open() with language tag collation keywords instead. 483*0e209d39SAndroid Build Coastguard Worker */ 484*0e209d39SAndroid Build Coastguard Worker U_DEPRECATED UCollator* U_EXPORT2 485*0e209d39SAndroid Build Coastguard Worker ucol_openFromShortString( const char *definition, 486*0e209d39SAndroid Build Coastguard Worker UBool forceDefaults, 487*0e209d39SAndroid Build Coastguard Worker UParseError *parseError, 488*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 489*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_DEPRECATED_API */ 490*0e209d39SAndroid Build Coastguard Worker 491*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API 492*0e209d39SAndroid Build Coastguard Worker /** 493*0e209d39SAndroid Build Coastguard Worker * Get a set containing the contractions defined by the collator. The set includes 494*0e209d39SAndroid Build Coastguard Worker * both the root collator's contractions and the contractions defined by the collator. This set 495*0e209d39SAndroid Build Coastguard Worker * will contain only strings. If a tailoring explicitly suppresses contractions from 496*0e209d39SAndroid Build Coastguard Worker * the root collator (like Russian), removed contractions will not be in the resulting set. 497*0e209d39SAndroid Build Coastguard Worker * @param coll collator 498*0e209d39SAndroid Build Coastguard Worker * @param conts the set to hold the result. It gets emptied before 499*0e209d39SAndroid Build Coastguard Worker * contractions are added. 500*0e209d39SAndroid Build Coastguard Worker * @param status to hold the error code 501*0e209d39SAndroid Build Coastguard Worker * @return the size of the contraction set 502*0e209d39SAndroid Build Coastguard Worker * 503*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 3.4, use ucol_getContractionsAndExpansions instead 504*0e209d39SAndroid Build Coastguard Worker */ 505*0e209d39SAndroid Build Coastguard Worker U_DEPRECATED int32_t U_EXPORT2 506*0e209d39SAndroid Build Coastguard Worker ucol_getContractions( const UCollator *coll, 507*0e209d39SAndroid Build Coastguard Worker USet *conts, 508*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 509*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_DEPRECATED_API */ 510*0e209d39SAndroid Build Coastguard Worker 511*0e209d39SAndroid Build Coastguard Worker /** 512*0e209d39SAndroid Build Coastguard Worker * Get a set containing the expansions defined by the collator. The set includes 513*0e209d39SAndroid Build Coastguard Worker * both the root collator's expansions and the expansions defined by the tailoring 514*0e209d39SAndroid Build Coastguard Worker * @param coll collator 515*0e209d39SAndroid Build Coastguard Worker * @param contractions if not NULL, the set to hold the contractions 516*0e209d39SAndroid Build Coastguard Worker * @param expansions if not NULL, the set to hold the expansions 517*0e209d39SAndroid Build Coastguard Worker * @param addPrefixes add the prefix contextual elements to contractions 518*0e209d39SAndroid Build Coastguard Worker * @param status to hold the error code 519*0e209d39SAndroid Build Coastguard Worker * 520*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.4 521*0e209d39SAndroid Build Coastguard Worker */ 522*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 523*0e209d39SAndroid Build Coastguard Worker ucol_getContractionsAndExpansions( const UCollator *coll, 524*0e209d39SAndroid Build Coastguard Worker USet *contractions, USet *expansions, 525*0e209d39SAndroid Build Coastguard Worker UBool addPrefixes, UErrorCode *status); 526*0e209d39SAndroid Build Coastguard Worker 527*0e209d39SAndroid Build Coastguard Worker /** 528*0e209d39SAndroid Build Coastguard Worker * Close a UCollator. 529*0e209d39SAndroid Build Coastguard Worker * Once closed, a UCollator should not be used. Every open collator should 530*0e209d39SAndroid Build Coastguard Worker * be closed. Otherwise, a memory leak will result. 531*0e209d39SAndroid Build Coastguard Worker * @param coll The UCollator to close. 532*0e209d39SAndroid Build Coastguard Worker * @see ucol_open 533*0e209d39SAndroid Build Coastguard Worker * @see ucol_openRules 534*0e209d39SAndroid Build Coastguard Worker * @see ucol_clone 535*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 536*0e209d39SAndroid Build Coastguard Worker */ 537*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 538*0e209d39SAndroid Build Coastguard Worker ucol_close(UCollator *coll); 539*0e209d39SAndroid Build Coastguard Worker 540*0e209d39SAndroid Build Coastguard Worker #if U_SHOW_CPLUSPLUS_API 541*0e209d39SAndroid Build Coastguard Worker 542*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_BEGIN 543*0e209d39SAndroid Build Coastguard Worker 544*0e209d39SAndroid Build Coastguard Worker /** 545*0e209d39SAndroid Build Coastguard Worker * \class LocalUCollatorPointer 546*0e209d39SAndroid Build Coastguard Worker * "Smart pointer" class, closes a UCollator via ucol_close(). 547*0e209d39SAndroid Build Coastguard Worker * For most methods see the LocalPointerBase base class. 548*0e209d39SAndroid Build Coastguard Worker * 549*0e209d39SAndroid Build Coastguard Worker * @see LocalPointerBase 550*0e209d39SAndroid Build Coastguard Worker * @see LocalPointer 551*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.4 552*0e209d39SAndroid Build Coastguard Worker */ 553*0e209d39SAndroid Build Coastguard Worker U_DEFINE_LOCAL_OPEN_POINTER(LocalUCollatorPointer, UCollator, ucol_close); 554*0e209d39SAndroid Build Coastguard Worker 555*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_END 556*0e209d39SAndroid Build Coastguard Worker 557*0e209d39SAndroid Build Coastguard Worker #endif 558*0e209d39SAndroid Build Coastguard Worker 559*0e209d39SAndroid Build Coastguard Worker /** 560*0e209d39SAndroid Build Coastguard Worker * Compare two strings. 561*0e209d39SAndroid Build Coastguard Worker * The strings will be compared using the options already specified. 562*0e209d39SAndroid Build Coastguard Worker * @param coll The UCollator containing the comparison rules. 563*0e209d39SAndroid Build Coastguard Worker * @param source The source string. 564*0e209d39SAndroid Build Coastguard Worker * @param sourceLength The length of source, or -1 if null-terminated. 565*0e209d39SAndroid Build Coastguard Worker * @param target The target string. 566*0e209d39SAndroid Build Coastguard Worker * @param targetLength The length of target, or -1 if null-terminated. 567*0e209d39SAndroid Build Coastguard Worker * @return The result of comparing the strings; one of UCOL_EQUAL, 568*0e209d39SAndroid Build Coastguard Worker * UCOL_GREATER, UCOL_LESS 569*0e209d39SAndroid Build Coastguard Worker * @see ucol_greater 570*0e209d39SAndroid Build Coastguard Worker * @see ucol_greaterOrEqual 571*0e209d39SAndroid Build Coastguard Worker * @see ucol_equal 572*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 573*0e209d39SAndroid Build Coastguard Worker */ 574*0e209d39SAndroid Build Coastguard Worker U_CAPI UCollationResult U_EXPORT2 575*0e209d39SAndroid Build Coastguard Worker ucol_strcoll( const UCollator *coll, 576*0e209d39SAndroid Build Coastguard Worker const UChar *source, 577*0e209d39SAndroid Build Coastguard Worker int32_t sourceLength, 578*0e209d39SAndroid Build Coastguard Worker const UChar *target, 579*0e209d39SAndroid Build Coastguard Worker int32_t targetLength); 580*0e209d39SAndroid Build Coastguard Worker 581*0e209d39SAndroid Build Coastguard Worker /** 582*0e209d39SAndroid Build Coastguard Worker * Compare two strings in UTF-8. 583*0e209d39SAndroid Build Coastguard Worker * The strings will be compared using the options already specified. 584*0e209d39SAndroid Build Coastguard Worker * Note: When input string contains malformed a UTF-8 byte sequence, 585*0e209d39SAndroid Build Coastguard Worker * this function treats these bytes as REPLACEMENT CHARACTER (U+FFFD). 586*0e209d39SAndroid Build Coastguard Worker * @param coll The UCollator containing the comparison rules. 587*0e209d39SAndroid Build Coastguard Worker * @param source The source UTF-8 string. 588*0e209d39SAndroid Build Coastguard Worker * @param sourceLength The length of source, or -1 if null-terminated. 589*0e209d39SAndroid Build Coastguard Worker * @param target The target UTF-8 string. 590*0e209d39SAndroid Build Coastguard Worker * @param targetLength The length of target, or -1 if null-terminated. 591*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to a UErrorCode to receive any errors 592*0e209d39SAndroid Build Coastguard Worker * @return The result of comparing the strings; one of UCOL_EQUAL, 593*0e209d39SAndroid Build Coastguard Worker * UCOL_GREATER, UCOL_LESS 594*0e209d39SAndroid Build Coastguard Worker * @see ucol_greater 595*0e209d39SAndroid Build Coastguard Worker * @see ucol_greaterOrEqual 596*0e209d39SAndroid Build Coastguard Worker * @see ucol_equal 597*0e209d39SAndroid Build Coastguard Worker * @stable ICU 50 598*0e209d39SAndroid Build Coastguard Worker */ 599*0e209d39SAndroid Build Coastguard Worker U_CAPI UCollationResult U_EXPORT2 600*0e209d39SAndroid Build Coastguard Worker ucol_strcollUTF8( 601*0e209d39SAndroid Build Coastguard Worker const UCollator *coll, 602*0e209d39SAndroid Build Coastguard Worker const char *source, 603*0e209d39SAndroid Build Coastguard Worker int32_t sourceLength, 604*0e209d39SAndroid Build Coastguard Worker const char *target, 605*0e209d39SAndroid Build Coastguard Worker int32_t targetLength, 606*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 607*0e209d39SAndroid Build Coastguard Worker 608*0e209d39SAndroid Build Coastguard Worker /** 609*0e209d39SAndroid Build Coastguard Worker * Determine if one string is greater than another. 610*0e209d39SAndroid Build Coastguard Worker * This function is equivalent to {@link #ucol_strcoll } == UCOL_GREATER 611*0e209d39SAndroid Build Coastguard Worker * @param coll The UCollator containing the comparison rules. 612*0e209d39SAndroid Build Coastguard Worker * @param source The source string. 613*0e209d39SAndroid Build Coastguard Worker * @param sourceLength The length of source, or -1 if null-terminated. 614*0e209d39SAndroid Build Coastguard Worker * @param target The target string. 615*0e209d39SAndroid Build Coastguard Worker * @param targetLength The length of target, or -1 if null-terminated. 616*0e209d39SAndroid Build Coastguard Worker * @return true if source is greater than target, false otherwise. 617*0e209d39SAndroid Build Coastguard Worker * @see ucol_strcoll 618*0e209d39SAndroid Build Coastguard Worker * @see ucol_greaterOrEqual 619*0e209d39SAndroid Build Coastguard Worker * @see ucol_equal 620*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 621*0e209d39SAndroid Build Coastguard Worker */ 622*0e209d39SAndroid Build Coastguard Worker U_CAPI UBool U_EXPORT2 623*0e209d39SAndroid Build Coastguard Worker ucol_greater(const UCollator *coll, 624*0e209d39SAndroid Build Coastguard Worker const UChar *source, int32_t sourceLength, 625*0e209d39SAndroid Build Coastguard Worker const UChar *target, int32_t targetLength); 626*0e209d39SAndroid Build Coastguard Worker 627*0e209d39SAndroid Build Coastguard Worker /** 628*0e209d39SAndroid Build Coastguard Worker * Determine if one string is greater than or equal to another. 629*0e209d39SAndroid Build Coastguard Worker * This function is equivalent to {@link #ucol_strcoll } != UCOL_LESS 630*0e209d39SAndroid Build Coastguard Worker * @param coll The UCollator containing the comparison rules. 631*0e209d39SAndroid Build Coastguard Worker * @param source The source string. 632*0e209d39SAndroid Build Coastguard Worker * @param sourceLength The length of source, or -1 if null-terminated. 633*0e209d39SAndroid Build Coastguard Worker * @param target The target string. 634*0e209d39SAndroid Build Coastguard Worker * @param targetLength The length of target, or -1 if null-terminated. 635*0e209d39SAndroid Build Coastguard Worker * @return true if source is greater than or equal to target, false otherwise. 636*0e209d39SAndroid Build Coastguard Worker * @see ucol_strcoll 637*0e209d39SAndroid Build Coastguard Worker * @see ucol_greater 638*0e209d39SAndroid Build Coastguard Worker * @see ucol_equal 639*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 640*0e209d39SAndroid Build Coastguard Worker */ 641*0e209d39SAndroid Build Coastguard Worker U_CAPI UBool U_EXPORT2 642*0e209d39SAndroid Build Coastguard Worker ucol_greaterOrEqual(const UCollator *coll, 643*0e209d39SAndroid Build Coastguard Worker const UChar *source, int32_t sourceLength, 644*0e209d39SAndroid Build Coastguard Worker const UChar *target, int32_t targetLength); 645*0e209d39SAndroid Build Coastguard Worker 646*0e209d39SAndroid Build Coastguard Worker /** 647*0e209d39SAndroid Build Coastguard Worker * Compare two strings for equality. 648*0e209d39SAndroid Build Coastguard Worker * This function is equivalent to {@link #ucol_strcoll } == UCOL_EQUAL 649*0e209d39SAndroid Build Coastguard Worker * @param coll The UCollator containing the comparison rules. 650*0e209d39SAndroid Build Coastguard Worker * @param source The source string. 651*0e209d39SAndroid Build Coastguard Worker * @param sourceLength The length of source, or -1 if null-terminated. 652*0e209d39SAndroid Build Coastguard Worker * @param target The target string. 653*0e209d39SAndroid Build Coastguard Worker * @param targetLength The length of target, or -1 if null-terminated. 654*0e209d39SAndroid Build Coastguard Worker * @return true if source is equal to target, false otherwise 655*0e209d39SAndroid Build Coastguard Worker * @see ucol_strcoll 656*0e209d39SAndroid Build Coastguard Worker * @see ucol_greater 657*0e209d39SAndroid Build Coastguard Worker * @see ucol_greaterOrEqual 658*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 659*0e209d39SAndroid Build Coastguard Worker */ 660*0e209d39SAndroid Build Coastguard Worker U_CAPI UBool U_EXPORT2 661*0e209d39SAndroid Build Coastguard Worker ucol_equal(const UCollator *coll, 662*0e209d39SAndroid Build Coastguard Worker const UChar *source, int32_t sourceLength, 663*0e209d39SAndroid Build Coastguard Worker const UChar *target, int32_t targetLength); 664*0e209d39SAndroid Build Coastguard Worker 665*0e209d39SAndroid Build Coastguard Worker /** 666*0e209d39SAndroid Build Coastguard Worker * Compare two UTF-8 encoded strings. 667*0e209d39SAndroid Build Coastguard Worker * The strings will be compared using the options already specified. 668*0e209d39SAndroid Build Coastguard Worker * @param coll The UCollator containing the comparison rules. 669*0e209d39SAndroid Build Coastguard Worker * @param sIter The source string iterator. 670*0e209d39SAndroid Build Coastguard Worker * @param tIter The target string iterator. 671*0e209d39SAndroid Build Coastguard Worker * @return The result of comparing the strings; one of UCOL_EQUAL, 672*0e209d39SAndroid Build Coastguard Worker * UCOL_GREATER, UCOL_LESS 673*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to a UErrorCode to receive any errors 674*0e209d39SAndroid Build Coastguard Worker * @see ucol_strcoll 675*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.6 676*0e209d39SAndroid Build Coastguard Worker */ 677*0e209d39SAndroid Build Coastguard Worker U_CAPI UCollationResult U_EXPORT2 678*0e209d39SAndroid Build Coastguard Worker ucol_strcollIter( const UCollator *coll, 679*0e209d39SAndroid Build Coastguard Worker UCharIterator *sIter, 680*0e209d39SAndroid Build Coastguard Worker UCharIterator *tIter, 681*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 682*0e209d39SAndroid Build Coastguard Worker 683*0e209d39SAndroid Build Coastguard Worker /** 684*0e209d39SAndroid Build Coastguard Worker * Get the collation strength used in a UCollator. 685*0e209d39SAndroid Build Coastguard Worker * The strength influences how strings are compared. 686*0e209d39SAndroid Build Coastguard Worker * @param coll The UCollator to query. 687*0e209d39SAndroid Build Coastguard Worker * @return The collation strength; one of UCOL_PRIMARY, UCOL_SECONDARY, 688*0e209d39SAndroid Build Coastguard Worker * UCOL_TERTIARY, UCOL_QUATERNARY, UCOL_IDENTICAL 689*0e209d39SAndroid Build Coastguard Worker * @see ucol_setStrength 690*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 691*0e209d39SAndroid Build Coastguard Worker */ 692*0e209d39SAndroid Build Coastguard Worker U_CAPI UCollationStrength U_EXPORT2 693*0e209d39SAndroid Build Coastguard Worker ucol_getStrength(const UCollator *coll); 694*0e209d39SAndroid Build Coastguard Worker 695*0e209d39SAndroid Build Coastguard Worker /** 696*0e209d39SAndroid Build Coastguard Worker * Set the collation strength used in a UCollator. 697*0e209d39SAndroid Build Coastguard Worker * The strength influences how strings are compared. 698*0e209d39SAndroid Build Coastguard Worker * @param coll The UCollator to set. 699*0e209d39SAndroid Build Coastguard Worker * @param strength The desired collation strength; one of UCOL_PRIMARY, 700*0e209d39SAndroid Build Coastguard Worker * UCOL_SECONDARY, UCOL_TERTIARY, UCOL_QUATERNARY, UCOL_IDENTICAL, UCOL_DEFAULT 701*0e209d39SAndroid Build Coastguard Worker * @see ucol_getStrength 702*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 703*0e209d39SAndroid Build Coastguard Worker */ 704*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 705*0e209d39SAndroid Build Coastguard Worker ucol_setStrength(UCollator *coll, 706*0e209d39SAndroid Build Coastguard Worker UCollationStrength strength); 707*0e209d39SAndroid Build Coastguard Worker 708*0e209d39SAndroid Build Coastguard Worker /** 709*0e209d39SAndroid Build Coastguard Worker * Retrieves the reordering codes for this collator. 710*0e209d39SAndroid Build Coastguard Worker * These reordering codes are a combination of UScript codes and UColReorderCode entries. 711*0e209d39SAndroid Build Coastguard Worker * @param coll The UCollator to query. 712*0e209d39SAndroid Build Coastguard Worker * @param dest The array to fill with the script ordering. 713*0e209d39SAndroid Build Coastguard Worker * @param destCapacity The length of dest. If it is 0, then dest may be NULL and the function 714*0e209d39SAndroid Build Coastguard Worker * will only return the length of the result without writing any codes (pre-flighting). 715*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Must be a valid pointer to an error code value, which must not indicate a 716*0e209d39SAndroid Build Coastguard Worker * failure before the function call. 717*0e209d39SAndroid Build Coastguard Worker * @return The number of reordering codes written to the dest array. 718*0e209d39SAndroid Build Coastguard Worker * @see ucol_setReorderCodes 719*0e209d39SAndroid Build Coastguard Worker * @see ucol_getEquivalentReorderCodes 720*0e209d39SAndroid Build Coastguard Worker * @see UScriptCode 721*0e209d39SAndroid Build Coastguard Worker * @see UColReorderCode 722*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.8 723*0e209d39SAndroid Build Coastguard Worker */ 724*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 725*0e209d39SAndroid Build Coastguard Worker ucol_getReorderCodes(const UCollator* coll, 726*0e209d39SAndroid Build Coastguard Worker int32_t* dest, 727*0e209d39SAndroid Build Coastguard Worker int32_t destCapacity, 728*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode); 729*0e209d39SAndroid Build Coastguard Worker /** 730*0e209d39SAndroid Build Coastguard Worker * Sets the reordering codes for this collator. 731*0e209d39SAndroid Build Coastguard Worker * Collation reordering allows scripts and some other groups of characters 732*0e209d39SAndroid Build Coastguard Worker * to be moved relative to each other. This reordering is done on top of 733*0e209d39SAndroid Build Coastguard Worker * the DUCET/CLDR standard collation order. Reordering can specify groups to be placed 734*0e209d39SAndroid Build Coastguard Worker * at the start and/or the end of the collation order. These groups are specified using 735*0e209d39SAndroid Build Coastguard Worker * UScript codes and UColReorderCode entries. 736*0e209d39SAndroid Build Coastguard Worker * 737*0e209d39SAndroid Build Coastguard Worker * <p>By default, reordering codes specified for the start of the order are placed in the 738*0e209d39SAndroid Build Coastguard Worker * order given after several special non-script blocks. These special groups of characters 739*0e209d39SAndroid Build Coastguard Worker * are space, punctuation, symbol, currency, and digit. These special groups are represented with 740*0e209d39SAndroid Build Coastguard Worker * UColReorderCode entries. Script groups can be intermingled with 741*0e209d39SAndroid Build Coastguard Worker * these special non-script groups if those special groups are explicitly specified in the reordering. 742*0e209d39SAndroid Build Coastguard Worker * 743*0e209d39SAndroid Build Coastguard Worker * <p>The special code OTHERS stands for any script that is not explicitly 744*0e209d39SAndroid Build Coastguard Worker * mentioned in the list of reordering codes given. Anything that is after OTHERS 745*0e209d39SAndroid Build Coastguard Worker * will go at the very end of the reordering in the order given. 746*0e209d39SAndroid Build Coastguard Worker * 747*0e209d39SAndroid Build Coastguard Worker * <p>The special reorder code DEFAULT will reset the reordering for this collator 748*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 749*0e209d39SAndroid Build Coastguard Worker * was specified when this collator was created from resource data or from rules. The 750*0e209d39SAndroid Build Coastguard Worker * DEFAULT code <b>must</b> be the sole code supplied when it is used. 751*0e209d39SAndroid Build Coastguard Worker * If not, then U_ILLEGAL_ARGUMENT_ERROR will be set. 752*0e209d39SAndroid Build Coastguard Worker * 753*0e209d39SAndroid Build Coastguard Worker * <p>The special reorder code NONE will remove any reordering for this collator. 754*0e209d39SAndroid Build Coastguard Worker * The result of setting no reordering will be to have the DUCET/CLDR ordering used. The 755*0e209d39SAndroid Build Coastguard Worker * NONE code <b>must</b> be the sole code supplied when it is used. 756*0e209d39SAndroid Build Coastguard Worker * 757*0e209d39SAndroid Build Coastguard Worker * @param coll The UCollator to set. 758*0e209d39SAndroid Build Coastguard Worker * @param reorderCodes An array of script codes in the new order. This can be NULL if the 759*0e209d39SAndroid Build Coastguard Worker * length is also set to 0. An empty array will clear any reordering codes on the collator. 760*0e209d39SAndroid Build Coastguard Worker * @param reorderCodesLength The length of reorderCodes. 761*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Must be a valid pointer to an error code value, which must not indicate a 762*0e209d39SAndroid Build Coastguard Worker * failure before the function call. 763*0e209d39SAndroid Build Coastguard Worker * @see ucol_getReorderCodes 764*0e209d39SAndroid Build Coastguard Worker * @see ucol_getEquivalentReorderCodes 765*0e209d39SAndroid Build Coastguard Worker * @see UScriptCode 766*0e209d39SAndroid Build Coastguard Worker * @see UColReorderCode 767*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.8 768*0e209d39SAndroid Build Coastguard Worker */ 769*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 770*0e209d39SAndroid Build Coastguard Worker ucol_setReorderCodes(UCollator* coll, 771*0e209d39SAndroid Build Coastguard Worker const int32_t* reorderCodes, 772*0e209d39SAndroid Build Coastguard Worker int32_t reorderCodesLength, 773*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode); 774*0e209d39SAndroid Build Coastguard Worker 775*0e209d39SAndroid Build Coastguard Worker /** 776*0e209d39SAndroid Build Coastguard Worker * Retrieves the reorder codes that are grouped with the given reorder code. Some reorder 777*0e209d39SAndroid Build Coastguard Worker * codes will be grouped and must reorder together. 778*0e209d39SAndroid Build Coastguard Worker * Beginning with ICU 55, scripts only reorder together if they are primary-equal, 779*0e209d39SAndroid Build Coastguard Worker * for example Hiragana and Katakana. 780*0e209d39SAndroid Build Coastguard Worker * 781*0e209d39SAndroid Build Coastguard Worker * @param reorderCode The reorder code to determine equivalence for. 782*0e209d39SAndroid Build Coastguard Worker * @param dest The array to fill with the script ordering. 783*0e209d39SAndroid Build Coastguard Worker * @param destCapacity The length of dest. If it is 0, then dest may be NULL and the function 784*0e209d39SAndroid Build Coastguard Worker * will only return the length of the result without writing any codes (pre-flighting). 785*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Must be a valid pointer to an error code value, which must not indicate 786*0e209d39SAndroid Build Coastguard Worker * a failure before the function call. 787*0e209d39SAndroid Build Coastguard Worker * @return The number of reordering codes written to the dest array. 788*0e209d39SAndroid Build Coastguard Worker * @see ucol_setReorderCodes 789*0e209d39SAndroid Build Coastguard Worker * @see ucol_getReorderCodes 790*0e209d39SAndroid Build Coastguard Worker * @see UScriptCode 791*0e209d39SAndroid Build Coastguard Worker * @see UColReorderCode 792*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.8 793*0e209d39SAndroid Build Coastguard Worker */ 794*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 795*0e209d39SAndroid Build Coastguard Worker ucol_getEquivalentReorderCodes(int32_t reorderCode, 796*0e209d39SAndroid Build Coastguard Worker int32_t* dest, 797*0e209d39SAndroid Build Coastguard Worker int32_t destCapacity, 798*0e209d39SAndroid Build Coastguard Worker UErrorCode *pErrorCode); 799*0e209d39SAndroid Build Coastguard Worker 800*0e209d39SAndroid Build Coastguard Worker /** 801*0e209d39SAndroid Build Coastguard Worker * Get the display name for a UCollator. 802*0e209d39SAndroid Build Coastguard Worker * The display name is suitable for presentation to a user. 803*0e209d39SAndroid Build Coastguard Worker * @param objLoc The locale of the collator in question. 804*0e209d39SAndroid Build Coastguard Worker * @param dispLoc The locale for display. 805*0e209d39SAndroid Build Coastguard Worker * @param result A pointer to a buffer to receive the attribute. 806*0e209d39SAndroid Build Coastguard Worker * @param resultLength The maximum size of result. 807*0e209d39SAndroid Build Coastguard Worker * @param status A pointer to a UErrorCode to receive any errors 808*0e209d39SAndroid Build Coastguard Worker * @return The total buffer size needed; if greater than resultLength, 809*0e209d39SAndroid Build Coastguard Worker * the output was truncated. 810*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 811*0e209d39SAndroid Build Coastguard Worker */ 812*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 813*0e209d39SAndroid Build Coastguard Worker ucol_getDisplayName( const char *objLoc, 814*0e209d39SAndroid Build Coastguard Worker const char *dispLoc, 815*0e209d39SAndroid Build Coastguard Worker UChar *result, 816*0e209d39SAndroid Build Coastguard Worker int32_t resultLength, 817*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 818*0e209d39SAndroid Build Coastguard Worker 819*0e209d39SAndroid Build Coastguard Worker /** 820*0e209d39SAndroid Build Coastguard Worker * Get a locale for which collation rules are available. 821*0e209d39SAndroid Build Coastguard Worker * A UCollator in a locale returned by this function will perform the correct 822*0e209d39SAndroid Build Coastguard Worker * collation for the locale. 823*0e209d39SAndroid Build Coastguard Worker * @param localeIndex The index of the desired locale. 824*0e209d39SAndroid Build Coastguard Worker * @return A locale for which collation rules are available, or 0 if none. 825*0e209d39SAndroid Build Coastguard Worker * @see ucol_countAvailable 826*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 827*0e209d39SAndroid Build Coastguard Worker */ 828*0e209d39SAndroid Build Coastguard Worker U_CAPI const char* U_EXPORT2 829*0e209d39SAndroid Build Coastguard Worker ucol_getAvailable(int32_t localeIndex); 830*0e209d39SAndroid Build Coastguard Worker 831*0e209d39SAndroid Build Coastguard Worker /** 832*0e209d39SAndroid Build Coastguard Worker * Determine how many locales have collation rules available. 833*0e209d39SAndroid Build Coastguard Worker * This function is most useful as determining the loop ending condition for 834*0e209d39SAndroid Build Coastguard Worker * calls to {@link #ucol_getAvailable }. 835*0e209d39SAndroid Build Coastguard Worker * @return The number of locales for which collation rules are available. 836*0e209d39SAndroid Build Coastguard Worker * @see ucol_getAvailable 837*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 838*0e209d39SAndroid Build Coastguard Worker */ 839*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 840*0e209d39SAndroid Build Coastguard Worker ucol_countAvailable(void); 841*0e209d39SAndroid Build Coastguard Worker 842*0e209d39SAndroid Build Coastguard Worker #if !UCONFIG_NO_SERVICE 843*0e209d39SAndroid Build Coastguard Worker /** 844*0e209d39SAndroid Build Coastguard Worker * Create a string enumerator of all locales for which a valid 845*0e209d39SAndroid Build Coastguard Worker * collator may be opened. 846*0e209d39SAndroid Build Coastguard Worker * @param status input-output error code 847*0e209d39SAndroid Build Coastguard Worker * @return a string enumeration over locale strings. The caller is 848*0e209d39SAndroid Build Coastguard Worker * responsible for closing the result. 849*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 850*0e209d39SAndroid Build Coastguard Worker */ 851*0e209d39SAndroid Build Coastguard Worker U_CAPI UEnumeration* U_EXPORT2 852*0e209d39SAndroid Build Coastguard Worker ucol_openAvailableLocales(UErrorCode *status); 853*0e209d39SAndroid Build Coastguard Worker #endif 854*0e209d39SAndroid Build Coastguard Worker 855*0e209d39SAndroid Build Coastguard Worker /** 856*0e209d39SAndroid Build Coastguard Worker * Create a string enumerator of all possible keywords that are relevant to 857*0e209d39SAndroid Build Coastguard Worker * collation. At this point, the only recognized keyword for this 858*0e209d39SAndroid Build Coastguard Worker * service is "collation". 859*0e209d39SAndroid Build Coastguard Worker * @param status input-output error code 860*0e209d39SAndroid Build Coastguard Worker * @return a string enumeration over locale strings. The caller is 861*0e209d39SAndroid Build Coastguard Worker * responsible for closing the result. 862*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 863*0e209d39SAndroid Build Coastguard Worker */ 864*0e209d39SAndroid Build Coastguard Worker U_CAPI UEnumeration* U_EXPORT2 865*0e209d39SAndroid Build Coastguard Worker ucol_getKeywords(UErrorCode *status); 866*0e209d39SAndroid Build Coastguard Worker 867*0e209d39SAndroid Build Coastguard Worker /** 868*0e209d39SAndroid Build Coastguard Worker * Given a keyword, create a string enumeration of all values 869*0e209d39SAndroid Build Coastguard Worker * for that keyword that are currently in use. 870*0e209d39SAndroid Build Coastguard Worker * @param keyword a particular keyword as enumerated by 871*0e209d39SAndroid Build Coastguard Worker * ucol_getKeywords. If any other keyword is passed in, *status is set 872*0e209d39SAndroid Build Coastguard Worker * to U_ILLEGAL_ARGUMENT_ERROR. 873*0e209d39SAndroid Build Coastguard Worker * @param status input-output error code 874*0e209d39SAndroid Build Coastguard Worker * @return a string enumeration over collation keyword values, or NULL 875*0e209d39SAndroid Build Coastguard Worker * upon error. The caller is responsible for closing the result. 876*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 877*0e209d39SAndroid Build Coastguard Worker */ 878*0e209d39SAndroid Build Coastguard Worker U_CAPI UEnumeration* U_EXPORT2 879*0e209d39SAndroid Build Coastguard Worker ucol_getKeywordValues(const char *keyword, UErrorCode *status); 880*0e209d39SAndroid Build Coastguard Worker 881*0e209d39SAndroid Build Coastguard Worker /** 882*0e209d39SAndroid Build Coastguard Worker * Given a key and a locale, returns an array of string values in a preferred 883*0e209d39SAndroid Build Coastguard Worker * order that would make a difference. These are all and only those values where 884*0e209d39SAndroid Build Coastguard Worker * the open (creation) of the service with the locale formed from the input locale 885*0e209d39SAndroid Build Coastguard Worker * plus input keyword and that value has different behavior than creation with the 886*0e209d39SAndroid Build Coastguard Worker * input locale alone. 887*0e209d39SAndroid Build Coastguard Worker * @param key one of the keys supported by this service. For now, only 888*0e209d39SAndroid Build Coastguard Worker * "collation" is supported. 889*0e209d39SAndroid Build Coastguard Worker * @param locale the locale 890*0e209d39SAndroid Build Coastguard Worker * @param commonlyUsed if set to true it will return only commonly used values 891*0e209d39SAndroid Build Coastguard Worker * with the given locale in preferred order. Otherwise, 892*0e209d39SAndroid Build Coastguard Worker * it will return all the available values for the locale. 893*0e209d39SAndroid Build Coastguard Worker * @param status error status 894*0e209d39SAndroid Build Coastguard Worker * @return a string enumeration over keyword values for the given key and the locale. 895*0e209d39SAndroid Build Coastguard Worker * @stable ICU 4.2 896*0e209d39SAndroid Build Coastguard Worker */ 897*0e209d39SAndroid Build Coastguard Worker U_CAPI UEnumeration* U_EXPORT2 898*0e209d39SAndroid Build Coastguard Worker ucol_getKeywordValuesForLocale(const char* key, 899*0e209d39SAndroid Build Coastguard Worker const char* locale, 900*0e209d39SAndroid Build Coastguard Worker UBool commonlyUsed, 901*0e209d39SAndroid Build Coastguard Worker UErrorCode* status); 902*0e209d39SAndroid Build Coastguard Worker 903*0e209d39SAndroid Build Coastguard Worker /** 904*0e209d39SAndroid Build Coastguard Worker * Return the functionally equivalent locale for the specified 905*0e209d39SAndroid Build Coastguard Worker * input locale, with respect to given keyword, for the 906*0e209d39SAndroid Build Coastguard Worker * collation service. If two different input locale + keyword 907*0e209d39SAndroid Build Coastguard Worker * combinations produce the same result locale, then collators 908*0e209d39SAndroid Build Coastguard Worker * instantiated for these two different input locales will behave 909*0e209d39SAndroid Build Coastguard Worker * equivalently. The converse is not always true; two collators 910*0e209d39SAndroid Build Coastguard Worker * may in fact be equivalent, but return different results, due to 911*0e209d39SAndroid Build Coastguard Worker * internal details. The return result has no other meaning than 912*0e209d39SAndroid Build Coastguard Worker * that stated above, and implies nothing as to the relationship 913*0e209d39SAndroid Build Coastguard Worker * between the two locales. This is intended for use by 914*0e209d39SAndroid Build Coastguard Worker * applications who wish to cache collators, or otherwise reuse 915*0e209d39SAndroid Build Coastguard Worker * collators when possible. The functional equivalent may change 916*0e209d39SAndroid Build Coastguard Worker * over time. For more information, please see the <a 917*0e209d39SAndroid Build Coastguard Worker * href="https://unicode-org.github.io/icu/userguide/locale#locales-and-services"> 918*0e209d39SAndroid Build Coastguard Worker * Locales and Services</a> section of the ICU User Guide. 919*0e209d39SAndroid Build Coastguard Worker * @param result fillin for the functionally equivalent result locale 920*0e209d39SAndroid Build Coastguard Worker * @param resultCapacity capacity of the fillin buffer 921*0e209d39SAndroid Build Coastguard Worker * @param keyword a particular keyword as enumerated by 922*0e209d39SAndroid Build Coastguard Worker * ucol_getKeywords. 923*0e209d39SAndroid Build Coastguard Worker * @param locale the specified input locale 924*0e209d39SAndroid Build Coastguard Worker * @param isAvailable if non-NULL, pointer to a fillin parameter that 925*0e209d39SAndroid Build Coastguard Worker * on return indicates whether the specified input locale was 'available' 926*0e209d39SAndroid Build Coastguard Worker * to the collation service. A locale is defined as 'available' if it 927*0e209d39SAndroid Build Coastguard Worker * physically exists within the collation locale data. 928*0e209d39SAndroid Build Coastguard Worker * @param status pointer to input-output error code 929*0e209d39SAndroid Build Coastguard Worker * @return the actual buffer size needed for the locale. If greater 930*0e209d39SAndroid Build Coastguard Worker * than resultCapacity, the returned full name will be truncated and 931*0e209d39SAndroid Build Coastguard Worker * an error code will be returned. 932*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.0 933*0e209d39SAndroid Build Coastguard Worker */ 934*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 935*0e209d39SAndroid Build Coastguard Worker ucol_getFunctionalEquivalent(char* result, int32_t resultCapacity, 936*0e209d39SAndroid Build Coastguard Worker const char* keyword, const char* locale, 937*0e209d39SAndroid Build Coastguard Worker UBool* isAvailable, UErrorCode* status); 938*0e209d39SAndroid Build Coastguard Worker 939*0e209d39SAndroid Build Coastguard Worker /** 940*0e209d39SAndroid Build Coastguard Worker * Get the collation tailoring rules from a UCollator. 941*0e209d39SAndroid Build Coastguard Worker * The rules will follow the rule syntax. 942*0e209d39SAndroid Build Coastguard Worker * @param coll The UCollator to query. 943*0e209d39SAndroid Build Coastguard Worker * @param length 944*0e209d39SAndroid Build Coastguard Worker * @return The collation tailoring rules. 945*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 946*0e209d39SAndroid Build Coastguard Worker */ 947*0e209d39SAndroid Build Coastguard Worker U_CAPI const UChar* U_EXPORT2 948*0e209d39SAndroid Build Coastguard Worker ucol_getRules( const UCollator *coll, 949*0e209d39SAndroid Build Coastguard Worker int32_t *length); 950*0e209d39SAndroid Build Coastguard Worker 951*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API 952*0e209d39SAndroid Build Coastguard Worker /** Get the short definition string for a collator. This API harvests the collator's 953*0e209d39SAndroid Build Coastguard Worker * locale and the attribute set and produces a string that can be used for opening 954*0e209d39SAndroid Build Coastguard Worker * a collator with the same attributes using the ucol_openFromShortString API. 955*0e209d39SAndroid Build Coastguard Worker * This string will be normalized. 956*0e209d39SAndroid Build Coastguard Worker * The structure and the syntax of the string is defined in the "Naming collators" 957*0e209d39SAndroid Build Coastguard Worker * section of the users guide: 958*0e209d39SAndroid Build Coastguard Worker * https://unicode-org.github.io/icu/userguide/collation/concepts#collator-naming-scheme 959*0e209d39SAndroid Build Coastguard Worker * This API supports preflighting. 960*0e209d39SAndroid Build Coastguard Worker * @param coll a collator 961*0e209d39SAndroid Build Coastguard Worker * @param locale a locale that will appear as a collators locale in the resulting 962*0e209d39SAndroid Build Coastguard Worker * short string definition. If NULL, the locale will be harvested 963*0e209d39SAndroid Build Coastguard Worker * from the collator. 964*0e209d39SAndroid Build Coastguard Worker * @param buffer space to hold the resulting string 965*0e209d39SAndroid Build Coastguard Worker * @param capacity capacity of the buffer 966*0e209d39SAndroid Build Coastguard Worker * @param status for returning errors. All the preflighting errors are featured 967*0e209d39SAndroid Build Coastguard Worker * @return length of the resulting string 968*0e209d39SAndroid Build Coastguard Worker * @see ucol_openFromShortString 969*0e209d39SAndroid Build Coastguard Worker * @see ucol_normalizeShortDefinitionString 970*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 54 971*0e209d39SAndroid Build Coastguard Worker */ 972*0e209d39SAndroid Build Coastguard Worker U_DEPRECATED int32_t U_EXPORT2 973*0e209d39SAndroid Build Coastguard Worker ucol_getShortDefinitionString(const UCollator *coll, 974*0e209d39SAndroid Build Coastguard Worker const char *locale, 975*0e209d39SAndroid Build Coastguard Worker char *buffer, 976*0e209d39SAndroid Build Coastguard Worker int32_t capacity, 977*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 978*0e209d39SAndroid Build Coastguard Worker 979*0e209d39SAndroid Build Coastguard Worker /** Verifies and normalizes short definition string. 980*0e209d39SAndroid Build Coastguard Worker * Normalized short definition string has all the option sorted by the argument name, 981*0e209d39SAndroid Build Coastguard Worker * so that equivalent definition strings are the same. 982*0e209d39SAndroid Build Coastguard Worker * This API supports preflighting. 983*0e209d39SAndroid Build Coastguard Worker * @param source definition string 984*0e209d39SAndroid Build Coastguard Worker * @param destination space to hold the resulting string 985*0e209d39SAndroid Build Coastguard Worker * @param capacity capacity of the buffer 986*0e209d39SAndroid Build Coastguard Worker * @param parseError if not NULL, structure that will get filled with error's pre 987*0e209d39SAndroid Build Coastguard Worker * and post context in case of error. 988*0e209d39SAndroid Build Coastguard Worker * @param status Error code. This API will return an error if an invalid attribute 989*0e209d39SAndroid Build Coastguard Worker * or attribute/value combination is specified. All the preflighting 990*0e209d39SAndroid Build Coastguard Worker * errors are also featured 991*0e209d39SAndroid Build Coastguard Worker * @return length of the resulting normalized string. 992*0e209d39SAndroid Build Coastguard Worker * 993*0e209d39SAndroid Build Coastguard Worker * @see ucol_openFromShortString 994*0e209d39SAndroid Build Coastguard Worker * @see ucol_getShortDefinitionString 995*0e209d39SAndroid Build Coastguard Worker * 996*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 54 997*0e209d39SAndroid Build Coastguard Worker */ 998*0e209d39SAndroid Build Coastguard Worker U_DEPRECATED int32_t U_EXPORT2 999*0e209d39SAndroid Build Coastguard Worker ucol_normalizeShortDefinitionString(const char *source, 1000*0e209d39SAndroid Build Coastguard Worker char *destination, 1001*0e209d39SAndroid Build Coastguard Worker int32_t capacity, 1002*0e209d39SAndroid Build Coastguard Worker UParseError *parseError, 1003*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 1004*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_DEPRECATED_API */ 1005*0e209d39SAndroid Build Coastguard Worker 1006*0e209d39SAndroid Build Coastguard Worker 1007*0e209d39SAndroid Build Coastguard Worker /** 1008*0e209d39SAndroid Build Coastguard Worker * Get a sort key for a string from a UCollator. 1009*0e209d39SAndroid Build Coastguard Worker * Sort keys may be compared using <TT>strcmp</TT>. 1010*0e209d39SAndroid Build Coastguard Worker * 1011*0e209d39SAndroid Build Coastguard Worker * Note that sort keys are often less efficient than simply doing comparison. 1012*0e209d39SAndroid Build Coastguard Worker * For more details, see the ICU User Guide. 1013*0e209d39SAndroid Build Coastguard Worker * 1014*0e209d39SAndroid Build Coastguard Worker * Like ICU functions that write to an output buffer, the buffer contents 1015*0e209d39SAndroid Build Coastguard Worker * is undefined if the buffer capacity (resultLength parameter) is too small. 1016*0e209d39SAndroid Build Coastguard Worker * Unlike ICU functions that write a string to an output buffer, 1017*0e209d39SAndroid Build Coastguard Worker * the terminating zero byte is counted in the sort key length. 1018*0e209d39SAndroid Build Coastguard Worker * @param coll The UCollator containing the collation rules. 1019*0e209d39SAndroid Build Coastguard Worker * @param source The string to transform. 1020*0e209d39SAndroid Build Coastguard Worker * @param sourceLength The length of source, or -1 if null-terminated. 1021*0e209d39SAndroid Build Coastguard Worker * @param result A pointer to a buffer to receive the attribute. 1022*0e209d39SAndroid Build Coastguard Worker * @param resultLength The maximum size of result. 1023*0e209d39SAndroid Build Coastguard Worker * @return The size needed to fully store the sort key. 1024*0e209d39SAndroid Build Coastguard Worker * If there was an internal error generating the sort key, 1025*0e209d39SAndroid Build Coastguard Worker * a zero value is returned. 1026*0e209d39SAndroid Build Coastguard Worker * @see ucol_keyHashCode 1027*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 1028*0e209d39SAndroid Build Coastguard Worker */ 1029*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 1030*0e209d39SAndroid Build Coastguard Worker ucol_getSortKey(const UCollator *coll, 1031*0e209d39SAndroid Build Coastguard Worker const UChar *source, 1032*0e209d39SAndroid Build Coastguard Worker int32_t sourceLength, 1033*0e209d39SAndroid Build Coastguard Worker uint8_t *result, 1034*0e209d39SAndroid Build Coastguard Worker int32_t resultLength); 1035*0e209d39SAndroid Build Coastguard Worker 1036*0e209d39SAndroid Build Coastguard Worker 1037*0e209d39SAndroid Build Coastguard Worker /** Gets the next count bytes of a sort key. Caller needs 1038*0e209d39SAndroid Build Coastguard Worker * to preserve state array between calls and to provide 1039*0e209d39SAndroid Build Coastguard Worker * the same type of UCharIterator set with the same string. 1040*0e209d39SAndroid Build Coastguard Worker * The destination buffer provided must be big enough to store 1041*0e209d39SAndroid Build Coastguard Worker * the number of requested bytes. 1042*0e209d39SAndroid Build Coastguard Worker * 1043*0e209d39SAndroid Build Coastguard Worker * The generated sort key may or may not be compatible with 1044*0e209d39SAndroid Build Coastguard Worker * sort keys generated using ucol_getSortKey(). 1045*0e209d39SAndroid Build Coastguard Worker * @param coll The UCollator containing the collation rules. 1046*0e209d39SAndroid Build Coastguard Worker * @param iter UCharIterator containing the string we need 1047*0e209d39SAndroid Build Coastguard Worker * the sort key to be calculated for. 1048*0e209d39SAndroid Build Coastguard Worker * @param state Opaque state of sortkey iteration. 1049*0e209d39SAndroid Build Coastguard Worker * @param dest Buffer to hold the resulting sortkey part 1050*0e209d39SAndroid Build Coastguard Worker * @param count number of sort key bytes required. 1051*0e209d39SAndroid Build Coastguard Worker * @param status error code indicator. 1052*0e209d39SAndroid Build Coastguard Worker * @return the actual number of bytes of a sortkey. It can be 1053*0e209d39SAndroid Build Coastguard Worker * smaller than count if we have reached the end of 1054*0e209d39SAndroid Build Coastguard Worker * the sort key. 1055*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.6 1056*0e209d39SAndroid Build Coastguard Worker */ 1057*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 1058*0e209d39SAndroid Build Coastguard Worker ucol_nextSortKeyPart(const UCollator *coll, 1059*0e209d39SAndroid Build Coastguard Worker UCharIterator *iter, 1060*0e209d39SAndroid Build Coastguard Worker uint32_t state[2], 1061*0e209d39SAndroid Build Coastguard Worker uint8_t *dest, int32_t count, 1062*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 1063*0e209d39SAndroid Build Coastguard Worker 1064*0e209d39SAndroid Build Coastguard Worker /** enum that is taken by ucol_getBound API 1065*0e209d39SAndroid Build Coastguard Worker * See below for explanation 1066*0e209d39SAndroid Build Coastguard Worker * do not change the values assigned to the 1067*0e209d39SAndroid Build Coastguard Worker * members of this enum. Underlying code 1068*0e209d39SAndroid Build Coastguard Worker * depends on them having these numbers 1069*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 1070*0e209d39SAndroid Build Coastguard Worker */ 1071*0e209d39SAndroid Build Coastguard Worker typedef enum { 1072*0e209d39SAndroid Build Coastguard Worker /** lower bound */ 1073*0e209d39SAndroid Build Coastguard Worker UCOL_BOUND_LOWER = 0, 1074*0e209d39SAndroid Build Coastguard Worker /** upper bound that will match strings of exact size */ 1075*0e209d39SAndroid Build Coastguard Worker UCOL_BOUND_UPPER = 1, 1076*0e209d39SAndroid Build Coastguard Worker /** upper bound that will match all the strings that have the same initial substring as the given string */ 1077*0e209d39SAndroid Build Coastguard Worker UCOL_BOUND_UPPER_LONG = 2, 1078*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API 1079*0e209d39SAndroid Build Coastguard Worker /** 1080*0e209d39SAndroid Build Coastguard Worker * One more than the highest normal UColBoundMode value. 1081*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 58 The numeric value may change over time, see ICU ticket #12420. 1082*0e209d39SAndroid Build Coastguard Worker */ 1083*0e209d39SAndroid Build Coastguard Worker UCOL_BOUND_VALUE_COUNT 1084*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_DEPRECATED_API */ 1085*0e209d39SAndroid Build Coastguard Worker } UColBoundMode; 1086*0e209d39SAndroid Build Coastguard Worker 1087*0e209d39SAndroid Build Coastguard Worker /** 1088*0e209d39SAndroid Build Coastguard Worker * Produce a bound for a given sortkey and a number of levels. 1089*0e209d39SAndroid Build Coastguard Worker * Return value is always the number of bytes needed, regardless of 1090*0e209d39SAndroid Build Coastguard Worker * whether the result buffer was big enough or even valid.<br> 1091*0e209d39SAndroid Build Coastguard Worker * Resulting bounds can be used to produce a range of strings that are 1092*0e209d39SAndroid Build Coastguard Worker * between upper and lower bounds. For example, if bounds are produced 1093*0e209d39SAndroid Build Coastguard Worker * for a sortkey of string "smith", strings between upper and lower 1094*0e209d39SAndroid Build Coastguard Worker * bounds with one level would include "Smith", "SMITH", "sMiTh".<br> 1095*0e209d39SAndroid Build Coastguard Worker * There are two upper bounds that can be produced. If UCOL_BOUND_UPPER 1096*0e209d39SAndroid Build Coastguard Worker * is produced, strings matched would be as above. However, if bound 1097*0e209d39SAndroid Build Coastguard Worker * produced using UCOL_BOUND_UPPER_LONG is used, the above example will 1098*0e209d39SAndroid Build Coastguard Worker * also match "Smithsonian" and similar.<br> 1099*0e209d39SAndroid Build Coastguard Worker * For more on usage, see example in cintltst/capitst.c in procedure 1100*0e209d39SAndroid Build Coastguard Worker * TestBounds. 1101*0e209d39SAndroid Build Coastguard Worker * Sort keys may be compared using <TT>strcmp</TT>. 1102*0e209d39SAndroid Build Coastguard Worker * @param source The source sortkey. 1103*0e209d39SAndroid Build Coastguard Worker * @param sourceLength The length of source, or -1 if null-terminated. 1104*0e209d39SAndroid Build Coastguard Worker * (If an unmodified sortkey is passed, it is always null 1105*0e209d39SAndroid Build Coastguard Worker * terminated). 1106*0e209d39SAndroid Build Coastguard Worker * @param boundType Type of bound required. It can be UCOL_BOUND_LOWER, which 1107*0e209d39SAndroid Build Coastguard Worker * produces a lower inclusive bound, UCOL_BOUND_UPPER, that 1108*0e209d39SAndroid Build Coastguard Worker * produces upper bound that matches strings of the same length 1109*0e209d39SAndroid Build Coastguard Worker * or UCOL_BOUND_UPPER_LONG that matches strings that have the 1110*0e209d39SAndroid Build Coastguard Worker * same starting substring as the source string. 1111*0e209d39SAndroid Build Coastguard Worker * @param noOfLevels Number of levels required in the resulting bound (for most 1112*0e209d39SAndroid Build Coastguard Worker * uses, the recommended value is 1). See users guide for 1113*0e209d39SAndroid Build Coastguard Worker * explanation on number of levels a sortkey can have. 1114*0e209d39SAndroid Build Coastguard Worker * @param result A pointer to a buffer to receive the resulting sortkey. 1115*0e209d39SAndroid Build Coastguard Worker * @param resultLength The maximum size of result. 1116*0e209d39SAndroid Build Coastguard Worker * @param status Used for returning error code if something went wrong. If the 1117*0e209d39SAndroid Build Coastguard Worker * number of levels requested is higher than the number of levels 1118*0e209d39SAndroid Build Coastguard Worker * in the source key, a warning (U_SORT_KEY_TOO_SHORT_WARNING) is 1119*0e209d39SAndroid Build Coastguard Worker * issued. 1120*0e209d39SAndroid Build Coastguard Worker * @return The size needed to fully store the bound. 1121*0e209d39SAndroid Build Coastguard Worker * @see ucol_keyHashCode 1122*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.1 1123*0e209d39SAndroid Build Coastguard Worker */ 1124*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 1125*0e209d39SAndroid Build Coastguard Worker ucol_getBound(const uint8_t *source, 1126*0e209d39SAndroid Build Coastguard Worker int32_t sourceLength, 1127*0e209d39SAndroid Build Coastguard Worker UColBoundMode boundType, 1128*0e209d39SAndroid Build Coastguard Worker uint32_t noOfLevels, 1129*0e209d39SAndroid Build Coastguard Worker uint8_t *result, 1130*0e209d39SAndroid Build Coastguard Worker int32_t resultLength, 1131*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 1132*0e209d39SAndroid Build Coastguard Worker 1133*0e209d39SAndroid Build Coastguard Worker /** 1134*0e209d39SAndroid Build Coastguard Worker * Gets the version information for a Collator. Version is currently 1135*0e209d39SAndroid Build Coastguard Worker * an opaque 32-bit number which depends, among other things, on major 1136*0e209d39SAndroid Build Coastguard Worker * versions of the collator tailoring and UCA. 1137*0e209d39SAndroid Build Coastguard Worker * @param coll The UCollator to query. 1138*0e209d39SAndroid Build Coastguard Worker * @param info the version # information, the result will be filled in 1139*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 1140*0e209d39SAndroid Build Coastguard Worker */ 1141*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 1142*0e209d39SAndroid Build Coastguard Worker ucol_getVersion(const UCollator* coll, UVersionInfo info); 1143*0e209d39SAndroid Build Coastguard Worker 1144*0e209d39SAndroid Build Coastguard Worker /** 1145*0e209d39SAndroid Build Coastguard Worker * Gets the UCA version information for a Collator. Version is the 1146*0e209d39SAndroid Build Coastguard Worker * UCA version number (3.1.1, 4.0). 1147*0e209d39SAndroid Build Coastguard Worker * @param coll The UCollator to query. 1148*0e209d39SAndroid Build Coastguard Worker * @param info the version # information, the result will be filled in 1149*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.8 1150*0e209d39SAndroid Build Coastguard Worker */ 1151*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 1152*0e209d39SAndroid Build Coastguard Worker ucol_getUCAVersion(const UCollator* coll, UVersionInfo info); 1153*0e209d39SAndroid Build Coastguard Worker 1154*0e209d39SAndroid Build Coastguard Worker /** 1155*0e209d39SAndroid Build Coastguard Worker * Merges two sort keys. The levels are merged with their corresponding counterparts 1156*0e209d39SAndroid Build Coastguard Worker * (primaries with primaries, secondaries with secondaries etc.). Between the values 1157*0e209d39SAndroid Build Coastguard Worker * from the same level a separator is inserted. 1158*0e209d39SAndroid Build Coastguard Worker * 1159*0e209d39SAndroid Build Coastguard Worker * This is useful, for example, for combining sort keys from first and last names 1160*0e209d39SAndroid Build Coastguard Worker * to sort such pairs. 1161*0e209d39SAndroid Build Coastguard Worker * See http://www.unicode.org/reports/tr10/#Merging_Sort_Keys 1162*0e209d39SAndroid Build Coastguard Worker * 1163*0e209d39SAndroid Build Coastguard Worker * The recommended way to achieve "merged" sorting is by 1164*0e209d39SAndroid Build Coastguard Worker * concatenating strings with U+FFFE between them. 1165*0e209d39SAndroid Build Coastguard Worker * The concatenation has the same sort order as the merged sort keys, 1166*0e209d39SAndroid Build Coastguard Worker * but merge(getSortKey(str1), getSortKey(str2)) may differ from getSortKey(str1 + '\\uFFFE' + str2). 1167*0e209d39SAndroid Build Coastguard Worker * Using strings with U+FFFE may yield shorter sort keys. 1168*0e209d39SAndroid Build Coastguard Worker * 1169*0e209d39SAndroid Build Coastguard Worker * For details about Sort Key Features see 1170*0e209d39SAndroid Build Coastguard Worker * https://unicode-org.github.io/icu/userguide/collation/api#sort-key-features 1171*0e209d39SAndroid Build Coastguard Worker * 1172*0e209d39SAndroid Build Coastguard Worker * It is possible to merge multiple sort keys by consecutively merging 1173*0e209d39SAndroid Build Coastguard Worker * another one with the intermediate result. 1174*0e209d39SAndroid Build Coastguard Worker * 1175*0e209d39SAndroid Build Coastguard Worker * The length of the merge result is the sum of the lengths of the input sort keys. 1176*0e209d39SAndroid Build Coastguard Worker * 1177*0e209d39SAndroid Build Coastguard Worker * Example (uncompressed): 1178*0e209d39SAndroid Build Coastguard Worker * <pre>191B1D 01 050505 01 910505 00 1179*0e209d39SAndroid Build Coastguard Worker * 1F2123 01 050505 01 910505 00</pre> 1180*0e209d39SAndroid Build Coastguard Worker * will be merged as 1181*0e209d39SAndroid Build Coastguard Worker * <pre>191B1D 02 1F2123 01 050505 02 050505 01 910505 02 910505 00</pre> 1182*0e209d39SAndroid Build Coastguard Worker * 1183*0e209d39SAndroid Build Coastguard Worker * If the destination buffer is not big enough, then its contents are undefined. 1184*0e209d39SAndroid Build Coastguard Worker * If any of source lengths are zero or any of the source pointers are NULL/undefined, 1185*0e209d39SAndroid Build Coastguard Worker * the result is of size zero. 1186*0e209d39SAndroid Build Coastguard Worker * 1187*0e209d39SAndroid Build Coastguard Worker * @param src1 the first sort key 1188*0e209d39SAndroid Build Coastguard Worker * @param src1Length the length of the first sort key, including the zero byte at the end; 1189*0e209d39SAndroid Build Coastguard Worker * can be -1 if the function is to find the length 1190*0e209d39SAndroid Build Coastguard Worker * @param src2 the second sort key 1191*0e209d39SAndroid Build Coastguard Worker * @param src2Length the length of the second sort key, including the zero byte at the end; 1192*0e209d39SAndroid Build Coastguard Worker * can be -1 if the function is to find the length 1193*0e209d39SAndroid Build Coastguard Worker * @param dest the buffer where the merged sort key is written, 1194*0e209d39SAndroid Build Coastguard Worker * can be NULL if destCapacity==0 1195*0e209d39SAndroid Build Coastguard Worker * @param destCapacity the number of bytes in the dest buffer 1196*0e209d39SAndroid Build Coastguard Worker * @return the length of the merged sort key, src1Length+src2Length; 1197*0e209d39SAndroid Build Coastguard Worker * can be larger than destCapacity, or 0 if an error occurs (only for illegal arguments), 1198*0e209d39SAndroid Build Coastguard Worker * in which cases the contents of dest is undefined 1199*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 1200*0e209d39SAndroid Build Coastguard Worker */ 1201*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 1202*0e209d39SAndroid Build Coastguard Worker ucol_mergeSortkeys(const uint8_t *src1, int32_t src1Length, 1203*0e209d39SAndroid Build Coastguard Worker const uint8_t *src2, int32_t src2Length, 1204*0e209d39SAndroid Build Coastguard Worker uint8_t *dest, int32_t destCapacity); 1205*0e209d39SAndroid Build Coastguard Worker 1206*0e209d39SAndroid Build Coastguard Worker /** 1207*0e209d39SAndroid Build Coastguard Worker * Universal attribute setter 1208*0e209d39SAndroid Build Coastguard Worker * @param coll collator which attributes are to be changed 1209*0e209d39SAndroid Build Coastguard Worker * @param attr attribute type 1210*0e209d39SAndroid Build Coastguard Worker * @param value attribute value 1211*0e209d39SAndroid Build Coastguard Worker * @param status to indicate whether the operation went on smoothly or there were errors 1212*0e209d39SAndroid Build Coastguard Worker * @see UColAttribute 1213*0e209d39SAndroid Build Coastguard Worker * @see UColAttributeValue 1214*0e209d39SAndroid Build Coastguard Worker * @see ucol_getAttribute 1215*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 1216*0e209d39SAndroid Build Coastguard Worker */ 1217*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 1218*0e209d39SAndroid Build Coastguard Worker ucol_setAttribute(UCollator *coll, UColAttribute attr, UColAttributeValue value, UErrorCode *status); 1219*0e209d39SAndroid Build Coastguard Worker 1220*0e209d39SAndroid Build Coastguard Worker /** 1221*0e209d39SAndroid Build Coastguard Worker * Universal attribute getter 1222*0e209d39SAndroid Build Coastguard Worker * @param coll collator which attributes are to be changed 1223*0e209d39SAndroid Build Coastguard Worker * @param attr attribute type 1224*0e209d39SAndroid Build Coastguard Worker * @return attribute value 1225*0e209d39SAndroid Build Coastguard Worker * @param status to indicate whether the operation went on smoothly or there were errors 1226*0e209d39SAndroid Build Coastguard Worker * @see UColAttribute 1227*0e209d39SAndroid Build Coastguard Worker * @see UColAttributeValue 1228*0e209d39SAndroid Build Coastguard Worker * @see ucol_setAttribute 1229*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 1230*0e209d39SAndroid Build Coastguard Worker */ 1231*0e209d39SAndroid Build Coastguard Worker U_CAPI UColAttributeValue U_EXPORT2 1232*0e209d39SAndroid Build Coastguard Worker ucol_getAttribute(const UCollator *coll, UColAttribute attr, UErrorCode *status); 1233*0e209d39SAndroid Build Coastguard Worker 1234*0e209d39SAndroid Build Coastguard Worker /** 1235*0e209d39SAndroid Build Coastguard Worker * Sets the variable top to the top of the specified reordering group. 1236*0e209d39SAndroid Build Coastguard Worker * The variable top determines the highest-sorting character 1237*0e209d39SAndroid Build Coastguard Worker * which is affected by UCOL_ALTERNATE_HANDLING. 1238*0e209d39SAndroid Build Coastguard Worker * If that attribute is set to UCOL_NON_IGNORABLE, then the variable top has no effect. 1239*0e209d39SAndroid Build Coastguard Worker * @param coll the collator 1240*0e209d39SAndroid Build Coastguard Worker * @param group one of UCOL_REORDER_CODE_SPACE, UCOL_REORDER_CODE_PUNCTUATION, 1241*0e209d39SAndroid Build Coastguard Worker * UCOL_REORDER_CODE_SYMBOL, UCOL_REORDER_CODE_CURRENCY; 1242*0e209d39SAndroid Build Coastguard Worker * or UCOL_REORDER_CODE_DEFAULT to restore the default max variable group 1243*0e209d39SAndroid Build Coastguard Worker * @param pErrorCode Standard ICU error code. Its input value must 1244*0e209d39SAndroid Build Coastguard Worker * pass the U_SUCCESS() test, or else the function returns 1245*0e209d39SAndroid Build Coastguard Worker * immediately. Check for U_FAILURE() on output or use with 1246*0e209d39SAndroid Build Coastguard Worker * function chaining. (See User Guide for details.) 1247*0e209d39SAndroid Build Coastguard Worker * @see ucol_getMaxVariable 1248*0e209d39SAndroid Build Coastguard Worker * @stable ICU 53 1249*0e209d39SAndroid Build Coastguard Worker */ 1250*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 1251*0e209d39SAndroid Build Coastguard Worker ucol_setMaxVariable(UCollator *coll, UColReorderCode group, UErrorCode *pErrorCode); 1252*0e209d39SAndroid Build Coastguard Worker 1253*0e209d39SAndroid Build Coastguard Worker /** 1254*0e209d39SAndroid Build Coastguard Worker * Returns the maximum reordering group whose characters are affected by UCOL_ALTERNATE_HANDLING. 1255*0e209d39SAndroid Build Coastguard Worker * @param coll the collator 1256*0e209d39SAndroid Build Coastguard Worker * @return the maximum variable reordering group. 1257*0e209d39SAndroid Build Coastguard Worker * @see ucol_setMaxVariable 1258*0e209d39SAndroid Build Coastguard Worker * @stable ICU 53 1259*0e209d39SAndroid Build Coastguard Worker */ 1260*0e209d39SAndroid Build Coastguard Worker U_CAPI UColReorderCode U_EXPORT2 1261*0e209d39SAndroid Build Coastguard Worker ucol_getMaxVariable(const UCollator *coll); 1262*0e209d39SAndroid Build Coastguard Worker 1263*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API 1264*0e209d39SAndroid Build Coastguard Worker /** 1265*0e209d39SAndroid Build Coastguard Worker * Sets the variable top to the primary weight of the specified string. 1266*0e209d39SAndroid Build Coastguard Worker * 1267*0e209d39SAndroid Build Coastguard Worker * Beginning with ICU 53, the variable top is pinned to 1268*0e209d39SAndroid Build Coastguard Worker * the top of one of the supported reordering groups, 1269*0e209d39SAndroid Build Coastguard Worker * and it must not be beyond the last of those groups. 1270*0e209d39SAndroid Build Coastguard Worker * See ucol_setMaxVariable(). 1271*0e209d39SAndroid Build Coastguard Worker * @param coll the collator 1272*0e209d39SAndroid Build Coastguard Worker * @param varTop one or more (if contraction) UChars to which the variable top should be set 1273*0e209d39SAndroid Build Coastguard Worker * @param len length of variable top string. If -1 it is considered to be zero terminated. 1274*0e209d39SAndroid Build Coastguard Worker * @param status error code. If error code is set, the return value is undefined. 1275*0e209d39SAndroid Build Coastguard Worker * Errors set by this function are:<br> 1276*0e209d39SAndroid Build Coastguard Worker * U_CE_NOT_FOUND_ERROR if more than one character was passed and there is no such contraction<br> 1277*0e209d39SAndroid Build Coastguard Worker * U_ILLEGAL_ARGUMENT_ERROR if the variable top is beyond 1278*0e209d39SAndroid Build Coastguard Worker * the last reordering group supported by ucol_setMaxVariable() 1279*0e209d39SAndroid Build Coastguard Worker * @return variable top primary weight 1280*0e209d39SAndroid Build Coastguard Worker * @see ucol_getVariableTop 1281*0e209d39SAndroid Build Coastguard Worker * @see ucol_restoreVariableTop 1282*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 53 Call ucol_setMaxVariable() instead. 1283*0e209d39SAndroid Build Coastguard Worker */ 1284*0e209d39SAndroid Build Coastguard Worker U_DEPRECATED uint32_t U_EXPORT2 1285*0e209d39SAndroid Build Coastguard Worker ucol_setVariableTop(UCollator *coll, 1286*0e209d39SAndroid Build Coastguard Worker const UChar *varTop, int32_t len, 1287*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 1288*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_DEPRECATED_API */ 1289*0e209d39SAndroid Build Coastguard Worker 1290*0e209d39SAndroid Build Coastguard Worker /** 1291*0e209d39SAndroid Build Coastguard Worker * Gets the variable top value of a Collator. 1292*0e209d39SAndroid Build Coastguard Worker * @param coll collator which variable top needs to be retrieved 1293*0e209d39SAndroid Build Coastguard Worker * @param status error code (not changed by function). If error code is set, 1294*0e209d39SAndroid Build Coastguard Worker * the return value is undefined. 1295*0e209d39SAndroid Build Coastguard Worker * @return the variable top primary weight 1296*0e209d39SAndroid Build Coastguard Worker * @see ucol_getMaxVariable 1297*0e209d39SAndroid Build Coastguard Worker * @see ucol_setVariableTop 1298*0e209d39SAndroid Build Coastguard Worker * @see ucol_restoreVariableTop 1299*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 1300*0e209d39SAndroid Build Coastguard Worker */ 1301*0e209d39SAndroid Build Coastguard Worker U_CAPI uint32_t U_EXPORT2 ucol_getVariableTop(const UCollator *coll, UErrorCode *status); 1302*0e209d39SAndroid Build Coastguard Worker 1303*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API 1304*0e209d39SAndroid Build Coastguard Worker /** 1305*0e209d39SAndroid Build Coastguard Worker * Sets the variable top to the specified primary weight. 1306*0e209d39SAndroid Build Coastguard Worker * 1307*0e209d39SAndroid Build Coastguard Worker * Beginning with ICU 53, the variable top is pinned to 1308*0e209d39SAndroid Build Coastguard Worker * the top of one of the supported reordering groups, 1309*0e209d39SAndroid Build Coastguard Worker * and it must not be beyond the last of those groups. 1310*0e209d39SAndroid Build Coastguard Worker * See ucol_setMaxVariable(). 1311*0e209d39SAndroid Build Coastguard Worker * @param coll collator to be set 1312*0e209d39SAndroid Build Coastguard Worker * @param varTop primary weight, as returned by ucol_setVariableTop or ucol_getVariableTop 1313*0e209d39SAndroid Build Coastguard Worker * @param status error code 1314*0e209d39SAndroid Build Coastguard Worker * @see ucol_getVariableTop 1315*0e209d39SAndroid Build Coastguard Worker * @see ucol_setVariableTop 1316*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 53 Call ucol_setMaxVariable() instead. 1317*0e209d39SAndroid Build Coastguard Worker */ 1318*0e209d39SAndroid Build Coastguard Worker U_DEPRECATED void U_EXPORT2 1319*0e209d39SAndroid Build Coastguard Worker ucol_restoreVariableTop(UCollator *coll, const uint32_t varTop, UErrorCode *status); 1320*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_DEPRECATED_API */ 1321*0e209d39SAndroid Build Coastguard Worker 1322*0e209d39SAndroid Build Coastguard Worker /** 1323*0e209d39SAndroid Build Coastguard Worker * Thread safe cloning operation. The result is a clone of a given collator. 1324*0e209d39SAndroid Build Coastguard Worker * @param coll collator to be cloned 1325*0e209d39SAndroid Build Coastguard Worker * @param status to indicate whether the operation went on smoothly or there were errors 1326*0e209d39SAndroid Build Coastguard Worker * @return pointer to the new clone 1327*0e209d39SAndroid Build Coastguard Worker * @see ucol_open 1328*0e209d39SAndroid Build Coastguard Worker * @see ucol_openRules 1329*0e209d39SAndroid Build Coastguard Worker * @see ucol_close 1330*0e209d39SAndroid Build Coastguard Worker * @stable ICU 71 1331*0e209d39SAndroid Build Coastguard Worker */ 1332*0e209d39SAndroid Build Coastguard Worker U_CAPI UCollator* U_EXPORT2 ucol_clone(const UCollator *coll, UErrorCode *status); 1333*0e209d39SAndroid Build Coastguard Worker 1334*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API 1335*0e209d39SAndroid Build Coastguard Worker 1336*0e209d39SAndroid Build Coastguard Worker /** 1337*0e209d39SAndroid Build Coastguard Worker * Thread safe cloning operation. The result is a clone of a given collator. 1338*0e209d39SAndroid Build Coastguard Worker * @param coll collator to be cloned 1339*0e209d39SAndroid Build Coastguard Worker * @param stackBuffer <em>Deprecated functionality as of ICU 52, use NULL.</em><br> 1340*0e209d39SAndroid Build Coastguard Worker * user allocated space for the new clone. 1341*0e209d39SAndroid Build Coastguard Worker * If NULL new memory will be allocated. 1342*0e209d39SAndroid Build Coastguard Worker * If buffer is not large enough, new memory will be allocated. 1343*0e209d39SAndroid Build Coastguard Worker * Clients can use the U_COL_SAFECLONE_BUFFERSIZE. 1344*0e209d39SAndroid Build Coastguard Worker * @param pBufferSize <em>Deprecated functionality as of ICU 52, use NULL or 1.</em><br> 1345*0e209d39SAndroid Build Coastguard Worker * pointer to size of allocated space. 1346*0e209d39SAndroid Build Coastguard Worker * If *pBufferSize == 0, a sufficient size for use in cloning will 1347*0e209d39SAndroid Build Coastguard Worker * be returned ('pre-flighting') 1348*0e209d39SAndroid Build Coastguard Worker * If *pBufferSize is not enough for a stack-based safe clone, 1349*0e209d39SAndroid Build Coastguard Worker * new memory will be allocated. 1350*0e209d39SAndroid Build Coastguard Worker * @param status to indicate whether the operation went on smoothly or there were errors 1351*0e209d39SAndroid Build Coastguard Worker * An informational status value, U_SAFECLONE_ALLOCATED_ERROR, is used 1352*0e209d39SAndroid Build Coastguard Worker * if pBufferSize != NULL and any allocations were necessary 1353*0e209d39SAndroid Build Coastguard Worker * @return pointer to the new clone 1354*0e209d39SAndroid Build Coastguard Worker * @see ucol_open 1355*0e209d39SAndroid Build Coastguard Worker * @see ucol_openRules 1356*0e209d39SAndroid Build Coastguard Worker * @see ucol_close 1357*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 71 Use ucol_clone() instead. 1358*0e209d39SAndroid Build Coastguard Worker */ 1359*0e209d39SAndroid Build Coastguard Worker U_DEPRECATED UCollator* U_EXPORT2 1360*0e209d39SAndroid Build Coastguard Worker ucol_safeClone(const UCollator *coll, 1361*0e209d39SAndroid Build Coastguard Worker void *stackBuffer, 1362*0e209d39SAndroid Build Coastguard Worker int32_t *pBufferSize, 1363*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 1364*0e209d39SAndroid Build Coastguard Worker 1365*0e209d39SAndroid Build Coastguard Worker 1366*0e209d39SAndroid Build Coastguard Worker /** default memory size for the new clone. 1367*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 52. Do not rely on ucol_safeClone() cloning into any provided buffer. 1368*0e209d39SAndroid Build Coastguard Worker */ 1369*0e209d39SAndroid Build Coastguard Worker #define U_COL_SAFECLONE_BUFFERSIZE 1 1370*0e209d39SAndroid Build Coastguard Worker 1371*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_DEPRECATED_API */ 1372*0e209d39SAndroid Build Coastguard Worker 1373*0e209d39SAndroid Build Coastguard Worker /** 1374*0e209d39SAndroid Build Coastguard Worker * Returns current rules. Delta defines whether full rules are returned or just the tailoring. 1375*0e209d39SAndroid Build Coastguard Worker * Returns number of UChars needed to store rules. If buffer is NULL or bufferLen is not enough 1376*0e209d39SAndroid Build Coastguard Worker * to store rules, will store up to available space. 1377*0e209d39SAndroid Build Coastguard Worker * 1378*0e209d39SAndroid Build Coastguard Worker * ucol_getRules() should normally be used instead. 1379*0e209d39SAndroid Build Coastguard Worker * See https://unicode-org.github.io/icu/userguide/collation/customization#building-on-existing-locales 1380*0e209d39SAndroid Build Coastguard Worker * @param coll collator to get the rules from 1381*0e209d39SAndroid Build Coastguard Worker * @param delta one of UCOL_TAILORING_ONLY, UCOL_FULL_RULES. 1382*0e209d39SAndroid Build Coastguard Worker * @param buffer buffer to store the result in. If NULL, you'll get no rules. 1383*0e209d39SAndroid Build Coastguard Worker * @param bufferLen length of buffer to store rules in. If less than needed you'll get only the part that fits in. 1384*0e209d39SAndroid Build Coastguard Worker * @return current rules 1385*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.0 1386*0e209d39SAndroid Build Coastguard Worker * @see UCOL_FULL_RULES 1387*0e209d39SAndroid Build Coastguard Worker */ 1388*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 1389*0e209d39SAndroid Build Coastguard Worker ucol_getRulesEx(const UCollator *coll, UColRuleOption delta, UChar *buffer, int32_t bufferLen); 1390*0e209d39SAndroid Build Coastguard Worker 1391*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_DEPRECATED_API 1392*0e209d39SAndroid Build Coastguard Worker /** 1393*0e209d39SAndroid Build Coastguard Worker * gets the locale name of the collator. If the collator 1394*0e209d39SAndroid Build Coastguard Worker * is instantiated from the rules, then this function returns 1395*0e209d39SAndroid Build Coastguard Worker * NULL. 1396*0e209d39SAndroid Build Coastguard Worker * @param coll The UCollator for which the locale is needed 1397*0e209d39SAndroid Build Coastguard Worker * @param type You can choose between requested, valid and actual 1398*0e209d39SAndroid Build Coastguard Worker * locale. For description see the definition of 1399*0e209d39SAndroid Build Coastguard Worker * ULocDataLocaleType in uloc.h 1400*0e209d39SAndroid Build Coastguard Worker * @param status error code of the operation 1401*0e209d39SAndroid Build Coastguard Worker * @return real locale name from which the collation data comes. 1402*0e209d39SAndroid Build Coastguard Worker * If the collator was instantiated from rules, returns 1403*0e209d39SAndroid Build Coastguard Worker * NULL. 1404*0e209d39SAndroid Build Coastguard Worker * @deprecated ICU 2.8 Use ucol_getLocaleByType instead 1405*0e209d39SAndroid Build Coastguard Worker */ 1406*0e209d39SAndroid Build Coastguard Worker U_DEPRECATED const char * U_EXPORT2 1407*0e209d39SAndroid Build Coastguard Worker ucol_getLocale(const UCollator *coll, ULocDataLocaleType type, UErrorCode *status); 1408*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_DEPRECATED_API */ 1409*0e209d39SAndroid Build Coastguard Worker 1410*0e209d39SAndroid Build Coastguard Worker /** 1411*0e209d39SAndroid Build Coastguard Worker * gets the locale name of the collator. If the collator 1412*0e209d39SAndroid Build Coastguard Worker * is instantiated from the rules, then this function returns 1413*0e209d39SAndroid Build Coastguard Worker * NULL. 1414*0e209d39SAndroid Build Coastguard Worker * @param coll The UCollator for which the locale is needed 1415*0e209d39SAndroid Build Coastguard Worker * @param type You can choose between requested, valid and actual 1416*0e209d39SAndroid Build Coastguard Worker * locale. For description see the definition of 1417*0e209d39SAndroid Build Coastguard Worker * ULocDataLocaleType in uloc.h 1418*0e209d39SAndroid Build Coastguard Worker * @param status error code of the operation 1419*0e209d39SAndroid Build Coastguard Worker * @return real locale name from which the collation data comes. 1420*0e209d39SAndroid Build Coastguard Worker * If the collator was instantiated from rules, returns 1421*0e209d39SAndroid Build Coastguard Worker * NULL. 1422*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.8 1423*0e209d39SAndroid Build Coastguard Worker */ 1424*0e209d39SAndroid Build Coastguard Worker U_CAPI const char * U_EXPORT2 1425*0e209d39SAndroid Build Coastguard Worker ucol_getLocaleByType(const UCollator *coll, ULocDataLocaleType type, UErrorCode *status); 1426*0e209d39SAndroid Build Coastguard Worker 1427*0e209d39SAndroid Build Coastguard Worker /** 1428*0e209d39SAndroid Build Coastguard Worker * Get a Unicode set that contains all the characters and sequences tailored in 1429*0e209d39SAndroid Build Coastguard Worker * this collator. The result must be disposed of by using uset_close. 1430*0e209d39SAndroid Build Coastguard Worker * @param coll The UCollator for which we want to get tailored chars 1431*0e209d39SAndroid Build Coastguard Worker * @param status error code of the operation 1432*0e209d39SAndroid Build Coastguard Worker * @return a pointer to newly created USet. Must be be disposed by using uset_close 1433*0e209d39SAndroid Build Coastguard Worker * @see ucol_openRules 1434*0e209d39SAndroid Build Coastguard Worker * @see uset_close 1435*0e209d39SAndroid Build Coastguard Worker * @stable ICU 2.4 1436*0e209d39SAndroid Build Coastguard Worker */ 1437*0e209d39SAndroid Build Coastguard Worker U_CAPI USet * U_EXPORT2 1438*0e209d39SAndroid Build Coastguard Worker ucol_getTailoredSet(const UCollator *coll, UErrorCode *status); 1439*0e209d39SAndroid Build Coastguard Worker 1440*0e209d39SAndroid Build Coastguard Worker #ifndef U_HIDE_INTERNAL_API 1441*0e209d39SAndroid Build Coastguard Worker /** Calculates the set of unsafe code points, given a collator. 1442*0e209d39SAndroid Build Coastguard Worker * A character is unsafe if you could append any character and cause the ordering to alter significantly. 1443*0e209d39SAndroid Build Coastguard Worker * Collation sorts in normalized order, so anything that rearranges in normalization can cause this. 1444*0e209d39SAndroid Build Coastguard Worker * Thus if you have a character like a_umlaut, and you add a lower_dot to it, 1445*0e209d39SAndroid Build Coastguard Worker * then it normalizes to a_lower_dot + umlaut, and sorts differently. 1446*0e209d39SAndroid Build Coastguard Worker * @param coll Collator 1447*0e209d39SAndroid Build Coastguard Worker * @param unsafe a fill-in set to receive the unsafe points 1448*0e209d39SAndroid Build Coastguard Worker * @param status for catching errors 1449*0e209d39SAndroid Build Coastguard Worker * @return number of elements in the set 1450*0e209d39SAndroid Build Coastguard Worker * @internal ICU 3.0 1451*0e209d39SAndroid Build Coastguard Worker */ 1452*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 1453*0e209d39SAndroid Build Coastguard Worker ucol_getUnsafeSet( const UCollator *coll, 1454*0e209d39SAndroid Build Coastguard Worker USet *unsafe, 1455*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 1456*0e209d39SAndroid Build Coastguard Worker 1457*0e209d39SAndroid Build Coastguard Worker /** Touches all resources needed for instantiating a collator from a short string definition, 1458*0e209d39SAndroid Build Coastguard Worker * thus filling up the cache. 1459*0e209d39SAndroid Build Coastguard Worker * @param definition A short string containing a locale and a set of attributes. 1460*0e209d39SAndroid Build Coastguard Worker * Attributes not explicitly mentioned are left at the default 1461*0e209d39SAndroid Build Coastguard Worker * state for a locale. 1462*0e209d39SAndroid Build Coastguard Worker * @param parseError if not NULL, structure that will get filled with error's pre 1463*0e209d39SAndroid Build Coastguard Worker * and post context in case of error. 1464*0e209d39SAndroid Build Coastguard Worker * @param forceDefaults if false, the settings that are the same as the collator 1465*0e209d39SAndroid Build Coastguard Worker * default settings will not be applied (for example, setting 1466*0e209d39SAndroid Build Coastguard Worker * French secondary on a French collator would not be executed). 1467*0e209d39SAndroid Build Coastguard Worker * If true, all the settings will be applied regardless of the 1468*0e209d39SAndroid Build Coastguard Worker * collator default value. If the definition 1469*0e209d39SAndroid Build Coastguard Worker * strings are to be cached, should be set to false. 1470*0e209d39SAndroid Build Coastguard Worker * @param status Error code. Apart from regular error conditions connected to 1471*0e209d39SAndroid Build Coastguard Worker * instantiating collators (like out of memory or similar), this 1472*0e209d39SAndroid Build Coastguard Worker * API will return an error if an invalid attribute or attribute/value 1473*0e209d39SAndroid Build Coastguard Worker * combination is specified. 1474*0e209d39SAndroid Build Coastguard Worker * @see ucol_openFromShortString 1475*0e209d39SAndroid Build Coastguard Worker * @internal ICU 3.2.1 1476*0e209d39SAndroid Build Coastguard Worker */ 1477*0e209d39SAndroid Build Coastguard Worker U_CAPI void U_EXPORT2 1478*0e209d39SAndroid Build Coastguard Worker ucol_prepareShortStringOpen( const char *definition, 1479*0e209d39SAndroid Build Coastguard Worker UBool forceDefaults, 1480*0e209d39SAndroid Build Coastguard Worker UParseError *parseError, 1481*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 1482*0e209d39SAndroid Build Coastguard Worker #endif /* U_HIDE_INTERNAL_API */ 1483*0e209d39SAndroid Build Coastguard Worker 1484*0e209d39SAndroid Build Coastguard Worker /** Creates a binary image of a collator. This binary image can be stored and 1485*0e209d39SAndroid Build Coastguard Worker * later used to instantiate a collator using ucol_openBinary. 1486*0e209d39SAndroid Build Coastguard Worker * This API supports preflighting. 1487*0e209d39SAndroid Build Coastguard Worker * @param coll Collator 1488*0e209d39SAndroid Build Coastguard Worker * @param buffer a fill-in buffer to receive the binary image 1489*0e209d39SAndroid Build Coastguard Worker * @param capacity capacity of the destination buffer 1490*0e209d39SAndroid Build Coastguard Worker * @param status for catching errors 1491*0e209d39SAndroid Build Coastguard Worker * @return size of the image 1492*0e209d39SAndroid Build Coastguard Worker * @see ucol_openBinary 1493*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.2 1494*0e209d39SAndroid Build Coastguard Worker */ 1495*0e209d39SAndroid Build Coastguard Worker U_CAPI int32_t U_EXPORT2 1496*0e209d39SAndroid Build Coastguard Worker ucol_cloneBinary(const UCollator *coll, 1497*0e209d39SAndroid Build Coastguard Worker uint8_t *buffer, int32_t capacity, 1498*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 1499*0e209d39SAndroid Build Coastguard Worker 1500*0e209d39SAndroid Build Coastguard Worker /** Opens a collator from a collator binary image created using 1501*0e209d39SAndroid Build Coastguard Worker * ucol_cloneBinary. Binary image used in instantiation of the 1502*0e209d39SAndroid Build Coastguard Worker * collator remains owned by the user and should stay around for 1503*0e209d39SAndroid Build Coastguard Worker * the lifetime of the collator. The API also takes a base collator 1504*0e209d39SAndroid Build Coastguard Worker * which must be the root collator. 1505*0e209d39SAndroid Build Coastguard Worker * @param bin binary image owned by the user and required through the 1506*0e209d39SAndroid Build Coastguard Worker * lifetime of the collator 1507*0e209d39SAndroid Build Coastguard Worker * @param length size of the image. If negative, the API will try to 1508*0e209d39SAndroid Build Coastguard Worker * figure out the length of the image 1509*0e209d39SAndroid Build Coastguard Worker * @param base Base collator, for lookup of untailored characters. 1510*0e209d39SAndroid Build Coastguard Worker * Must be the root collator, must not be NULL. 1511*0e209d39SAndroid Build Coastguard Worker * The base is required to be present through the lifetime of the collator. 1512*0e209d39SAndroid Build Coastguard Worker * @param status for catching errors 1513*0e209d39SAndroid Build Coastguard Worker * @return newly created collator 1514*0e209d39SAndroid Build Coastguard Worker * @see ucol_cloneBinary 1515*0e209d39SAndroid Build Coastguard Worker * @stable ICU 3.2 1516*0e209d39SAndroid Build Coastguard Worker */ 1517*0e209d39SAndroid Build Coastguard Worker U_CAPI UCollator* U_EXPORT2 1518*0e209d39SAndroid Build Coastguard Worker ucol_openBinary(const uint8_t *bin, int32_t length, 1519*0e209d39SAndroid Build Coastguard Worker const UCollator *base, 1520*0e209d39SAndroid Build Coastguard Worker UErrorCode *status); 1521*0e209d39SAndroid Build Coastguard Worker 1522*0e209d39SAndroid Build Coastguard Worker 1523*0e209d39SAndroid Build Coastguard Worker #endif /* #if !UCONFIG_NO_COLLATION */ 1524*0e209d39SAndroid Build Coastguard Worker 1525*0e209d39SAndroid Build Coastguard Worker #endif 1526