17777dab0Sopenharmony_ci// © 2016 and later: Unicode, Inc. and others.
27777dab0Sopenharmony_ci// License & terms of use: http://www.unicode.org/copyright.html
37777dab0Sopenharmony_ci/*
47777dab0Sopenharmony_ci*******************************************************************************
57777dab0Sopenharmony_ci* Copyright (c) 1996-2015, International Business Machines Corporation and others.
67777dab0Sopenharmony_ci* All Rights Reserved.
77777dab0Sopenharmony_ci*******************************************************************************
87777dab0Sopenharmony_ci*/
97777dab0Sopenharmony_ci
107777dab0Sopenharmony_ci#ifndef UCOL_H
117777dab0Sopenharmony_ci#define UCOL_H
127777dab0Sopenharmony_ci
137777dab0Sopenharmony_ci#include "unicode/utypes.h"
147777dab0Sopenharmony_ci
157777dab0Sopenharmony_ci#if !UCONFIG_NO_COLLATION
167777dab0Sopenharmony_ci
177777dab0Sopenharmony_ci#include "unicode/parseerr.h"
187777dab0Sopenharmony_ci#include "unicode/uloc.h"
197777dab0Sopenharmony_ci#include "unicode/uset.h"
207777dab0Sopenharmony_ci#include "unicode/uscript.h"
217777dab0Sopenharmony_ci
227777dab0Sopenharmony_ci#if U_SHOW_CPLUSPLUS_API
237777dab0Sopenharmony_ci#include "unicode/localpointer.h"
247777dab0Sopenharmony_ci#endif   // U_SHOW_CPLUSPLUS_API
257777dab0Sopenharmony_ci
267777dab0Sopenharmony_ci/**
277777dab0Sopenharmony_ci * \file
287777dab0Sopenharmony_ci * \brief C API: Collator
297777dab0Sopenharmony_ci *
307777dab0Sopenharmony_ci * <h2> Collator C API </h2>
317777dab0Sopenharmony_ci *
327777dab0Sopenharmony_ci * The C API for Collator performs locale-sensitive
337777dab0Sopenharmony_ci * string comparison. You use this service to build
347777dab0Sopenharmony_ci * searching and sorting routines for natural language text.
357777dab0Sopenharmony_ci * <p>
367777dab0Sopenharmony_ci * For more information about the collation service see
377777dab0Sopenharmony_ci * <a href="https://unicode-org.github.io/icu/userguide/collation">the User Guide</a>.
387777dab0Sopenharmony_ci * <p>
397777dab0Sopenharmony_ci * Collation service provides correct sorting orders for most locales supported in ICU.
407777dab0Sopenharmony_ci * If specific data for a locale is not available, the orders eventually falls back
417777dab0Sopenharmony_ci * to the <a href="http://www.unicode.org/reports/tr35/tr35-collation.html#Root_Collation">CLDR root sort order</a>.
427777dab0Sopenharmony_ci * <p>
437777dab0Sopenharmony_ci * Sort ordering may be customized by providing your own set of rules. For more on
447777dab0Sopenharmony_ci * this subject see the <a href="https://unicode-org.github.io/icu/userguide/collation/customization">
457777dab0Sopenharmony_ci * Collation Customization</a> section of the User Guide.
467777dab0Sopenharmony_ci * <p>
477777dab0Sopenharmony_ci * @see         UCollationResult
487777dab0Sopenharmony_ci * @see         UNormalizationMode
497777dab0Sopenharmony_ci * @see         UCollationStrength
507777dab0Sopenharmony_ci * @see         UCollationElements
517777dab0Sopenharmony_ci */
527777dab0Sopenharmony_ci
537777dab0Sopenharmony_ci/** A collator.
547777dab0Sopenharmony_ci*  For usage in C programs.
557777dab0Sopenharmony_ci*/
567777dab0Sopenharmony_cistruct UCollator;
577777dab0Sopenharmony_ci/** structure representing a collator object instance
587777dab0Sopenharmony_ci * @stable ICU 2.0
597777dab0Sopenharmony_ci */
607777dab0Sopenharmony_citypedef struct UCollator UCollator;
617777dab0Sopenharmony_ci
627777dab0Sopenharmony_ci
637777dab0Sopenharmony_ci/**
647777dab0Sopenharmony_ci * UCOL_LESS is returned if source string is compared to be less than target
657777dab0Sopenharmony_ci * string in the ucol_strcoll() method.
667777dab0Sopenharmony_ci * UCOL_EQUAL is returned if source string is compared to be equal to target
677777dab0Sopenharmony_ci * string in the ucol_strcoll() method.
687777dab0Sopenharmony_ci * UCOL_GREATER is returned if source string is compared to be greater than
697777dab0Sopenharmony_ci * target string in the ucol_strcoll() method.
707777dab0Sopenharmony_ci * @see ucol_strcoll()
717777dab0Sopenharmony_ci * <p>
727777dab0Sopenharmony_ci * Possible values for a comparison result
737777dab0Sopenharmony_ci * @stable ICU 2.0
747777dab0Sopenharmony_ci */
757777dab0Sopenharmony_citypedef enum {
767777dab0Sopenharmony_ci  /** string a == string b */
777777dab0Sopenharmony_ci  UCOL_EQUAL    = 0,
787777dab0Sopenharmony_ci  /** string a > string b */
797777dab0Sopenharmony_ci  UCOL_GREATER    = 1,
807777dab0Sopenharmony_ci  /** string a < string b */
817777dab0Sopenharmony_ci  UCOL_LESS    = -1
827777dab0Sopenharmony_ci} UCollationResult ;
837777dab0Sopenharmony_ci
847777dab0Sopenharmony_ci
857777dab0Sopenharmony_ci/** Enum containing attribute values for controlling collation behavior.
867777dab0Sopenharmony_ci * Here are all the allowable values. Not every attribute can take every value. The only
877777dab0Sopenharmony_ci * universal value is UCOL_DEFAULT, which resets the attribute value to the predefined
887777dab0Sopenharmony_ci * value for that locale
897777dab0Sopenharmony_ci * @stable ICU 2.0
907777dab0Sopenharmony_ci */
917777dab0Sopenharmony_citypedef enum {
927777dab0Sopenharmony_ci  /** accepted by most attributes */
937777dab0Sopenharmony_ci  UCOL_DEFAULT = -1,
947777dab0Sopenharmony_ci
957777dab0Sopenharmony_ci  /** Primary collation strength */
967777dab0Sopenharmony_ci  UCOL_PRIMARY = 0,
977777dab0Sopenharmony_ci  /** Secondary collation strength */
987777dab0Sopenharmony_ci  UCOL_SECONDARY = 1,
997777dab0Sopenharmony_ci  /** Tertiary collation strength */
1007777dab0Sopenharmony_ci  UCOL_TERTIARY = 2,
1017777dab0Sopenharmony_ci  /** Default collation strength */
1027777dab0Sopenharmony_ci  UCOL_DEFAULT_STRENGTH = UCOL_TERTIARY,
1037777dab0Sopenharmony_ci  UCOL_CE_STRENGTH_LIMIT,
1047777dab0Sopenharmony_ci  /** Quaternary collation strength */
1057777dab0Sopenharmony_ci  UCOL_QUATERNARY=3,
1067777dab0Sopenharmony_ci  /** Identical collation strength */
1077777dab0Sopenharmony_ci  UCOL_IDENTICAL=15,
1087777dab0Sopenharmony_ci  UCOL_STRENGTH_LIMIT,
1097777dab0Sopenharmony_ci
1107777dab0Sopenharmony_ci  /** Turn the feature off - works for UCOL_FRENCH_COLLATION,
1117777dab0Sopenharmony_ci      UCOL_CASE_LEVEL, UCOL_HIRAGANA_QUATERNARY_MODE
1127777dab0Sopenharmony_ci      & UCOL_DECOMPOSITION_MODE*/
1137777dab0Sopenharmony_ci  UCOL_OFF = 16,
1147777dab0Sopenharmony_ci  /** Turn the feature on - works for UCOL_FRENCH_COLLATION,
1157777dab0Sopenharmony_ci      UCOL_CASE_LEVEL, UCOL_HIRAGANA_QUATERNARY_MODE
1167777dab0Sopenharmony_ci      & UCOL_DECOMPOSITION_MODE*/
1177777dab0Sopenharmony_ci  UCOL_ON = 17,
1187777dab0Sopenharmony_ci
1197777dab0Sopenharmony_ci  /** Valid for UCOL_ALTERNATE_HANDLING. Alternate handling will be shifted */
1207777dab0Sopenharmony_ci  UCOL_SHIFTED = 20,
1217777dab0Sopenharmony_ci  /** Valid for UCOL_ALTERNATE_HANDLING. Alternate handling will be non ignorable */
1227777dab0Sopenharmony_ci  UCOL_NON_IGNORABLE = 21,
1237777dab0Sopenharmony_ci
1247777dab0Sopenharmony_ci  /** Valid for UCOL_CASE_FIRST -
1257777dab0Sopenharmony_ci      lower case sorts before upper case */
1267777dab0Sopenharmony_ci  UCOL_LOWER_FIRST = 24,
1277777dab0Sopenharmony_ci  /** upper case sorts before lower case */
1287777dab0Sopenharmony_ci  UCOL_UPPER_FIRST = 25
1297777dab0Sopenharmony_ci} UColAttributeValue;
1307777dab0Sopenharmony_ci
1317777dab0Sopenharmony_ci/**
1327777dab0Sopenharmony_ci * Enum containing the codes for reordering segments of the collation table that are not script
1337777dab0Sopenharmony_ci * codes. These reordering codes are to be used in conjunction with the script codes.
1347777dab0Sopenharmony_ci * @see ucol_getReorderCodes
1357777dab0Sopenharmony_ci * @see ucol_setReorderCodes
1367777dab0Sopenharmony_ci * @see ucol_getEquivalentReorderCodes
1377777dab0Sopenharmony_ci * @see UScriptCode
1387777dab0Sopenharmony_ci * @stable ICU 4.8
1397777dab0Sopenharmony_ci */
1407777dab0Sopenharmony_ci typedef enum {
1417777dab0Sopenharmony_ci   /**
1427777dab0Sopenharmony_ci    * A special reordering code that is used to specify the default
1437777dab0Sopenharmony_ci    * reordering codes for a locale.
1447777dab0Sopenharmony_ci    * @stable ICU 4.8
1457777dab0Sopenharmony_ci    */
1467777dab0Sopenharmony_ci    UCOL_REORDER_CODE_DEFAULT       = -1,
1477777dab0Sopenharmony_ci   /**
1487777dab0Sopenharmony_ci    * A special reordering code that is used to specify no reordering codes.
1497777dab0Sopenharmony_ci    * @stable ICU 4.8
1507777dab0Sopenharmony_ci    */
1517777dab0Sopenharmony_ci    UCOL_REORDER_CODE_NONE          = USCRIPT_UNKNOWN,
1527777dab0Sopenharmony_ci   /**
1537777dab0Sopenharmony_ci    * A special reordering code that is used to specify all other codes used for
1547777dab0Sopenharmony_ci    * reordering except for the codes lised as UColReorderCode values and those
1557777dab0Sopenharmony_ci    * listed explicitly in a reordering.
1567777dab0Sopenharmony_ci    * @stable ICU 4.8
1577777dab0Sopenharmony_ci    */
1587777dab0Sopenharmony_ci    UCOL_REORDER_CODE_OTHERS        = USCRIPT_UNKNOWN,
1597777dab0Sopenharmony_ci   /**
1607777dab0Sopenharmony_ci    * Characters with the space property.
1617777dab0Sopenharmony_ci    * This is equivalent to the rule value "space".
1627777dab0Sopenharmony_ci    * @stable ICU 4.8
1637777dab0Sopenharmony_ci    */
1647777dab0Sopenharmony_ci    UCOL_REORDER_CODE_SPACE         = 0x1000,
1657777dab0Sopenharmony_ci   /**
1667777dab0Sopenharmony_ci    * The first entry in the enumeration of reordering groups. This is intended for use in
1677777dab0Sopenharmony_ci    * range checking and enumeration of the reorder codes.
1687777dab0Sopenharmony_ci    * @stable ICU 4.8
1697777dab0Sopenharmony_ci    */
1707777dab0Sopenharmony_ci    UCOL_REORDER_CODE_FIRST         = UCOL_REORDER_CODE_SPACE,
1717777dab0Sopenharmony_ci   /**
1727777dab0Sopenharmony_ci    * Characters with the punctuation property.
1737777dab0Sopenharmony_ci    * This is equivalent to the rule value "punct".
1747777dab0Sopenharmony_ci    * @stable ICU 4.8
1757777dab0Sopenharmony_ci    */
1767777dab0Sopenharmony_ci    UCOL_REORDER_CODE_PUNCTUATION   = 0x1001,
1777777dab0Sopenharmony_ci   /**
1787777dab0Sopenharmony_ci    * Characters with the symbol property.
1797777dab0Sopenharmony_ci    * This is equivalent to the rule value "symbol".
1807777dab0Sopenharmony_ci    * @stable ICU 4.8
1817777dab0Sopenharmony_ci    */
1827777dab0Sopenharmony_ci    UCOL_REORDER_CODE_SYMBOL        = 0x1002,
1837777dab0Sopenharmony_ci   /**
1847777dab0Sopenharmony_ci    * Characters with the currency property.
1857777dab0Sopenharmony_ci    * This is equivalent to the rule value "currency".
1867777dab0Sopenharmony_ci    * @stable ICU 4.8
1877777dab0Sopenharmony_ci    */
1887777dab0Sopenharmony_ci    UCOL_REORDER_CODE_CURRENCY      = 0x1003,
1897777dab0Sopenharmony_ci   /**
1907777dab0Sopenharmony_ci    * Characters with the digit property.
1917777dab0Sopenharmony_ci    * This is equivalent to the rule value "digit".
1927777dab0Sopenharmony_ci    * @stable ICU 4.8
1937777dab0Sopenharmony_ci    */
1947777dab0Sopenharmony_ci    UCOL_REORDER_CODE_DIGIT         = 0x1004
1957777dab0Sopenharmony_ci} UColReorderCode;
1967777dab0Sopenharmony_ci
1977777dab0Sopenharmony_ci/**
1987777dab0Sopenharmony_ci * Base letter represents a primary difference.  Set comparison
1997777dab0Sopenharmony_ci * level to UCOL_PRIMARY to ignore secondary and tertiary differences.
2007777dab0Sopenharmony_ci * Use this to set the strength of a Collator object.
2017777dab0Sopenharmony_ci * Example of primary difference, "abc" &lt; "abd"
2027777dab0Sopenharmony_ci *
2037777dab0Sopenharmony_ci * Diacritical differences on the same base letter represent a secondary
2047777dab0Sopenharmony_ci * difference.  Set comparison level to UCOL_SECONDARY to ignore tertiary
2057777dab0Sopenharmony_ci * differences. Use this to set the strength of a Collator object.
2067777dab0Sopenharmony_ci * Example of secondary difference, "&auml;" >> "a".
2077777dab0Sopenharmony_ci *
2087777dab0Sopenharmony_ci * Uppercase and lowercase versions of the same character represents a
2097777dab0Sopenharmony_ci * tertiary difference.  Set comparison level to UCOL_TERTIARY to include
2107777dab0Sopenharmony_ci * all comparison differences. Use this to set the strength of a Collator
2117777dab0Sopenharmony_ci * object.
2127777dab0Sopenharmony_ci * Example of tertiary difference, "abc" &lt;&lt;&lt; "ABC".
2137777dab0Sopenharmony_ci *
2147777dab0Sopenharmony_ci * Two characters are considered "identical" when they have the same
2157777dab0Sopenharmony_ci * unicode spellings.  UCOL_IDENTICAL.
2167777dab0Sopenharmony_ci * For example, "&auml;" == "&auml;".
2177777dab0Sopenharmony_ci *
2187777dab0Sopenharmony_ci * UCollationStrength is also used to determine the strength of sort keys
2197777dab0Sopenharmony_ci * generated from UCollator objects
2207777dab0Sopenharmony_ci * These values can be now found in the UColAttributeValue enum.
2217777dab0Sopenharmony_ci * @stable ICU 2.0
2227777dab0Sopenharmony_ci **/
2237777dab0Sopenharmony_citypedef UColAttributeValue UCollationStrength;
2247777dab0Sopenharmony_ci
2257777dab0Sopenharmony_ci/** Attributes that collation service understands. All the attributes can take UCOL_DEFAULT
2267777dab0Sopenharmony_ci * value, as well as the values specific to each one.
2277777dab0Sopenharmony_ci * @stable ICU 2.0
2287777dab0Sopenharmony_ci */
2297777dab0Sopenharmony_citypedef enum {
2307777dab0Sopenharmony_ci     /** Attribute for direction of secondary weights - used in Canadian French.
2317777dab0Sopenharmony_ci      * Acceptable values are UCOL_ON, which results in secondary weights
2327777dab0Sopenharmony_ci      * being considered backwards and UCOL_OFF which treats secondary
2337777dab0Sopenharmony_ci      * weights in the order they appear.
2347777dab0Sopenharmony_ci      * @stable ICU 2.0
2357777dab0Sopenharmony_ci      */
2367777dab0Sopenharmony_ci     UCOL_FRENCH_COLLATION,
2377777dab0Sopenharmony_ci     /** Attribute for handling variable elements.
2387777dab0Sopenharmony_ci      * Acceptable values are UCOL_NON_IGNORABLE (default)
2397777dab0Sopenharmony_ci      * which treats all the codepoints with non-ignorable
2407777dab0Sopenharmony_ci      * primary weights in the same way,
2417777dab0Sopenharmony_ci      * and UCOL_SHIFTED which causes codepoints with primary
2427777dab0Sopenharmony_ci      * weights that are equal or below the variable top value
2437777dab0Sopenharmony_ci      * to be ignored on primary level and moved to the quaternary
2447777dab0Sopenharmony_ci      * level.
2457777dab0Sopenharmony_ci      * @stable ICU 2.0
2467777dab0Sopenharmony_ci      */
2477777dab0Sopenharmony_ci     UCOL_ALTERNATE_HANDLING,
2487777dab0Sopenharmony_ci     /** Controls the ordering of upper and lower case letters.
2497777dab0Sopenharmony_ci      * Acceptable values are UCOL_OFF (default), which orders
2507777dab0Sopenharmony_ci      * upper and lower case letters in accordance to their tertiary
2517777dab0Sopenharmony_ci      * weights, UCOL_UPPER_FIRST which forces upper case letters to
2527777dab0Sopenharmony_ci      * sort before lower case letters, and UCOL_LOWER_FIRST which does
2537777dab0Sopenharmony_ci      * the opposite.
2547777dab0Sopenharmony_ci      * @stable ICU 2.0
2557777dab0Sopenharmony_ci      */
2567777dab0Sopenharmony_ci     UCOL_CASE_FIRST,
2577777dab0Sopenharmony_ci     /** Controls whether an extra case level (positioned before the third
2587777dab0Sopenharmony_ci      * level) is generated or not. Acceptable values are UCOL_OFF (default),
2597777dab0Sopenharmony_ci      * when case level is not generated, and UCOL_ON which causes the case
2607777dab0Sopenharmony_ci      * level to be generated. Contents of the case level are affected by
2617777dab0Sopenharmony_ci      * the value of UCOL_CASE_FIRST attribute. A simple way to ignore
2627777dab0Sopenharmony_ci      * accent differences in a string is to set the strength to UCOL_PRIMARY
2637777dab0Sopenharmony_ci      * and enable case level.
2647777dab0Sopenharmony_ci      * @stable ICU 2.0
2657777dab0Sopenharmony_ci      */
2667777dab0Sopenharmony_ci     UCOL_CASE_LEVEL,
2677777dab0Sopenharmony_ci     /** Controls whether the normalization check and necessary normalizations
2687777dab0Sopenharmony_ci      * are performed. When set to UCOL_OFF (default) no normalization check
2697777dab0Sopenharmony_ci      * is performed. The correctness of the result is guaranteed only if the
2707777dab0Sopenharmony_ci      * input data is in so-called FCD form (see users manual for more info).
2717777dab0Sopenharmony_ci      * When set to UCOL_ON, an incremental check is performed to see whether
2727777dab0Sopenharmony_ci      * the input data is in the FCD form. If the data is not in the FCD form,
2737777dab0Sopenharmony_ci      * incremental NFD normalization is performed.
2747777dab0Sopenharmony_ci      * @stable ICU 2.0
2757777dab0Sopenharmony_ci      */
2767777dab0Sopenharmony_ci     UCOL_NORMALIZATION_MODE,
2777777dab0Sopenharmony_ci     /** An alias for UCOL_NORMALIZATION_MODE attribute.
2787777dab0Sopenharmony_ci      * @stable ICU 2.0
2797777dab0Sopenharmony_ci      */
2807777dab0Sopenharmony_ci     UCOL_DECOMPOSITION_MODE = UCOL_NORMALIZATION_MODE,
2817777dab0Sopenharmony_ci     /** The strength attribute. Can be either UCOL_PRIMARY, UCOL_SECONDARY,
2827777dab0Sopenharmony_ci      * UCOL_TERTIARY, UCOL_QUATERNARY or UCOL_IDENTICAL. The usual strength
2837777dab0Sopenharmony_ci      * for most locales (except Japanese) is tertiary.
2847777dab0Sopenharmony_ci      *
2857777dab0Sopenharmony_ci      * Quaternary strength
2867777dab0Sopenharmony_ci      * is useful when combined with shifted setting for alternate handling
2877777dab0Sopenharmony_ci      * attribute and for JIS X 4061 collation, when it is used to distinguish
2887777dab0Sopenharmony_ci      * between Katakana and Hiragana.
2897777dab0Sopenharmony_ci      * Otherwise, quaternary level
2907777dab0Sopenharmony_ci      * is affected only by the number of non-ignorable code points in
2917777dab0Sopenharmony_ci      * the string.
2927777dab0Sopenharmony_ci      *
2937777dab0Sopenharmony_ci      * Identical strength is rarely useful, as it amounts
2947777dab0Sopenharmony_ci      * to codepoints of the NFD form of the string.
2957777dab0Sopenharmony_ci      * @stable ICU 2.0
2967777dab0Sopenharmony_ci      */
2977777dab0Sopenharmony_ci     UCOL_STRENGTH,
2987777dab0Sopenharmony_ci     /**
2997777dab0Sopenharmony_ci      * When turned on, this attribute makes
3007777dab0Sopenharmony_ci      * substrings of digits sort according to their numeric values.
3017777dab0Sopenharmony_ci      *
3027777dab0Sopenharmony_ci      * This is a way to get '100' to sort AFTER '2'. Note that the longest
3037777dab0Sopenharmony_ci      * digit substring that can be treated as a single unit is
3047777dab0Sopenharmony_ci      * 254 digits (not counting leading zeros). If a digit substring is
3057777dab0Sopenharmony_ci      * longer than that, the digits beyond the limit will be treated as a
3067777dab0Sopenharmony_ci      * separate digit substring.
3077777dab0Sopenharmony_ci      *
3087777dab0Sopenharmony_ci      * A "digit" in this sense is a code point with General_Category=Nd,
3097777dab0Sopenharmony_ci      * which does not include circled numbers, roman numerals, etc.
3107777dab0Sopenharmony_ci      * Only a contiguous digit substring is considered, that is,
3117777dab0Sopenharmony_ci      * non-negative integers without separators.
3127777dab0Sopenharmony_ci      * There is no support for plus/minus signs, decimals, exponents, etc.
3137777dab0Sopenharmony_ci      *
3147777dab0Sopenharmony_ci      * @stable ICU 2.8
3157777dab0Sopenharmony_ci      */
3167777dab0Sopenharmony_ci     UCOL_NUMERIC_COLLATION = UCOL_STRENGTH + 2
3177777dab0Sopenharmony_ci} UColAttribute;
3187777dab0Sopenharmony_ci
3197777dab0Sopenharmony_ci/** Options for retrieving the rule string
3207777dab0Sopenharmony_ci *  @stable ICU 2.0
3217777dab0Sopenharmony_ci */
3227777dab0Sopenharmony_citypedef enum {
3237777dab0Sopenharmony_ci  /**
3247777dab0Sopenharmony_ci   * Retrieves the tailoring rules only.
3257777dab0Sopenharmony_ci   * Same as calling the version of getRules() without UColRuleOption.
3267777dab0Sopenharmony_ci   * @stable ICU 2.0
3277777dab0Sopenharmony_ci   */
3287777dab0Sopenharmony_ci  UCOL_TAILORING_ONLY,
3297777dab0Sopenharmony_ci  /**
3307777dab0Sopenharmony_ci   * Retrieves the "UCA rules" concatenated with the tailoring rules.
3317777dab0Sopenharmony_ci   * The "UCA rules" are an <i>approximation</i> of the root collator's sort order.
3327777dab0Sopenharmony_ci   * They are almost never used or useful at runtime and can be removed from the data.
3337777dab0Sopenharmony_ci   * See https://unicode-org.github.io/icu/userguide/collation/customization#building-on-existing-locales
3347777dab0Sopenharmony_ci   * @stable ICU 2.0
3357777dab0Sopenharmony_ci   */
3367777dab0Sopenharmony_ci  UCOL_FULL_RULES
3377777dab0Sopenharmony_ci} UColRuleOption ;
3387777dab0Sopenharmony_ci
3397777dab0Sopenharmony_ci/**
3407777dab0Sopenharmony_ci * Open a UCollator for comparing strings.
3417777dab0Sopenharmony_ci *
3427777dab0Sopenharmony_ci * For some languages, multiple collation types are available;
3437777dab0Sopenharmony_ci * for example, "de@collation=phonebook".
3447777dab0Sopenharmony_ci * Starting with ICU 54, collation attributes can be specified via locale keywords as well,
3457777dab0Sopenharmony_ci * in the old locale extension syntax ("el@colCaseFirst=upper")
3467777dab0Sopenharmony_ci * or in language tag syntax ("el-u-kf-upper").
3477777dab0Sopenharmony_ci * See <a href="https://unicode-org.github.io/icu/userguide/collation/api">User Guide: Collation API</a>.
3487777dab0Sopenharmony_ci *
3497777dab0Sopenharmony_ci * The UCollator pointer is used in all the calls to the Collation
3507777dab0Sopenharmony_ci * service. After finished, collator must be disposed of by calling
3517777dab0Sopenharmony_ci * {@link #ucol_close }.
3527777dab0Sopenharmony_ci * @param loc The locale containing the required collation rules.
3537777dab0Sopenharmony_ci *            Special values for locales can be passed in -
3547777dab0Sopenharmony_ci *            if NULL is passed for the locale, the default locale
3557777dab0Sopenharmony_ci *            collation rules will be used. If empty string ("") or
3567777dab0Sopenharmony_ci *            "root" are passed, the root collator will be returned.
3577777dab0Sopenharmony_ci * @param status A pointer to a UErrorCode to receive any errors
3587777dab0Sopenharmony_ci * @return A pointer to a UCollator, or 0 if an error occurred.
3597777dab0Sopenharmony_ci * @see ucol_openRules
3607777dab0Sopenharmony_ci * @see ucol_clone
3617777dab0Sopenharmony_ci * @see ucol_close
3627777dab0Sopenharmony_ci * @stable ICU 2.0
3637777dab0Sopenharmony_ci */
3647777dab0Sopenharmony_ciU_CAPI UCollator* U_EXPORT2
3657777dab0Sopenharmony_ciucol_open(const char *loc, UErrorCode *status);
3667777dab0Sopenharmony_ci
3677777dab0Sopenharmony_ci/**
3687777dab0Sopenharmony_ci * Produce a UCollator instance according to the rules supplied.
3697777dab0Sopenharmony_ci * The rules are used to change the default ordering, defined in the
3707777dab0Sopenharmony_ci * UCA in a process called tailoring. The resulting UCollator pointer
3717777dab0Sopenharmony_ci * can be used in the same way as the one obtained by {@link #ucol_strcoll }.
3727777dab0Sopenharmony_ci * @param rules A string describing the collation rules. For the syntax
3737777dab0Sopenharmony_ci *              of the rules please see users guide.
3747777dab0Sopenharmony_ci * @param rulesLength The length of rules, or -1 if null-terminated.
3757777dab0Sopenharmony_ci * @param normalizationMode The normalization mode: One of
3767777dab0Sopenharmony_ci *             UCOL_OFF     (expect the text to not need normalization),
3777777dab0Sopenharmony_ci *             UCOL_ON      (normalize), or
3787777dab0Sopenharmony_ci *             UCOL_DEFAULT (set the mode according to the rules)
3797777dab0Sopenharmony_ci * @param strength The default collation strength; one of UCOL_PRIMARY, UCOL_SECONDARY,
3807777dab0Sopenharmony_ci * UCOL_TERTIARY, UCOL_IDENTICAL,UCOL_DEFAULT_STRENGTH - can be also set in the rules.
3817777dab0Sopenharmony_ci * @param parseError  A pointer to UParseError to receive information about errors
3827777dab0Sopenharmony_ci *                    occurred during parsing. This argument can currently be set
3837777dab0Sopenharmony_ci *                    to NULL, but at users own risk. Please provide a real structure.
3847777dab0Sopenharmony_ci * @param status A pointer to a UErrorCode to receive any errors
3857777dab0Sopenharmony_ci * @return A pointer to a UCollator. It is not guaranteed that NULL be returned in case
3867777dab0Sopenharmony_ci *         of error - please use status argument to check for errors.
3877777dab0Sopenharmony_ci * @see ucol_open
3887777dab0Sopenharmony_ci * @see ucol_clone
3897777dab0Sopenharmony_ci * @see ucol_close
3907777dab0Sopenharmony_ci * @stable ICU 2.0
3917777dab0Sopenharmony_ci */
3927777dab0Sopenharmony_ciU_CAPI UCollator* U_EXPORT2
3937777dab0Sopenharmony_ciucol_openRules( const UChar        *rules,
3947777dab0Sopenharmony_ci                int32_t            rulesLength,
3957777dab0Sopenharmony_ci                UColAttributeValue normalizationMode,
3967777dab0Sopenharmony_ci                UCollationStrength strength,
3977777dab0Sopenharmony_ci                UParseError        *parseError,
3987777dab0Sopenharmony_ci                UErrorCode         *status);
3997777dab0Sopenharmony_ci
4007777dab0Sopenharmony_ci/**
4017777dab0Sopenharmony_ci * Get a set containing the expansions defined by the collator. The set includes
4027777dab0Sopenharmony_ci * both the root collator's expansions and the expansions defined by the tailoring
4037777dab0Sopenharmony_ci * @param coll collator
4047777dab0Sopenharmony_ci * @param contractions if not NULL, the set to hold the contractions
4057777dab0Sopenharmony_ci * @param expansions if not NULL, the set to hold the expansions
4067777dab0Sopenharmony_ci * @param addPrefixes add the prefix contextual elements to contractions
4077777dab0Sopenharmony_ci * @param status to hold the error code
4087777dab0Sopenharmony_ci *
4097777dab0Sopenharmony_ci * @stable ICU 3.4
4107777dab0Sopenharmony_ci */
4117777dab0Sopenharmony_ciU_CAPI void U_EXPORT2
4127777dab0Sopenharmony_ciucol_getContractionsAndExpansions( const UCollator *coll,
4137777dab0Sopenharmony_ci                  USet *contractions, USet *expansions,
4147777dab0Sopenharmony_ci                  UBool addPrefixes, UErrorCode *status);
4157777dab0Sopenharmony_ci
4167777dab0Sopenharmony_ci/**
4177777dab0Sopenharmony_ci * Close a UCollator.
4187777dab0Sopenharmony_ci * Once closed, a UCollator should not be used. Every open collator should
4197777dab0Sopenharmony_ci * be closed. Otherwise, a memory leak will result.
4207777dab0Sopenharmony_ci * @param coll The UCollator to close.
4217777dab0Sopenharmony_ci * @see ucol_open
4227777dab0Sopenharmony_ci * @see ucol_openRules
4237777dab0Sopenharmony_ci * @see ucol_clone
4247777dab0Sopenharmony_ci * @stable ICU 2.0
4257777dab0Sopenharmony_ci */
4267777dab0Sopenharmony_ciU_CAPI void U_EXPORT2
4277777dab0Sopenharmony_ciucol_close(UCollator *coll);
4287777dab0Sopenharmony_ci
4297777dab0Sopenharmony_ci#if U_SHOW_CPLUSPLUS_API
4307777dab0Sopenharmony_ci
4317777dab0Sopenharmony_ciU_NAMESPACE_BEGIN
4327777dab0Sopenharmony_ci
4337777dab0Sopenharmony_ci/**
4347777dab0Sopenharmony_ci * \class LocalUCollatorPointer
4357777dab0Sopenharmony_ci * "Smart pointer" class, closes a UCollator via ucol_close().
4367777dab0Sopenharmony_ci * For most methods see the LocalPointerBase base class.
4377777dab0Sopenharmony_ci *
4387777dab0Sopenharmony_ci * @see LocalPointerBase
4397777dab0Sopenharmony_ci * @see LocalPointer
4407777dab0Sopenharmony_ci * @stable ICU 4.4
4417777dab0Sopenharmony_ci */
4427777dab0Sopenharmony_ciU_DEFINE_LOCAL_OPEN_POINTER(LocalUCollatorPointer, UCollator, ucol_close);
4437777dab0Sopenharmony_ci
4447777dab0Sopenharmony_ciU_NAMESPACE_END
4457777dab0Sopenharmony_ci
4467777dab0Sopenharmony_ci#endif
4477777dab0Sopenharmony_ci
4487777dab0Sopenharmony_ci/**
4497777dab0Sopenharmony_ci * Compare two strings.
4507777dab0Sopenharmony_ci * The strings will be compared using the options already specified.
4517777dab0Sopenharmony_ci * @param coll The UCollator containing the comparison rules.
4527777dab0Sopenharmony_ci * @param source The source string.
4537777dab0Sopenharmony_ci * @param sourceLength The length of source, or -1 if null-terminated.
4547777dab0Sopenharmony_ci * @param target The target string.
4557777dab0Sopenharmony_ci * @param targetLength The length of target, or -1 if null-terminated.
4567777dab0Sopenharmony_ci * @return The result of comparing the strings; one of UCOL_EQUAL,
4577777dab0Sopenharmony_ci * UCOL_GREATER, UCOL_LESS
4587777dab0Sopenharmony_ci * @see ucol_greater
4597777dab0Sopenharmony_ci * @see ucol_greaterOrEqual
4607777dab0Sopenharmony_ci * @see ucol_equal
4617777dab0Sopenharmony_ci * @stable ICU 2.0
4627777dab0Sopenharmony_ci */
4637777dab0Sopenharmony_ciU_CAPI UCollationResult U_EXPORT2
4647777dab0Sopenharmony_ciucol_strcoll(    const    UCollator    *coll,
4657777dab0Sopenharmony_ci        const    UChar        *source,
4667777dab0Sopenharmony_ci        int32_t            sourceLength,
4677777dab0Sopenharmony_ci        const    UChar        *target,
4687777dab0Sopenharmony_ci        int32_t            targetLength);
4697777dab0Sopenharmony_ci
4707777dab0Sopenharmony_ci/**
4717777dab0Sopenharmony_ci* Compare two strings in UTF-8.
4727777dab0Sopenharmony_ci* The strings will be compared using the options already specified.
4737777dab0Sopenharmony_ci* Note: When input string contains malformed a UTF-8 byte sequence,
4747777dab0Sopenharmony_ci* this function treats these bytes as REPLACEMENT CHARACTER (U+FFFD).
4757777dab0Sopenharmony_ci* @param coll The UCollator containing the comparison rules.
4767777dab0Sopenharmony_ci* @param source The source UTF-8 string.
4777777dab0Sopenharmony_ci* @param sourceLength The length of source, or -1 if null-terminated.
4787777dab0Sopenharmony_ci* @param target The target UTF-8 string.
4797777dab0Sopenharmony_ci* @param targetLength The length of target, or -1 if null-terminated.
4807777dab0Sopenharmony_ci* @param status A pointer to a UErrorCode to receive any errors
4817777dab0Sopenharmony_ci* @return The result of comparing the strings; one of UCOL_EQUAL,
4827777dab0Sopenharmony_ci* UCOL_GREATER, UCOL_LESS
4837777dab0Sopenharmony_ci* @see ucol_greater
4847777dab0Sopenharmony_ci* @see ucol_greaterOrEqual
4857777dab0Sopenharmony_ci* @see ucol_equal
4867777dab0Sopenharmony_ci* @stable ICU 50
4877777dab0Sopenharmony_ci*/
4887777dab0Sopenharmony_ciU_CAPI UCollationResult U_EXPORT2
4897777dab0Sopenharmony_ciucol_strcollUTF8(
4907777dab0Sopenharmony_ci        const UCollator *coll,
4917777dab0Sopenharmony_ci        const char      *source,
4927777dab0Sopenharmony_ci        int32_t         sourceLength,
4937777dab0Sopenharmony_ci        const char      *target,
4947777dab0Sopenharmony_ci        int32_t         targetLength,
4957777dab0Sopenharmony_ci        UErrorCode      *status);
4967777dab0Sopenharmony_ci
4977777dab0Sopenharmony_ci/**
4987777dab0Sopenharmony_ci * Determine if one string is greater than another.
4997777dab0Sopenharmony_ci * This function is equivalent to {@link #ucol_strcoll } == UCOL_GREATER
5007777dab0Sopenharmony_ci * @param coll The UCollator containing the comparison rules.
5017777dab0Sopenharmony_ci * @param source The source string.
5027777dab0Sopenharmony_ci * @param sourceLength The length of source, or -1 if null-terminated.
5037777dab0Sopenharmony_ci * @param target The target string.
5047777dab0Sopenharmony_ci * @param targetLength The length of target, or -1 if null-terminated.
5057777dab0Sopenharmony_ci * @return true if source is greater than target, false otherwise.
5067777dab0Sopenharmony_ci * @see ucol_strcoll
5077777dab0Sopenharmony_ci * @see ucol_greaterOrEqual
5087777dab0Sopenharmony_ci * @see ucol_equal
5097777dab0Sopenharmony_ci * @stable ICU 2.0
5107777dab0Sopenharmony_ci */
5117777dab0Sopenharmony_ciU_CAPI UBool U_EXPORT2
5127777dab0Sopenharmony_ciucol_greater(const UCollator *coll,
5137777dab0Sopenharmony_ci             const UChar     *source, int32_t sourceLength,
5147777dab0Sopenharmony_ci             const UChar     *target, int32_t targetLength);
5157777dab0Sopenharmony_ci
5167777dab0Sopenharmony_ci/**
5177777dab0Sopenharmony_ci * Determine if one string is greater than or equal to another.
5187777dab0Sopenharmony_ci * This function is equivalent to {@link #ucol_strcoll } != UCOL_LESS
5197777dab0Sopenharmony_ci * @param coll The UCollator containing the comparison rules.
5207777dab0Sopenharmony_ci * @param source The source string.
5217777dab0Sopenharmony_ci * @param sourceLength The length of source, or -1 if null-terminated.
5227777dab0Sopenharmony_ci * @param target The target string.
5237777dab0Sopenharmony_ci * @param targetLength The length of target, or -1 if null-terminated.
5247777dab0Sopenharmony_ci * @return true if source is greater than or equal to target, false otherwise.
5257777dab0Sopenharmony_ci * @see ucol_strcoll
5267777dab0Sopenharmony_ci * @see ucol_greater
5277777dab0Sopenharmony_ci * @see ucol_equal
5287777dab0Sopenharmony_ci * @stable ICU 2.0
5297777dab0Sopenharmony_ci */
5307777dab0Sopenharmony_ciU_CAPI UBool U_EXPORT2
5317777dab0Sopenharmony_ciucol_greaterOrEqual(const UCollator *coll,
5327777dab0Sopenharmony_ci                    const UChar     *source, int32_t sourceLength,
5337777dab0Sopenharmony_ci                    const UChar     *target, int32_t targetLength);
5347777dab0Sopenharmony_ci
5357777dab0Sopenharmony_ci/**
5367777dab0Sopenharmony_ci * Compare two strings for equality.
5377777dab0Sopenharmony_ci * This function is equivalent to {@link #ucol_strcoll } == UCOL_EQUAL
5387777dab0Sopenharmony_ci * @param coll The UCollator containing the comparison rules.
5397777dab0Sopenharmony_ci * @param source The source string.
5407777dab0Sopenharmony_ci * @param sourceLength The length of source, or -1 if null-terminated.
5417777dab0Sopenharmony_ci * @param target The target string.
5427777dab0Sopenharmony_ci * @param targetLength The length of target, or -1 if null-terminated.
5437777dab0Sopenharmony_ci * @return true if source is equal to target, false otherwise
5447777dab0Sopenharmony_ci * @see ucol_strcoll
5457777dab0Sopenharmony_ci * @see ucol_greater
5467777dab0Sopenharmony_ci * @see ucol_greaterOrEqual
5477777dab0Sopenharmony_ci * @stable ICU 2.0
5487777dab0Sopenharmony_ci */
5497777dab0Sopenharmony_ciU_CAPI UBool U_EXPORT2
5507777dab0Sopenharmony_ciucol_equal(const UCollator *coll,
5517777dab0Sopenharmony_ci           const UChar     *source, int32_t sourceLength,
5527777dab0Sopenharmony_ci           const UChar     *target, int32_t targetLength);
5537777dab0Sopenharmony_ci
5547777dab0Sopenharmony_ci
5557777dab0Sopenharmony_ci/**
5567777dab0Sopenharmony_ci * Get the collation strength used in a UCollator.
5577777dab0Sopenharmony_ci * The strength influences how strings are compared.
5587777dab0Sopenharmony_ci * @param coll The UCollator to query.
5597777dab0Sopenharmony_ci * @return The collation strength; one of UCOL_PRIMARY, UCOL_SECONDARY,
5607777dab0Sopenharmony_ci * UCOL_TERTIARY, UCOL_QUATERNARY, UCOL_IDENTICAL
5617777dab0Sopenharmony_ci * @see ucol_setStrength
5627777dab0Sopenharmony_ci * @stable ICU 2.0
5637777dab0Sopenharmony_ci */
5647777dab0Sopenharmony_ciU_CAPI UCollationStrength U_EXPORT2
5657777dab0Sopenharmony_ciucol_getStrength(const UCollator *coll);
5667777dab0Sopenharmony_ci
5677777dab0Sopenharmony_ci/**
5687777dab0Sopenharmony_ci * Set the collation strength used in a UCollator.
5697777dab0Sopenharmony_ci * The strength influences how strings are compared.
5707777dab0Sopenharmony_ci * @param coll The UCollator to set.
5717777dab0Sopenharmony_ci * @param strength The desired collation strength; one of UCOL_PRIMARY,
5727777dab0Sopenharmony_ci * UCOL_SECONDARY, UCOL_TERTIARY, UCOL_QUATERNARY, UCOL_IDENTICAL, UCOL_DEFAULT
5737777dab0Sopenharmony_ci * @see ucol_getStrength
5747777dab0Sopenharmony_ci * @stable ICU 2.0
5757777dab0Sopenharmony_ci */
5767777dab0Sopenharmony_ciU_CAPI void U_EXPORT2
5777777dab0Sopenharmony_ciucol_setStrength(UCollator *coll,
5787777dab0Sopenharmony_ci                 UCollationStrength strength);
5797777dab0Sopenharmony_ci
5807777dab0Sopenharmony_ci/**
5817777dab0Sopenharmony_ci * Retrieves the reordering codes for this collator.
5827777dab0Sopenharmony_ci * These reordering codes are a combination of UScript codes and UColReorderCode entries.
5837777dab0Sopenharmony_ci * @param coll The UCollator to query.
5847777dab0Sopenharmony_ci * @param dest The array to fill with the script ordering.
5857777dab0Sopenharmony_ci * @param destCapacity The length of dest. If it is 0, then dest may be NULL and the function
5867777dab0Sopenharmony_ci * will only return the length of the result without writing any codes (pre-flighting).
5877777dab0Sopenharmony_ci * @param pErrorCode Must be a valid pointer to an error code value, which must not indicate a
5887777dab0Sopenharmony_ci * failure before the function call.
5897777dab0Sopenharmony_ci * @return The number of reordering codes written to the dest array.
5907777dab0Sopenharmony_ci * @see ucol_setReorderCodes
5917777dab0Sopenharmony_ci * @see ucol_getEquivalentReorderCodes
5927777dab0Sopenharmony_ci * @see UScriptCode
5937777dab0Sopenharmony_ci * @see UColReorderCode
5947777dab0Sopenharmony_ci * @stable ICU 4.8
5957777dab0Sopenharmony_ci */
5967777dab0Sopenharmony_ciU_CAPI int32_t U_EXPORT2
5977777dab0Sopenharmony_ciucol_getReorderCodes(const UCollator* coll,
5987777dab0Sopenharmony_ci                    int32_t* dest,
5997777dab0Sopenharmony_ci                    int32_t destCapacity,
6007777dab0Sopenharmony_ci                    UErrorCode *pErrorCode);
6017777dab0Sopenharmony_ci/**
6027777dab0Sopenharmony_ci * Sets the reordering codes for this collator.
6037777dab0Sopenharmony_ci * Collation reordering allows scripts and some other groups of characters
6047777dab0Sopenharmony_ci * to be moved relative to each other. This reordering is done on top of
6057777dab0Sopenharmony_ci * the DUCET/CLDR standard collation order. Reordering can specify groups to be placed
6067777dab0Sopenharmony_ci * at the start and/or the end of the collation order. These groups are specified using
6077777dab0Sopenharmony_ci * UScript codes and UColReorderCode entries.
6087777dab0Sopenharmony_ci *
6097777dab0Sopenharmony_ci * <p>By default, reordering codes specified for the start of the order are placed in the
6107777dab0Sopenharmony_ci * order given after several special non-script blocks. These special groups of characters
6117777dab0Sopenharmony_ci * are space, punctuation, symbol, currency, and digit. These special groups are represented with
6127777dab0Sopenharmony_ci * UColReorderCode entries. Script groups can be intermingled with
6137777dab0Sopenharmony_ci * these special non-script groups if those special groups are explicitly specified in the reordering.
6147777dab0Sopenharmony_ci *
6157777dab0Sopenharmony_ci * <p>The special code OTHERS stands for any script that is not explicitly
6167777dab0Sopenharmony_ci * mentioned in the list of reordering codes given. Anything that is after OTHERS
6177777dab0Sopenharmony_ci * will go at the very end of the reordering in the order given.
6187777dab0Sopenharmony_ci *
6197777dab0Sopenharmony_ci * <p>The special reorder code DEFAULT will reset the reordering for this collator
6207777dab0Sopenharmony_ci * to the default for this collator. The default reordering may be the DUCET/CLDR order or may be a reordering that
6217777dab0Sopenharmony_ci * was specified when this collator was created from resource data or from rules. The
6227777dab0Sopenharmony_ci * DEFAULT code <b>must</b> be the sole code supplied when it is used.
6237777dab0Sopenharmony_ci * If not, then U_ILLEGAL_ARGUMENT_ERROR will be set.
6247777dab0Sopenharmony_ci *
6257777dab0Sopenharmony_ci * <p>The special reorder code NONE will remove any reordering for this collator.
6267777dab0Sopenharmony_ci * The result of setting no reordering will be to have the DUCET/CLDR ordering used. The
6277777dab0Sopenharmony_ci * NONE code <b>must</b> be the sole code supplied when it is used.
6287777dab0Sopenharmony_ci *
6297777dab0Sopenharmony_ci * @param coll The UCollator to set.
6307777dab0Sopenharmony_ci * @param reorderCodes An array of script codes in the new order. This can be NULL if the
6317777dab0Sopenharmony_ci * length is also set to 0. An empty array will clear any reordering codes on the collator.
6327777dab0Sopenharmony_ci * @param reorderCodesLength The length of reorderCodes.
6337777dab0Sopenharmony_ci * @param pErrorCode Must be a valid pointer to an error code value, which must not indicate a
6347777dab0Sopenharmony_ci * failure before the function call.
6357777dab0Sopenharmony_ci * @see ucol_getReorderCodes
6367777dab0Sopenharmony_ci * @see ucol_getEquivalentReorderCodes
6377777dab0Sopenharmony_ci * @see UScriptCode
6387777dab0Sopenharmony_ci * @see UColReorderCode
6397777dab0Sopenharmony_ci * @stable ICU 4.8
6407777dab0Sopenharmony_ci */
6417777dab0Sopenharmony_ciU_CAPI void U_EXPORT2
6427777dab0Sopenharmony_ciucol_setReorderCodes(UCollator* coll,
6437777dab0Sopenharmony_ci                    const int32_t* reorderCodes,
6447777dab0Sopenharmony_ci                    int32_t reorderCodesLength,
6457777dab0Sopenharmony_ci                    UErrorCode *pErrorCode);
6467777dab0Sopenharmony_ci
6477777dab0Sopenharmony_ci/**
6487777dab0Sopenharmony_ci * Retrieves the reorder codes that are grouped with the given reorder code. Some reorder
6497777dab0Sopenharmony_ci * codes will be grouped and must reorder together.
6507777dab0Sopenharmony_ci * Beginning with ICU 55, scripts only reorder together if they are primary-equal,
6517777dab0Sopenharmony_ci * for example Hiragana and Katakana.
6527777dab0Sopenharmony_ci *
6537777dab0Sopenharmony_ci * @param reorderCode The reorder code to determine equivalence for.
6547777dab0Sopenharmony_ci * @param dest The array to fill with the script ordering.
6557777dab0Sopenharmony_ci * @param destCapacity The length of dest. If it is 0, then dest may be NULL and the function
6567777dab0Sopenharmony_ci * will only return the length of the result without writing any codes (pre-flighting).
6577777dab0Sopenharmony_ci * @param pErrorCode Must be a valid pointer to an error code value, which must not indicate
6587777dab0Sopenharmony_ci * a failure before the function call.
6597777dab0Sopenharmony_ci * @return The number of reordering codes written to the dest array.
6607777dab0Sopenharmony_ci * @see ucol_setReorderCodes
6617777dab0Sopenharmony_ci * @see ucol_getReorderCodes
6627777dab0Sopenharmony_ci * @see UScriptCode
6637777dab0Sopenharmony_ci * @see UColReorderCode
6647777dab0Sopenharmony_ci * @stable ICU 4.8
6657777dab0Sopenharmony_ci */
6667777dab0Sopenharmony_ciU_CAPI int32_t U_EXPORT2
6677777dab0Sopenharmony_ciucol_getEquivalentReorderCodes(int32_t reorderCode,
6687777dab0Sopenharmony_ci                    int32_t* dest,
6697777dab0Sopenharmony_ci                    int32_t destCapacity,
6707777dab0Sopenharmony_ci                    UErrorCode *pErrorCode);
6717777dab0Sopenharmony_ci
6727777dab0Sopenharmony_ci/**
6737777dab0Sopenharmony_ci * Get the display name for a UCollator.
6747777dab0Sopenharmony_ci * The display name is suitable for presentation to a user.
6757777dab0Sopenharmony_ci * @param objLoc The locale of the collator in question.
6767777dab0Sopenharmony_ci * @param dispLoc The locale for display.
6777777dab0Sopenharmony_ci * @param result A pointer to a buffer to receive the attribute.
6787777dab0Sopenharmony_ci * @param resultLength The maximum size of result.
6797777dab0Sopenharmony_ci * @param status A pointer to a UErrorCode to receive any errors
6807777dab0Sopenharmony_ci * @return The total buffer size needed; if greater than resultLength,
6817777dab0Sopenharmony_ci * the output was truncated.
6827777dab0Sopenharmony_ci * @stable ICU 2.0
6837777dab0Sopenharmony_ci */
6847777dab0Sopenharmony_ciU_CAPI int32_t U_EXPORT2
6857777dab0Sopenharmony_ciucol_getDisplayName(    const    char        *objLoc,
6867777dab0Sopenharmony_ci            const    char        *dispLoc,
6877777dab0Sopenharmony_ci            UChar             *result,
6887777dab0Sopenharmony_ci            int32_t         resultLength,
6897777dab0Sopenharmony_ci            UErrorCode        *status);
6907777dab0Sopenharmony_ci
6917777dab0Sopenharmony_ci/**
6927777dab0Sopenharmony_ci * Get a locale for which collation rules are available.
6937777dab0Sopenharmony_ci * A UCollator in a locale returned by this function will perform the correct
6947777dab0Sopenharmony_ci * collation for the locale.
6957777dab0Sopenharmony_ci * @param localeIndex The index of the desired locale.
6967777dab0Sopenharmony_ci * @return A locale for which collation rules are available, or 0 if none.
6977777dab0Sopenharmony_ci * @see ucol_countAvailable
6987777dab0Sopenharmony_ci * @stable ICU 2.0
6997777dab0Sopenharmony_ci */
7007777dab0Sopenharmony_ciU_CAPI const char* U_EXPORT2
7017777dab0Sopenharmony_ciucol_getAvailable(int32_t localeIndex);
7027777dab0Sopenharmony_ci
7037777dab0Sopenharmony_ci/**
7047777dab0Sopenharmony_ci * Determine how many locales have collation rules available.
7057777dab0Sopenharmony_ci * This function is most useful as determining the loop ending condition for
7067777dab0Sopenharmony_ci * calls to {@link #ucol_getAvailable }.
7077777dab0Sopenharmony_ci * @return The number of locales for which collation rules are available.
7087777dab0Sopenharmony_ci * @see ucol_getAvailable
7097777dab0Sopenharmony_ci * @stable ICU 2.0
7107777dab0Sopenharmony_ci */
7117777dab0Sopenharmony_ciU_CAPI int32_t U_EXPORT2
7127777dab0Sopenharmony_ciucol_countAvailable(void);
7137777dab0Sopenharmony_ci
7147777dab0Sopenharmony_ci#if !UCONFIG_NO_SERVICE
7157777dab0Sopenharmony_ci/**
7167777dab0Sopenharmony_ci * Create a string enumerator of all locales for which a valid
7177777dab0Sopenharmony_ci * collator may be opened.
7187777dab0Sopenharmony_ci * @param status input-output error code
7197777dab0Sopenharmony_ci * @return a string enumeration over locale strings. The caller is
7207777dab0Sopenharmony_ci * responsible for closing the result.
7217777dab0Sopenharmony_ci * @stable ICU 3.0
7227777dab0Sopenharmony_ci */
7237777dab0Sopenharmony_ciU_CAPI UEnumeration* U_EXPORT2
7247777dab0Sopenharmony_ciucol_openAvailableLocales(UErrorCode *status);
7257777dab0Sopenharmony_ci#endif
7267777dab0Sopenharmony_ci
7277777dab0Sopenharmony_ci/**
7287777dab0Sopenharmony_ci * Create a string enumerator of all possible keywords that are relevant to
7297777dab0Sopenharmony_ci * collation. At this point, the only recognized keyword for this
7307777dab0Sopenharmony_ci * service is "collation".
7317777dab0Sopenharmony_ci * @param status input-output error code
7327777dab0Sopenharmony_ci * @return a string enumeration over locale strings. The caller is
7337777dab0Sopenharmony_ci * responsible for closing the result.
7347777dab0Sopenharmony_ci * @stable ICU 3.0
7357777dab0Sopenharmony_ci */
7367777dab0Sopenharmony_ciU_CAPI UEnumeration* U_EXPORT2
7377777dab0Sopenharmony_ciucol_getKeywords(UErrorCode *status);
7387777dab0Sopenharmony_ci
7397777dab0Sopenharmony_ci/**
7407777dab0Sopenharmony_ci * Given a keyword, create a string enumeration of all values
7417777dab0Sopenharmony_ci * for that keyword that are currently in use.
7427777dab0Sopenharmony_ci * @param keyword a particular keyword as enumerated by
7437777dab0Sopenharmony_ci * ucol_getKeywords. If any other keyword is passed in, *status is set
7447777dab0Sopenharmony_ci * to U_ILLEGAL_ARGUMENT_ERROR.
7457777dab0Sopenharmony_ci * @param status input-output error code
7467777dab0Sopenharmony_ci * @return a string enumeration over collation keyword values, or NULL
7477777dab0Sopenharmony_ci * upon error. The caller is responsible for closing the result.
7487777dab0Sopenharmony_ci * @stable ICU 3.0
7497777dab0Sopenharmony_ci */
7507777dab0Sopenharmony_ciU_CAPI UEnumeration* U_EXPORT2
7517777dab0Sopenharmony_ciucol_getKeywordValues(const char *keyword, UErrorCode *status);
7527777dab0Sopenharmony_ci
7537777dab0Sopenharmony_ci/**
7547777dab0Sopenharmony_ci * Given a key and a locale, returns an array of string values in a preferred
7557777dab0Sopenharmony_ci * order that would make a difference. These are all and only those values where
7567777dab0Sopenharmony_ci * the open (creation) of the service with the locale formed from the input locale
7577777dab0Sopenharmony_ci * plus input keyword and that value has different behavior than creation with the
7587777dab0Sopenharmony_ci * input locale alone.
7597777dab0Sopenharmony_ci * @param key           one of the keys supported by this service.  For now, only
7607777dab0Sopenharmony_ci *                      "collation" is supported.
7617777dab0Sopenharmony_ci * @param locale        the locale
7627777dab0Sopenharmony_ci * @param commonlyUsed  if set to true it will return only commonly used values
7637777dab0Sopenharmony_ci *                      with the given locale in preferred order.  Otherwise,
7647777dab0Sopenharmony_ci *                      it will return all the available values for the locale.
7657777dab0Sopenharmony_ci * @param status error status
7667777dab0Sopenharmony_ci * @return a string enumeration over keyword values for the given key and the locale.
7677777dab0Sopenharmony_ci * @stable ICU 4.2
7687777dab0Sopenharmony_ci */
7697777dab0Sopenharmony_ciU_CAPI UEnumeration* U_EXPORT2
7707777dab0Sopenharmony_ciucol_getKeywordValuesForLocale(const char* key,
7717777dab0Sopenharmony_ci                               const char* locale,
7727777dab0Sopenharmony_ci                               UBool commonlyUsed,
7737777dab0Sopenharmony_ci                               UErrorCode* status);
7747777dab0Sopenharmony_ci
7757777dab0Sopenharmony_ci/**
7767777dab0Sopenharmony_ci * Return the functionally equivalent locale for the specified
7777777dab0Sopenharmony_ci * input locale, with respect to given keyword, for the
7787777dab0Sopenharmony_ci * collation service. If two different input locale + keyword
7797777dab0Sopenharmony_ci * combinations produce the same result locale, then collators
7807777dab0Sopenharmony_ci * instantiated for these two different input locales will behave
7817777dab0Sopenharmony_ci * equivalently. The converse is not always true; two collators
7827777dab0Sopenharmony_ci * may in fact be equivalent, but return different results, due to
7837777dab0Sopenharmony_ci * internal details. The return result has no other meaning than
7847777dab0Sopenharmony_ci * that stated above, and implies nothing as to the relationship
7857777dab0Sopenharmony_ci * between the two locales. This is intended for use by
7867777dab0Sopenharmony_ci * applications who wish to cache collators, or otherwise reuse
7877777dab0Sopenharmony_ci * collators when possible. The functional equivalent may change
7887777dab0Sopenharmony_ci * over time. For more information, please see the <a
7897777dab0Sopenharmony_ci * href="https://unicode-org.github.io/icu/userguide/locale#locales-and-services">
7907777dab0Sopenharmony_ci * Locales and Services</a> section of the ICU User Guide.
7917777dab0Sopenharmony_ci * @param result fillin for the functionally equivalent result locale
7927777dab0Sopenharmony_ci * @param resultCapacity capacity of the fillin buffer
7937777dab0Sopenharmony_ci * @param keyword a particular keyword as enumerated by
7947777dab0Sopenharmony_ci * ucol_getKeywords.
7957777dab0Sopenharmony_ci * @param locale the specified input locale
7967777dab0Sopenharmony_ci * @param isAvailable if non-NULL, pointer to a fillin parameter that
7977777dab0Sopenharmony_ci * on return indicates whether the specified input locale was 'available'
7987777dab0Sopenharmony_ci * to the collation service. A locale is defined as 'available' if it
7997777dab0Sopenharmony_ci * physically exists within the collation locale data.
8007777dab0Sopenharmony_ci * @param status pointer to input-output error code
8017777dab0Sopenharmony_ci * @return the actual buffer size needed for the locale. If greater
8027777dab0Sopenharmony_ci * than resultCapacity, the returned full name will be truncated and
8037777dab0Sopenharmony_ci * an error code will be returned.
8047777dab0Sopenharmony_ci * @stable ICU 3.0
8057777dab0Sopenharmony_ci */
8067777dab0Sopenharmony_ciU_CAPI int32_t U_EXPORT2
8077777dab0Sopenharmony_ciucol_getFunctionalEquivalent(char* result, int32_t resultCapacity,
8087777dab0Sopenharmony_ci                             const char* keyword, const char* locale,
8097777dab0Sopenharmony_ci                             UBool* isAvailable, UErrorCode* status);
8107777dab0Sopenharmony_ci
8117777dab0Sopenharmony_ci/**
8127777dab0Sopenharmony_ci * Get the collation tailoring rules from a UCollator.
8137777dab0Sopenharmony_ci * The rules will follow the rule syntax.
8147777dab0Sopenharmony_ci * @param coll The UCollator to query.
8157777dab0Sopenharmony_ci * @param length
8167777dab0Sopenharmony_ci * @return The collation tailoring rules.
8177777dab0Sopenharmony_ci * @stable ICU 2.0
8187777dab0Sopenharmony_ci */
8197777dab0Sopenharmony_ciU_CAPI const UChar* U_EXPORT2
8207777dab0Sopenharmony_ciucol_getRules(    const    UCollator    *coll,
8217777dab0Sopenharmony_ci        int32_t            *length);
8227777dab0Sopenharmony_ci
8237777dab0Sopenharmony_ci/**
8247777dab0Sopenharmony_ci * Get a sort key for a string from a UCollator.
8257777dab0Sopenharmony_ci * Sort keys may be compared using <TT>strcmp</TT>.
8267777dab0Sopenharmony_ci *
8277777dab0Sopenharmony_ci * Note that sort keys are often less efficient than simply doing comparison.
8287777dab0Sopenharmony_ci * For more details, see the ICU User Guide.
8297777dab0Sopenharmony_ci *
8307777dab0Sopenharmony_ci * Like ICU functions that write to an output buffer, the buffer contents
8317777dab0Sopenharmony_ci * is undefined if the buffer capacity (resultLength parameter) is too small.
8327777dab0Sopenharmony_ci * Unlike ICU functions that write a string to an output buffer,
8337777dab0Sopenharmony_ci * the terminating zero byte is counted in the sort key length.
8347777dab0Sopenharmony_ci * @param coll The UCollator containing the collation rules.
8357777dab0Sopenharmony_ci * @param source The string to transform.
8367777dab0Sopenharmony_ci * @param sourceLength The length of source, or -1 if null-terminated.
8377777dab0Sopenharmony_ci * @param result A pointer to a buffer to receive the attribute.
8387777dab0Sopenharmony_ci * @param resultLength The maximum size of result.
8397777dab0Sopenharmony_ci * @return The size needed to fully store the sort key.
8407777dab0Sopenharmony_ci *      If there was an internal error generating the sort key,
8417777dab0Sopenharmony_ci *      a zero value is returned.
8427777dab0Sopenharmony_ci * @see ucol_keyHashCode
8437777dab0Sopenharmony_ci * @stable ICU 2.0
8447777dab0Sopenharmony_ci */
8457777dab0Sopenharmony_ciU_CAPI int32_t U_EXPORT2
8467777dab0Sopenharmony_ciucol_getSortKey(const    UCollator    *coll,
8477777dab0Sopenharmony_ci        const    UChar        *source,
8487777dab0Sopenharmony_ci        int32_t        sourceLength,
8497777dab0Sopenharmony_ci        uint8_t        *result,
8507777dab0Sopenharmony_ci        int32_t        resultLength);
8517777dab0Sopenharmony_ci
8527777dab0Sopenharmony_ci/** enum that is taken by ucol_getBound API
8537777dab0Sopenharmony_ci * See below for explanation
8547777dab0Sopenharmony_ci * do not change the values assigned to the
8557777dab0Sopenharmony_ci * members of this enum. Underlying code
8567777dab0Sopenharmony_ci * depends on them having these numbers
8577777dab0Sopenharmony_ci * @stable ICU 2.0
8587777dab0Sopenharmony_ci */
8597777dab0Sopenharmony_citypedef enum {
8607777dab0Sopenharmony_ci  /** lower bound */
8617777dab0Sopenharmony_ci  UCOL_BOUND_LOWER = 0,
8627777dab0Sopenharmony_ci  /** upper bound that will match strings of exact size */
8637777dab0Sopenharmony_ci  UCOL_BOUND_UPPER = 1,
8647777dab0Sopenharmony_ci  /** upper bound that will match all the strings that have the same initial substring as the given string */
8657777dab0Sopenharmony_ci  UCOL_BOUND_UPPER_LONG = 2
8667777dab0Sopenharmony_ci} UColBoundMode;
8677777dab0Sopenharmony_ci
8687777dab0Sopenharmony_ci/**
8697777dab0Sopenharmony_ci * Produce a bound for a given sortkey and a number of levels.
8707777dab0Sopenharmony_ci * Return value is always the number of bytes needed, regardless of
8717777dab0Sopenharmony_ci * whether the result buffer was big enough or even valid.<br>
8727777dab0Sopenharmony_ci * Resulting bounds can be used to produce a range of strings that are
8737777dab0Sopenharmony_ci * between upper and lower bounds. For example, if bounds are produced
8747777dab0Sopenharmony_ci * for a sortkey of string "smith", strings between upper and lower
8757777dab0Sopenharmony_ci * bounds with one level would include "Smith", "SMITH", "sMiTh".<br>
8767777dab0Sopenharmony_ci * There are two upper bounds that can be produced. If UCOL_BOUND_UPPER
8777777dab0Sopenharmony_ci * is produced, strings matched would be as above. However, if bound
8787777dab0Sopenharmony_ci * produced using UCOL_BOUND_UPPER_LONG is used, the above example will
8797777dab0Sopenharmony_ci * also match "Smithsonian" and similar.<br>
8807777dab0Sopenharmony_ci * For more on usage, see example in cintltst/capitst.c in procedure
8817777dab0Sopenharmony_ci * TestBounds.
8827777dab0Sopenharmony_ci * Sort keys may be compared using <TT>strcmp</TT>.
8837777dab0Sopenharmony_ci * @param source The source sortkey.
8847777dab0Sopenharmony_ci * @param sourceLength The length of source, or -1 if null-terminated.
8857777dab0Sopenharmony_ci *                     (If an unmodified sortkey is passed, it is always null
8867777dab0Sopenharmony_ci *                      terminated).
8877777dab0Sopenharmony_ci * @param boundType Type of bound required. It can be UCOL_BOUND_LOWER, which
8887777dab0Sopenharmony_ci *                  produces a lower inclusive bound, UCOL_BOUND_UPPER, that
8897777dab0Sopenharmony_ci *                  produces upper bound that matches strings of the same length
8907777dab0Sopenharmony_ci *                  or UCOL_BOUND_UPPER_LONG that matches strings that have the
8917777dab0Sopenharmony_ci *                  same starting substring as the source string.
8927777dab0Sopenharmony_ci * @param noOfLevels  Number of levels required in the resulting bound (for most
8937777dab0Sopenharmony_ci *                    uses, the recommended value is 1). See users guide for
8947777dab0Sopenharmony_ci *                    explanation on number of levels a sortkey can have.
8957777dab0Sopenharmony_ci * @param result A pointer to a buffer to receive the resulting sortkey.
8967777dab0Sopenharmony_ci * @param resultLength The maximum size of result.
8977777dab0Sopenharmony_ci * @param status Used for returning error code if something went wrong. If the
8987777dab0Sopenharmony_ci *               number of levels requested is higher than the number of levels
8997777dab0Sopenharmony_ci *               in the source key, a warning (U_SORT_KEY_TOO_SHORT_WARNING) is
9007777dab0Sopenharmony_ci *               issued.
9017777dab0Sopenharmony_ci * @return The size needed to fully store the bound.
9027777dab0Sopenharmony_ci * @see ucol_keyHashCode
9037777dab0Sopenharmony_ci * @stable ICU 2.1
9047777dab0Sopenharmony_ci */
9057777dab0Sopenharmony_ciU_CAPI int32_t U_EXPORT2
9067777dab0Sopenharmony_ciucol_getBound(const uint8_t       *source,
9077777dab0Sopenharmony_ci        int32_t             sourceLength,
9087777dab0Sopenharmony_ci        UColBoundMode       boundType,
9097777dab0Sopenharmony_ci        uint32_t            noOfLevels,
9107777dab0Sopenharmony_ci        uint8_t             *result,
9117777dab0Sopenharmony_ci        int32_t             resultLength,
9127777dab0Sopenharmony_ci        UErrorCode          *status);
9137777dab0Sopenharmony_ci
9147777dab0Sopenharmony_ci
9157777dab0Sopenharmony_ci/**
9167777dab0Sopenharmony_ci * Merges two sort keys. The levels are merged with their corresponding counterparts
9177777dab0Sopenharmony_ci * (primaries with primaries, secondaries with secondaries etc.). Between the values
9187777dab0Sopenharmony_ci * from the same level a separator is inserted.
9197777dab0Sopenharmony_ci *
9207777dab0Sopenharmony_ci * This is useful, for example, for combining sort keys from first and last names
9217777dab0Sopenharmony_ci * to sort such pairs.
9227777dab0Sopenharmony_ci * See http://www.unicode.org/reports/tr10/#Merging_Sort_Keys
9237777dab0Sopenharmony_ci *
9247777dab0Sopenharmony_ci * The recommended way to achieve "merged" sorting is by
9257777dab0Sopenharmony_ci * concatenating strings with U+FFFE between them.
9267777dab0Sopenharmony_ci * The concatenation has the same sort order as the merged sort keys,
9277777dab0Sopenharmony_ci * but merge(getSortKey(str1), getSortKey(str2)) may differ from getSortKey(str1 + '\\uFFFE' + str2).
9287777dab0Sopenharmony_ci * Using strings with U+FFFE may yield shorter sort keys.
9297777dab0Sopenharmony_ci *
9307777dab0Sopenharmony_ci * For details about Sort Key Features see
9317777dab0Sopenharmony_ci * https://unicode-org.github.io/icu/userguide/collation/api#sort-key-features
9327777dab0Sopenharmony_ci *
9337777dab0Sopenharmony_ci * It is possible to merge multiple sort keys by consecutively merging
9347777dab0Sopenharmony_ci * another one with the intermediate result.
9357777dab0Sopenharmony_ci *
9367777dab0Sopenharmony_ci * The length of the merge result is the sum of the lengths of the input sort keys.
9377777dab0Sopenharmony_ci *
9387777dab0Sopenharmony_ci * Example (uncompressed):
9397777dab0Sopenharmony_ci * <pre>191B1D 01 050505 01 910505 00
9407777dab0Sopenharmony_ci * 1F2123 01 050505 01 910505 00</pre>
9417777dab0Sopenharmony_ci * will be merged as
9427777dab0Sopenharmony_ci * <pre>191B1D 02 1F2123 01 050505 02 050505 01 910505 02 910505 00</pre>
9437777dab0Sopenharmony_ci *
9447777dab0Sopenharmony_ci * If the destination buffer is not big enough, then its contents are undefined.
9457777dab0Sopenharmony_ci * If any of source lengths are zero or any of the source pointers are NULL/undefined,
9467777dab0Sopenharmony_ci * the result is of size zero.
9477777dab0Sopenharmony_ci *
9487777dab0Sopenharmony_ci * @param src1 the first sort key
9497777dab0Sopenharmony_ci * @param src1Length the length of the first sort key, including the zero byte at the end;
9507777dab0Sopenharmony_ci *        can be -1 if the function is to find the length
9517777dab0Sopenharmony_ci * @param src2 the second sort key
9527777dab0Sopenharmony_ci * @param src2Length the length of the second sort key, including the zero byte at the end;
9537777dab0Sopenharmony_ci *        can be -1 if the function is to find the length
9547777dab0Sopenharmony_ci * @param dest the buffer where the merged sort key is written,
9557777dab0Sopenharmony_ci *        can be NULL if destCapacity==0
9567777dab0Sopenharmony_ci * @param destCapacity the number of bytes in the dest buffer
9577777dab0Sopenharmony_ci * @return the length of the merged sort key, src1Length+src2Length;
9587777dab0Sopenharmony_ci *         can be larger than destCapacity, or 0 if an error occurs (only for illegal arguments),
9597777dab0Sopenharmony_ci *         in which cases the contents of dest is undefined
9607777dab0Sopenharmony_ci * @stable ICU 2.0
9617777dab0Sopenharmony_ci */
9627777dab0Sopenharmony_ciU_CAPI int32_t U_EXPORT2
9637777dab0Sopenharmony_ciucol_mergeSortkeys(const uint8_t *src1, int32_t src1Length,
9647777dab0Sopenharmony_ci                   const uint8_t *src2, int32_t src2Length,
9657777dab0Sopenharmony_ci                   uint8_t *dest, int32_t destCapacity);
9667777dab0Sopenharmony_ci
9677777dab0Sopenharmony_ci/**
9687777dab0Sopenharmony_ci * Universal attribute setter
9697777dab0Sopenharmony_ci * @param coll collator which attributes are to be changed
9707777dab0Sopenharmony_ci * @param attr attribute type
9717777dab0Sopenharmony_ci * @param value attribute value
9727777dab0Sopenharmony_ci * @param status to indicate whether the operation went on smoothly or there were errors
9737777dab0Sopenharmony_ci * @see UColAttribute
9747777dab0Sopenharmony_ci * @see UColAttributeValue
9757777dab0Sopenharmony_ci * @see ucol_getAttribute
9767777dab0Sopenharmony_ci * @stable ICU 2.0
9777777dab0Sopenharmony_ci */
9787777dab0Sopenharmony_ciU_CAPI void U_EXPORT2
9797777dab0Sopenharmony_ciucol_setAttribute(UCollator *coll, UColAttribute attr, UColAttributeValue value, UErrorCode *status);
9807777dab0Sopenharmony_ci
9817777dab0Sopenharmony_ci/**
9827777dab0Sopenharmony_ci * Universal attribute getter
9837777dab0Sopenharmony_ci * @param coll collator which attributes are to be changed
9847777dab0Sopenharmony_ci * @param attr attribute type
9857777dab0Sopenharmony_ci * @return attribute value
9867777dab0Sopenharmony_ci * @param status to indicate whether the operation went on smoothly or there were errors
9877777dab0Sopenharmony_ci * @see UColAttribute
9887777dab0Sopenharmony_ci * @see UColAttributeValue
9897777dab0Sopenharmony_ci * @see ucol_setAttribute
9907777dab0Sopenharmony_ci * @stable ICU 2.0
9917777dab0Sopenharmony_ci */
9927777dab0Sopenharmony_ciU_CAPI UColAttributeValue  U_EXPORT2
9937777dab0Sopenharmony_ciucol_getAttribute(const UCollator *coll, UColAttribute attr, UErrorCode *status);
9947777dab0Sopenharmony_ci
9957777dab0Sopenharmony_ci/**
9967777dab0Sopenharmony_ci * Sets the variable top to the top of the specified reordering group.
9977777dab0Sopenharmony_ci * The variable top determines the highest-sorting character
9987777dab0Sopenharmony_ci * which is affected by UCOL_ALTERNATE_HANDLING.
9997777dab0Sopenharmony_ci * If that attribute is set to UCOL_NON_IGNORABLE, then the variable top has no effect.
10007777dab0Sopenharmony_ci * @param coll the collator
10017777dab0Sopenharmony_ci * @param group one of UCOL_REORDER_CODE_SPACE, UCOL_REORDER_CODE_PUNCTUATION,
10027777dab0Sopenharmony_ci *              UCOL_REORDER_CODE_SYMBOL, UCOL_REORDER_CODE_CURRENCY;
10037777dab0Sopenharmony_ci *              or UCOL_REORDER_CODE_DEFAULT to restore the default max variable group
10047777dab0Sopenharmony_ci * @param pErrorCode Standard ICU error code. Its input value must
10057777dab0Sopenharmony_ci *                   pass the U_SUCCESS() test, or else the function returns
10067777dab0Sopenharmony_ci *                   immediately. Check for U_FAILURE() on output or use with
10077777dab0Sopenharmony_ci *                   function chaining. (See User Guide for details.)
10087777dab0Sopenharmony_ci * @see ucol_getMaxVariable
10097777dab0Sopenharmony_ci * @stable ICU 53
10107777dab0Sopenharmony_ci */
10117777dab0Sopenharmony_ciU_CAPI void U_EXPORT2
10127777dab0Sopenharmony_ciucol_setMaxVariable(UCollator *coll, UColReorderCode group, UErrorCode *pErrorCode);
10137777dab0Sopenharmony_ci
10147777dab0Sopenharmony_ci/**
10157777dab0Sopenharmony_ci * Returns the maximum reordering group whose characters are affected by UCOL_ALTERNATE_HANDLING.
10167777dab0Sopenharmony_ci * @param coll the collator
10177777dab0Sopenharmony_ci * @return the maximum variable reordering group.
10187777dab0Sopenharmony_ci * @see ucol_setMaxVariable
10197777dab0Sopenharmony_ci * @stable ICU 53
10207777dab0Sopenharmony_ci */
10217777dab0Sopenharmony_ciU_CAPI UColReorderCode U_EXPORT2
10227777dab0Sopenharmony_ciucol_getMaxVariable(const UCollator *coll);
10237777dab0Sopenharmony_ci
10247777dab0Sopenharmony_ci/**
10257777dab0Sopenharmony_ci * Gets the variable top value of a Collator.
10267777dab0Sopenharmony_ci * @param coll collator which variable top needs to be retrieved
10277777dab0Sopenharmony_ci * @param status error code (not changed by function). If error code is set,
10287777dab0Sopenharmony_ci *               the return value is undefined.
10297777dab0Sopenharmony_ci * @return the variable top primary weight
10307777dab0Sopenharmony_ci * @see ucol_getMaxVariable
10317777dab0Sopenharmony_ci * @see ucol_setVariableTop
10327777dab0Sopenharmony_ci * @see ucol_restoreVariableTop
10337777dab0Sopenharmony_ci * @stable ICU 2.0
10347777dab0Sopenharmony_ci */
10357777dab0Sopenharmony_ciU_CAPI uint32_t U_EXPORT2 ucol_getVariableTop(const UCollator *coll, UErrorCode *status);
10367777dab0Sopenharmony_ci
10377777dab0Sopenharmony_ci/**
10387777dab0Sopenharmony_ci * Thread safe cloning operation. The result is a clone of a given collator.
10397777dab0Sopenharmony_ci * @param coll collator to be cloned
10407777dab0Sopenharmony_ci * @param status to indicate whether the operation went on smoothly or there were errors
10417777dab0Sopenharmony_ci * @return pointer to the new clone
10427777dab0Sopenharmony_ci * @see ucol_open
10437777dab0Sopenharmony_ci * @see ucol_openRules
10447777dab0Sopenharmony_ci * @see ucol_close
10457777dab0Sopenharmony_ci * @stable ICU 71
10467777dab0Sopenharmony_ci */
10477777dab0Sopenharmony_ciU_CAPI UCollator* U_EXPORT2 ucol_clone(const UCollator *coll, UErrorCode *status);
10487777dab0Sopenharmony_ci
10497777dab0Sopenharmony_ci/**
10507777dab0Sopenharmony_ci * Returns current rules. Delta defines whether full rules are returned or just the tailoring.
10517777dab0Sopenharmony_ci * Returns number of UChars needed to store rules. If buffer is NULL or bufferLen is not enough
10527777dab0Sopenharmony_ci * to store rules, will store up to available space.
10537777dab0Sopenharmony_ci *
10547777dab0Sopenharmony_ci * ucol_getRules() should normally be used instead.
10557777dab0Sopenharmony_ci * See https://unicode-org.github.io/icu/userguide/collation/customization#building-on-existing-locales
10567777dab0Sopenharmony_ci * @param coll collator to get the rules from
10577777dab0Sopenharmony_ci * @param delta one of UCOL_TAILORING_ONLY, UCOL_FULL_RULES.
10587777dab0Sopenharmony_ci * @param buffer buffer to store the result in. If NULL, you'll get no rules.
10597777dab0Sopenharmony_ci * @param bufferLen length of buffer to store rules in. If less than needed you'll get only the part that fits in.
10607777dab0Sopenharmony_ci * @return current rules
10617777dab0Sopenharmony_ci * @stable ICU 2.0
10627777dab0Sopenharmony_ci * @see UCOL_FULL_RULES
10637777dab0Sopenharmony_ci */
10647777dab0Sopenharmony_ciU_CAPI int32_t U_EXPORT2
10657777dab0Sopenharmony_ciucol_getRulesEx(const UCollator *coll, UColRuleOption delta, UChar *buffer, int32_t bufferLen);
10667777dab0Sopenharmony_ci
10677777dab0Sopenharmony_ci/**
10687777dab0Sopenharmony_ci * gets the locale name of the collator. If the collator
10697777dab0Sopenharmony_ci * is instantiated from the rules, then this function returns
10707777dab0Sopenharmony_ci * NULL.
10717777dab0Sopenharmony_ci * @param coll The UCollator for which the locale is needed
10727777dab0Sopenharmony_ci * @param type You can choose between requested, valid and actual
10737777dab0Sopenharmony_ci *             locale. For description see the definition of
10747777dab0Sopenharmony_ci *             ULocDataLocaleType in uloc.h
10757777dab0Sopenharmony_ci * @param status error code of the operation
10767777dab0Sopenharmony_ci * @return real locale name from which the collation data comes.
10777777dab0Sopenharmony_ci *         If the collator was instantiated from rules, returns
10787777dab0Sopenharmony_ci *         NULL.
10797777dab0Sopenharmony_ci * @stable ICU 2.8
10807777dab0Sopenharmony_ci */
10817777dab0Sopenharmony_ciU_CAPI const char * U_EXPORT2
10827777dab0Sopenharmony_ciucol_getLocaleByType(const UCollator *coll, ULocDataLocaleType type, UErrorCode *status);
10837777dab0Sopenharmony_ci
10847777dab0Sopenharmony_ci/**
10857777dab0Sopenharmony_ci * Get a Unicode set that contains all the characters and sequences tailored in
10867777dab0Sopenharmony_ci * this collator. The result must be disposed of by using uset_close.
10877777dab0Sopenharmony_ci * @param coll        The UCollator for which we want to get tailored chars
10887777dab0Sopenharmony_ci * @param status      error code of the operation
10897777dab0Sopenharmony_ci * @return a pointer to newly created USet. Must be be disposed by using uset_close
10907777dab0Sopenharmony_ci * @see ucol_openRules
10917777dab0Sopenharmony_ci * @see uset_close
10927777dab0Sopenharmony_ci * @stable ICU 2.4
10937777dab0Sopenharmony_ci */
10947777dab0Sopenharmony_ciU_CAPI USet * U_EXPORT2
10957777dab0Sopenharmony_ciucol_getTailoredSet(const UCollator *coll, UErrorCode *status);
10967777dab0Sopenharmony_ci
10977777dab0Sopenharmony_ci/** Creates a binary image of a collator. This binary image can be stored and
10987777dab0Sopenharmony_ci *  later used to instantiate a collator using ucol_openBinary.
10997777dab0Sopenharmony_ci *  This API supports preflighting.
11007777dab0Sopenharmony_ci *  @param coll Collator
11017777dab0Sopenharmony_ci *  @param buffer a fill-in buffer to receive the binary image
11027777dab0Sopenharmony_ci *  @param capacity capacity of the destination buffer
11037777dab0Sopenharmony_ci *  @param status for catching errors
11047777dab0Sopenharmony_ci *  @return size of the image
11057777dab0Sopenharmony_ci *  @see ucol_openBinary
11067777dab0Sopenharmony_ci *  @stable ICU 3.2
11077777dab0Sopenharmony_ci */
11087777dab0Sopenharmony_ciU_CAPI int32_t U_EXPORT2
11097777dab0Sopenharmony_ciucol_cloneBinary(const UCollator *coll,
11107777dab0Sopenharmony_ci                 uint8_t *buffer, int32_t capacity,
11117777dab0Sopenharmony_ci                 UErrorCode *status);
11127777dab0Sopenharmony_ci
11137777dab0Sopenharmony_ci/** Opens a collator from a collator binary image created using
11147777dab0Sopenharmony_ci *  ucol_cloneBinary. Binary image used in instantiation of the
11157777dab0Sopenharmony_ci *  collator remains owned by the user and should stay around for
11167777dab0Sopenharmony_ci *  the lifetime of the collator. The API also takes a base collator
11177777dab0Sopenharmony_ci *  which must be the root collator.
11187777dab0Sopenharmony_ci *  @param bin binary image owned by the user and required through the
11197777dab0Sopenharmony_ci *             lifetime of the collator
11207777dab0Sopenharmony_ci *  @param length size of the image. If negative, the API will try to
11217777dab0Sopenharmony_ci *                figure out the length of the image
11227777dab0Sopenharmony_ci *  @param base Base collator, for lookup of untailored characters.
11237777dab0Sopenharmony_ci *              Must be the root collator, must not be NULL.
11247777dab0Sopenharmony_ci *              The base is required to be present through the lifetime of the collator.
11257777dab0Sopenharmony_ci *  @param status for catching errors
11267777dab0Sopenharmony_ci *  @return newly created collator
11277777dab0Sopenharmony_ci *  @see ucol_cloneBinary
11287777dab0Sopenharmony_ci *  @stable ICU 3.2
11297777dab0Sopenharmony_ci */
11307777dab0Sopenharmony_ciU_CAPI UCollator* U_EXPORT2
11317777dab0Sopenharmony_ciucol_openBinary(const uint8_t *bin, int32_t length,
11327777dab0Sopenharmony_ci                const UCollator *base,
11337777dab0Sopenharmony_ci                UErrorCode *status);
11347777dab0Sopenharmony_ci
11357777dab0Sopenharmony_ci
11367777dab0Sopenharmony_ci#endif /* #if !UCONFIG_NO_COLLATION */
11377777dab0Sopenharmony_ci
11387777dab0Sopenharmony_ci#endif
1139