ICU 50.2 50.2
ucol.h
Go to the documentation of this file.
1/*
2*******************************************************************************
3* Copyright (c) 1996-2012, International Business Machines Corporation and others.
4* All Rights Reserved.
5*******************************************************************************
6*/
7
8#ifndef UCOL_H
9#define UCOL_H
10
11#include "unicode/utypes.h"
12
13#if !UCONFIG_NO_COLLATION
14
15#include "unicode/unorm.h"
17#include "unicode/parseerr.h"
18#include "unicode/uloc.h"
19#include "unicode/uset.h"
20#include "unicode/uscript.h"
21
54
58struct UCollator;
62typedef struct UCollator UCollator;
63
64
77typedef enum {
85
86
93typedef enum {
96
105 UCOL_CE_STRENGTH_LIMIT,
110 UCOL_STRENGTH_LIMIT,
111
120
125
131
132 UCOL_ATTRIBUTE_VALUE_COUNT
133
135
207
235
332
352
370U_STABLE UCollator* U_EXPORT2
371ucol_open(const char *loc, UErrorCode *status);
372
398U_STABLE UCollator* U_EXPORT2
399ucol_openRules( const UChar *rules,
400 int32_t rulesLength,
401 UColAttributeValue normalizationMode,
402 UCollationStrength strength,
403 UParseError *parseError,
404 UErrorCode *status);
405
440U_STABLE UCollator* U_EXPORT2
441ucol_openFromShortString( const char *definition,
442 UBool forceDefaults,
443 UParseError *parseError,
444 UErrorCode *status);
445
446#ifndef U_HIDE_DEPRECATED_API
460U_DEPRECATED int32_t U_EXPORT2
462 USet *conts,
463 UErrorCode *status);
464#endif /* U_HIDE_DEPRECATED_API */
465
477U_STABLE void U_EXPORT2
479 USet *contractions, USet *expansions,
480 UBool addPrefixes, UErrorCode *status);
481
492U_STABLE void U_EXPORT2
494
495#if U_SHOW_CPLUSPLUS_API
496
498
509
511
512#endif
513
529U_STABLE UCollationResult U_EXPORT2
531 const UChar *source,
532 int32_t sourceLength,
533 const UChar *target,
534 int32_t targetLength);
535
556 const UCollator *coll,
557 const char *source,
558 int32_t sourceLength,
559 const char *target,
560 int32_t targetLength,
561 UErrorCode *status);
562
577U_STABLE UBool U_EXPORT2
579 const UChar *source, int32_t sourceLength,
580 const UChar *target, int32_t targetLength);
581
596U_STABLE UBool U_EXPORT2
598 const UChar *source, int32_t sourceLength,
599 const UChar *target, int32_t targetLength);
600
615U_STABLE UBool U_EXPORT2
617 const UChar *source, int32_t sourceLength,
618 const UChar *target, int32_t targetLength);
619
632U_STABLE UCollationResult U_EXPORT2
634 UCharIterator *sIter,
635 UCharIterator *tIter,
636 UErrorCode *status);
637
649
659U_STABLE void U_EXPORT2
661 UCollationStrength strength);
662
679U_STABLE int32_t U_EXPORT2
681 int32_t* dest,
682 int32_t destCapacity,
683 UErrorCode *pErrorCode);
719U_STABLE void U_EXPORT2
721 const int32_t* reorderCodes,
722 int32_t reorderCodesLength,
723 UErrorCode *pErrorCode);
724
741U_STABLE int32_t U_EXPORT2
743 int32_t* dest,
744 int32_t destCapacity,
745 UErrorCode *pErrorCode);
746
759U_STABLE int32_t U_EXPORT2
760ucol_getDisplayName( const char *objLoc,
761 const char *dispLoc,
762 UChar *result,
763 int32_t resultLength,
764 UErrorCode *status);
765
775U_STABLE const char* U_EXPORT2
776ucol_getAvailable(int32_t localeIndex);
777
786U_STABLE int32_t U_EXPORT2
788
789#if !UCONFIG_NO_SERVICE
798U_STABLE UEnumeration* U_EXPORT2
800#endif
801
811U_STABLE UEnumeration* U_EXPORT2
813
825U_STABLE UEnumeration* U_EXPORT2
826ucol_getKeywordValues(const char *keyword, UErrorCode *status);
827
844U_STABLE UEnumeration* U_EXPORT2
846 const char* locale,
847 UBool commonlyUsed,
848 UErrorCode* status);
849
880U_STABLE int32_t U_EXPORT2
881ucol_getFunctionalEquivalent(char* result, int32_t resultCapacity,
882 const char* keyword, const char* locale,
883 UBool* isAvailable, UErrorCode* status);
884
893U_STABLE const UChar* U_EXPORT2
895 int32_t *length);
896
917U_STABLE int32_t U_EXPORT2
919 const char *locale,
920 char *buffer,
921 int32_t capacity,
922 UErrorCode *status);
923
943
944U_STABLE int32_t U_EXPORT2
946 char *destination,
947 int32_t capacity,
948 UParseError *parseError,
949 UErrorCode *status);
950
951
971U_STABLE int32_t U_EXPORT2
973 const UChar *source,
974 int32_t sourceLength,
975 uint8_t *result,
976 int32_t resultLength);
977
978
999U_STABLE int32_t U_EXPORT2
1001 UCharIterator *iter,
1002 uint32_t state[2],
1003 uint8_t *dest, int32_t count,
1004 UErrorCode *status);
1005
1013typedef enum {
1020 UCOL_BOUND_VALUE_COUNT
1022
1060U_STABLE int32_t U_EXPORT2
1061ucol_getBound(const uint8_t *source,
1062 int32_t sourceLength,
1063 UColBoundMode boundType,
1064 uint32_t noOfLevels,
1065 uint8_t *result,
1066 int32_t resultLength,
1067 UErrorCode *status);
1068
1077U_STABLE void U_EXPORT2
1079
1087U_STABLE void U_EXPORT2
1089
1112U_STABLE int32_t U_EXPORT2
1113ucol_mergeSortkeys(const uint8_t *src1, int32_t src1Length,
1114 const uint8_t *src2, int32_t src2Length,
1115 uint8_t *dest, int32_t destCapacity);
1116
1128U_STABLE void U_EXPORT2
1130
1144
1164U_STABLE uint32_t U_EXPORT2
1166 const UChar *varTop, int32_t len,
1167 UErrorCode *status);
1168
1180U_STABLE uint32_t U_EXPORT2 ucol_getVariableTop(const UCollator *coll, UErrorCode *status);
1181
1193U_STABLE void U_EXPORT2
1194ucol_restoreVariableTop(UCollator *coll, const uint32_t varTop, UErrorCode *status);
1195
1218U_STABLE UCollator* U_EXPORT2
1220 void *stackBuffer,
1221 int32_t *pBufferSize,
1222 UErrorCode *status);
1223
1227#define U_COL_SAFECLONE_BUFFERSIZE 528
1228
1244U_STABLE int32_t U_EXPORT2
1245ucol_getRulesEx(const UCollator *coll, UColRuleOption delta, UChar *buffer, int32_t bufferLen);
1246
1247#ifndef U_HIDE_DEPRECATED_API
1262U_DEPRECATED const char * U_EXPORT2
1264#endif /* U_HIDE_DEPRECATED_API */
1265
1280U_STABLE const char * U_EXPORT2
1282
1293U_STABLE USet * U_EXPORT2
1295
1296#ifndef U_HIDE_INTERNAL_API
1310
1319U_INTERNAL UBool U_EXPORT2
1320ucol_equals(const UCollator *source, const UCollator *target);
1321
1333U_INTERNAL int32_t U_EXPORT2
1335 USet *unsafe,
1336 UErrorCode *status);
1337
1341U_INTERNAL void U_EXPORT2
1343
1364U_INTERNAL void U_EXPORT2
1365ucol_prepareShortStringOpen( const char *definition,
1366 UBool forceDefaults,
1367 UParseError *parseError,
1368 UErrorCode *status);
1369#endif /* U_HIDE_INTERNAL_API */
1370
1382U_STABLE int32_t U_EXPORT2
1384 uint8_t *buffer, int32_t capacity,
1385 UErrorCode *status);
1386
1404U_STABLE UCollator* U_EXPORT2
1405ucol_openBinary(const uint8_t *bin, int32_t length,
1406 const UCollator *base,
1407 UErrorCode *status);
1408
1409
1410#endif /* #if !UCONFIG_NO_COLLATION */
1411
1412#endif
"Smart pointer" class, closes a UCollator via ucol_close().
C++ API: "Smart pointers" for use with and in ICU4C C++ code.
#define U_DEFINE_LOCAL_OPEN_POINTER(LocalPointerClassName, Type, closeFunction)
"Smart pointer" definition macro, deletes objects via the closeFunction.
C API: Parse Error Information.
C API for code unit iteration.
Definition uiter.h:339
A UParseError struct is used to returned detailed information about parsing errors.
Definition parseerr.h:56
struct USet USet
A UnicodeSet.
Definition ucnv.h:67
UEnumeration * ucol_getKeywordValues(const char *keyword, UErrorCode *status)
Given a keyword, create a string enumeration of all values for that keyword that are currently in use...
int32_t ucol_getUnsafeSet(const UCollator *coll, USet *unsafe, UErrorCode *status)
Calculates the set of unsafe code points, given a collator.
void ucol_getUCAVersion(const UCollator *coll, UVersionInfo info)
Gets the UCA version information for a Collator.
uint32_t ucol_setVariableTop(UCollator *coll, const UChar *varTop, int32_t len, UErrorCode *status)
Variable top is a two byte primary value which causes all the codepoints with primary values that are...
int32_t ucol_mergeSortkeys(const uint8_t *src1, int32_t src1Length, const uint8_t *src2, int32_t src2Length, uint8_t *dest, int32_t destCapacity)
Merge two sort keys.
const UChar * ucol_getRules(const UCollator *coll, int32_t *length)
Get the collation tailoring rules from a UCollator.
int32_t ucol_getSortKey(const UCollator *coll, const UChar *source, int32_t sourceLength, uint8_t *result, int32_t resultLength)
Get a sort key for a string from a UCollator.
int32_t ucol_cloneBinary(const UCollator *coll, uint8_t *buffer, int32_t capacity, UErrorCode *status)
Creates a binary image of a collator.
int32_t ucol_getRulesEx(const UCollator *coll, UColRuleOption delta, UChar *buffer, int32_t bufferLen)
Returns current rules.
void ucol_getContractionsAndExpansions(const UCollator *coll, USet *contractions, USet *expansions, UBool addPrefixes, UErrorCode *status)
Get a set containing the expansions defined by the collator.
void ucol_setAttribute(UCollator *coll, UColAttribute attr, UColAttributeValue value, UErrorCode *status)
Universal attribute setter.
UCollationResult ucol_strcollUTF8(const UCollator *coll, const char *source, int32_t sourceLength, const char *target, int32_t targetLength, UErrorCode *status)
Compare two strings in UTF-8.
struct UCollator UCollator
structure representing a collator object instance
Definition ucol.h:62
int32_t ucol_getEquivalentReorderCodes(int32_t reorderCode, int32_t *dest, int32_t destCapacity, UErrorCode *pErrorCode)
Retrieves the reorder codes that are grouped with the given reorder code.
UCollator * ucol_open(const char *loc, UErrorCode *status)
Open a UCollator for comparing strings.
int32_t ucol_normalizeShortDefinitionString(const char *source, char *destination, int32_t capacity, UParseError *parseError, UErrorCode *status)
Verifies and normalizes short definition string.
UColRuleOption
Options for retrieving the rule string.
Definition ucol.h:336
@ UCOL_FULL_RULES
Retrieves the "UCA rules" concatenated with the tailoring rules.
Definition ucol.h:350
@ UCOL_TAILORING_ONLY
Retrieves the tailoring rules only.
Definition ucol.h:342
UEnumeration * ucol_getKeywordValuesForLocale(const char *key, const char *locale, UBool commonlyUsed, UErrorCode *status)
Given a key and a locale, returns an array of string values in a preferred order that would make a di...
UColAttribute
Attributes that collation service understands.
Definition ucol.h:240
@ UCOL_CASE_FIRST
Controls the ordering of upper and lower case letters.
Definition ucol.h:267
@ UCOL_NUMERIC_COLLATION
When turned on, this attribute generates a collation key for the numeric value of substrings of digit...
Definition ucol.h:325
@ UCOL_STRENGTH
The strength attribute.
Definition ucol.h:304
@ UCOL_CASE_LEVEL
Controls whether an extra case level (positioned before the third level) is generated or not.
Definition ucol.h:277
@ UCOL_FRENCH_COLLATION
Attribute for direction of secondary weights - used in Canadian French.
Definition ucol.h:247
@ UCOL_HIRAGANA_QUATERNARY_MODE
When turned on, this attribute positions Hiragana before all non-ignorables on quaternary level Thi...
Definition ucol.h:315
@ UCOL_DECOMPOSITION_MODE
An alias for UCOL_NORMALIZATION_MODE attribute.
Definition ucol.h:291
@ UCOL_ATTRIBUTE_COUNT
The number of UColAttribute constants.
Definition ucol.h:330
@ UCOL_ALTERNATE_HANDLING
Attribute for handling variable elements.
Definition ucol.h:258
@ UCOL_NORMALIZATION_MODE
Controls whether the normalization check and necessary normalizations are performed.
Definition ucol.h:287
int32_t ucol_getContractions(const UCollator *coll, USet *conts, UErrorCode *status)
Get a set containing the contractions defined by the collator.
USet * ucol_getTailoredSet(const UCollator *coll, UErrorCode *status)
Get an Unicode set that contains all the characters and sequences tailored in this collator.
void ucol_forgetUCA(void)
Reset UCA's static pointers.
void ucol_close(UCollator *coll)
Close a UCollator.
UColAttributeValue UCollationStrength
Base letter represents a primary difference.
Definition ucol.h:234
int32_t ucol_getReorderCodes(const UCollator *coll, int32_t *dest, int32_t destCapacity, UErrorCode *pErrorCode)
Retrieves the reordering codes for this collator.
void ucol_setReorderCodes(UCollator *coll, const int32_t *reorderCodes, int32_t reorderCodesLength, UErrorCode *pErrorCode)
Sets the reordering codes for this collator.
int32_t ucol_getShortDefinitionString(const UCollator *coll, const char *locale, char *buffer, int32_t capacity, UErrorCode *status)
Get the short definition string for a collator.
const char * ucol_getAvailable(int32_t localeIndex)
Get a locale for which collation rules are available.
UCollator * ucol_openRules(const UChar *rules, int32_t rulesLength, UColAttributeValue normalizationMode, UCollationStrength strength, UParseError *parseError, UErrorCode *status)
Produce an UCollator instance according to the rules supplied.
uint32_t ucol_getVariableTop(const UCollator *coll, UErrorCode *status)
Gets the variable top value of a Collator.
UCollator * ucol_openFromShortString(const char *definition, UBool forceDefaults, UParseError *parseError, UErrorCode *status)
Open a collator defined by a short form string.
const char * ucol_getLocale(const UCollator *coll, ULocDataLocaleType type, UErrorCode *status)
gets the locale name of the collator.
UCollationResult
UCOL_LESS is returned if source string is compared to be less than target string in the u_strcoll() m...
Definition ucol.h:77
@ UCOL_LESS
string a < string b
Definition ucol.h:83
@ UCOL_GREATER
string a > string b
Definition ucol.h:81
@ UCOL_EQUAL
string a == string b
Definition ucol.h:79
int32_t ucol_nextSortKeyPart(const UCollator *coll, UCharIterator *iter, uint32_t state[2], uint8_t *dest, int32_t count, UErrorCode *status)
Gets the next count bytes of a sort key.
UCollator * ucol_safeClone(const UCollator *coll, void *stackBuffer, int32_t *pBufferSize, UErrorCode *status)
Thread safe cloning operation.
UEnumeration * ucol_getKeywords(UErrorCode *status)
Create a string enumerator of all possible keywords that are relevant to collation.
UCollationResult ucol_strcoll(const UCollator *coll, const UChar *source, int32_t sourceLength, const UChar *target, int32_t targetLength)
Compare two strings.
UColAttributeValue ucol_getAttributeOrDefault(const UCollator *coll, UColAttribute attr, UErrorCode *status)
Universal attribute getter that returns UCOL_DEFAULT if the value is default.
int32_t ucol_getDisplayName(const char *objLoc, const char *dispLoc, UChar *result, int32_t resultLength, UErrorCode *status)
Get the display name for a UCollator.
UColBoundMode
enum that is taken by ucol_getBound API See below for explanation do not change the values assigned...
Definition ucol.h:1013
@ UCOL_BOUND_LOWER
lower bound
Definition ucol.h:1015
@ UCOL_BOUND_UPPER
upper bound that will match strings of exact size
Definition ucol.h:1017
@ UCOL_BOUND_UPPER_LONG
upper bound that will match all the strings that have the same initial substring as the given string
Definition ucol.h:1019
UBool ucol_greater(const UCollator *coll, const UChar *source, int32_t sourceLength, const UChar *target, int32_t targetLength)
Determine if one string is greater than another.
UEnumeration * ucol_openAvailableLocales(UErrorCode *status)
Create a string enumerator of all locales for which a valid collator may be opened.
UCollationStrength ucol_getStrength(const UCollator *coll)
Get the collation strength used in a UCollator.
int32_t ucol_countAvailable(void)
Determine how many locales have collation rules available.
int32_t ucol_getBound(const uint8_t *source, int32_t sourceLength, UColBoundMode boundType, uint32_t noOfLevels, uint8_t *result, int32_t resultLength, UErrorCode *status)
Produce a bound for a given sortkey and a number of levels.
UColAttributeValue
Enum containing attribute values for controling collation behavior.
Definition ucol.h:93
@ UCOL_UPPER_FIRST
upper case sorts before lower case
Definition ucol.h:130
@ UCOL_TERTIARY
Tertiary collation strength.
Definition ucol.h:102
@ UCOL_DEFAULT
accepted by most attributes
Definition ucol.h:95
@ UCOL_IDENTICAL
Identical collation strength.
Definition ucol.h:109
@ UCOL_OFF
Turn the feature off - works for UCOL_FRENCH_COLLATION, UCOL_CASE_LEVEL, UCOL_HIRAGANA_QUATERNARY_MOD...
Definition ucol.h:115
@ UCOL_QUATERNARY
Quaternary collation strength.
Definition ucol.h:107
@ UCOL_SHIFTED
Valid for UCOL_ALTERNATE_HANDLING.
Definition ucol.h:122
@ UCOL_PRIMARY
Primary collation strength.
Definition ucol.h:98
@ UCOL_LOWER_FIRST
Valid for UCOL_CASE_FIRST - lower case sorts before upper case.
Definition ucol.h:128
@ UCOL_SECONDARY
Secondary collation strength.
Definition ucol.h:100
@ UCOL_NON_IGNORABLE
Valid for UCOL_ALTERNATE_HANDLING.
Definition ucol.h:124
@ UCOL_ON
Turn the feature on - works for UCOL_FRENCH_COLLATION, UCOL_CASE_LEVEL, UCOL_HIRAGANA_QUATERNARY_MODE...
Definition ucol.h:119
@ UCOL_DEFAULT_STRENGTH
Default collation strength.
Definition ucol.h:104
UBool ucol_greaterOrEqual(const UCollator *coll, const UChar *source, int32_t sourceLength, const UChar *target, int32_t targetLength)
Determine if one string is greater than or equal to another.
void ucol_restoreVariableTop(UCollator *coll, const uint32_t varTop, UErrorCode *status)
Sets the variable top to a collation element value supplied.
UBool ucol_equal(const UCollator *coll, const UChar *source, int32_t sourceLength, const UChar *target, int32_t targetLength)
Compare two strings for equality.
UCollationResult ucol_strcollIter(const UCollator *coll, UCharIterator *sIter, UCharIterator *tIter, UErrorCode *status)
Compare two UTF-8 encoded trings.
void ucol_setStrength(UCollator *coll, UCollationStrength strength)
Set the collation strength used in a UCollator.
UColReorderCode
Enum containing the codes for reordering segments of the collation table that are not script codes.
Definition ucol.h:145
@ UCOL_REORDER_CODE_OTHERS
A special reordering code that is used to specify all other codes used for reordering except for the ...
Definition ucol.h:163
@ UCOL_REORDER_CODE_NONE
A special reordering code that is used to specify no reordering codes.
Definition ucol.h:156
@ UCOL_REORDER_CODE_DEFAULT
A special reordering code that is used to specify the default reordering codes for a locale.
Definition ucol.h:151
@ UCOL_REORDER_CODE_LIMIT
The limit of the reorder codes.
Definition ucol.h:205
@ UCOL_REORDER_CODE_SYMBOL
Characters with the symbol property.
Definition ucol.h:187
@ UCOL_REORDER_CODE_DIGIT
Characters with the digit property.
Definition ucol.h:199
@ UCOL_REORDER_CODE_PUNCTUATION
Characters with the punctuation property.
Definition ucol.h:181
@ UCOL_REORDER_CODE_SPACE
Characters with the space property.
Definition ucol.h:169
@ UCOL_REORDER_CODE_FIRST
The first entry in the enumeration of reordering groups.
Definition ucol.h:175
@ UCOL_REORDER_CODE_CURRENCY
Characters with the currency property.
Definition ucol.h:193
void ucol_getVersion(const UCollator *coll, UVersionInfo info)
Gets the version information for a Collator.
const char * ucol_getLocaleByType(const UCollator *coll, ULocDataLocaleType type, UErrorCode *status)
gets the locale name of the collator.
int32_t ucol_getFunctionalEquivalent(char *result, int32_t resultCapacity, const char *keyword, const char *locale, UBool *isAvailable, UErrorCode *status)
Return the functionally equivalent locale for the given requested locale, with respect to given keywo...
void ucol_prepareShortStringOpen(const char *definition, UBool forceDefaults, UParseError *parseError, UErrorCode *status)
Touches all resources needed for instantiating a collator from a short string definition,...
UColAttributeValue ucol_getAttribute(const UCollator *coll, UColAttribute attr, UErrorCode *status)
Universal attribute getter.
UBool ucol_equals(const UCollator *source, const UCollator *target)
Check whether two collators are equal.
UCollator * ucol_openBinary(const uint8_t *bin, int32_t length, const UCollator *base, UErrorCode *status)
Opens a collator from a collator binary image created using ucol_cloneBinary.
struct UEnumeration UEnumeration
structure representing an enumeration object instance
Definition uenum.h:39
C API: Locale.
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested,...
Definition uloc.h:336
#define U_DEPRECATED
This is used to declare a function as a deprecated public ICU C API.
Definition umachine.h:113
#define U_INTERNAL
This is used to declare a function as an internal ICU C API.
Definition umachine.h:117
int8_t UBool
The ICU boolean type.
Definition umachine.h:200
#define U_DRAFT
This is used to declare a function as a draft public ICU C API.
Definition umachine.h:111
uint16_t UChar
Define UChar to be UCHAR_TYPE, if that is #defined (for example, to char16_t), or wchar_t if that is ...
Definition umachine.h:278
#define U_STABLE
This is used to declare a function as a stable public ICU C API.
Definition umachine.h:109
C API: Unicode Normalization.
C API: Unicode Script Information.
@ USCRIPT_UNKNOWN
Definition uscript.h:277
C API: Unicode Set.
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers,...
Definition utypes.h:476
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition uversion.h:130
uint8_t UVersionInfo[U_MAX_VERSION_LENGTH]
The binary form of a version on ICU APIs is an array of 4 uint8_t.
Definition uversion.h:57
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition uversion.h:129