Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

ucol.h File Reference

C API: Collator. More...

#include "unicode/utypes.h"
#include "unicode/unorm.h"
#include "unicode/parseerr.h"
#include "unicode/uloc.h"
#include "unicode/uset.h"

Go to the source code of this file.

Defines

#define U_COL_SAFECLONE_BUFFERSIZE   512
 default memory size for the new clone. More...


Typedefs

typedef collIterate collIterate
 structure representing collation element iterator instance. More...

typedef UCollator UCollator
 structure representing a collator object instance. More...

typedef UColAttributeValue UCollationStrength
 Base letter represents a primary difference. More...


Enumerations

enum  UCollationResult { UCOL_EQUAL = 0, UCOL_GREATER = 1, UCOL_LESS = -1 }
 UCOL_LESS is returned if source string is compared to be less than target string in the u_strcoll() method. More...

enum  UColAttributeValue {
  UCOL_DEFAULT = -1, UCOL_PRIMARY = 0, UCOL_SECONDARY = 1, UCOL_TERTIARY = 2,
  UCOL_DEFAULT_STRENGTH = UCOL_TERTIARY, UCOL_CE_STRENGTH_LIMIT, UCOL_QUATERNARY = 3, UCOL_IDENTICAL = 15,
  UCOL_STRENGTH_LIMIT, UCOL_OFF = 16, UCOL_ON = 17, UCOL_SHIFTED = 20,
  UCOL_NON_IGNORABLE = 21, UCOL_LOWER_FIRST = 24, UCOL_UPPER_FIRST = 25, UCOL_ATTRIBUTE_VALUE_COUNT
}
 Enum containing attribute values for controling collation behavior. More...

enum  UColAttribute {
  UCOL_FRENCH_COLLATION, UCOL_ALTERNATE_HANDLING, UCOL_CASE_FIRST, UCOL_CASE_LEVEL,
  UCOL_NORMALIZATION_MODE, UCOL_DECOMPOSITION_MODE = UCOL_NORMALIZATION_MODE, UCOL_STRENGTH, UCOL_HIRAGANA_QUATERNARY_MODE,
  UCOL_NUMERIC_COLLATION, UCOL_ATTRIBUTE_COUNT
}
 Attributes that collation service understands. More...

enum  UColRuleOption { UCOL_TAILORING_ONLY, UCOL_FULL_RULES }
 Options for retrieving the rule string. More...

enum  UColBoundMode { UCOL_BOUND_LOWER = 0, UCOL_BOUND_UPPER = 1, UCOL_BOUND_UPPER_LONG = 2, UCOL_BOUND_VALUE_COUNT }
 enum that is taken by ucol_getBound API See below for explanation do not change the values assigned to the members of this enum. More...


Functions

UCollatorucol_open (const char *loc, UErrorCode *status)
 Open a UCollator for comparing strings. More...

UCollatorucol_openRules (const UChar *rules, int32_t rulesLength, UColAttributeValue normalizationMode, UCollationStrength strength, UParseError *parseError, UErrorCode *status)
 Produce an UCollator instance according to the rules supplied. More...

void ucol_close (UCollator *coll)
 Close a UCollator. More...

UCollationResult ucol_strcoll (const UCollator *coll, const UChar *source, int32_t sourceLength, const UChar *target, int32_t targetLength)
 Compare two strings. More...

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. More...

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. More...

UBool ucol_equal (const UCollator *coll, const UChar *source, int32_t sourceLength, const UChar *target, int32_t targetLength)
 Compare two strings for equality. More...

UCollationResult ucol_strcollIter (const UCollator *coll, UCharIterator *sIter, UCharIterator *tIter, UErrorCode *status)
 Compare two UTF-8 encoded trings. More...

UCollationStrength ucol_getStrength (const UCollator *coll)
 Get the collation strength used in a UCollator. More...

void ucol_setStrength (UCollator *coll, UCollationStrength strength)
 Set the collation strength used in a UCollator. More...

int32_t ucol_getDisplayName (const char *objLoc, const char *dispLoc, UChar *result, int32_t resultLength, UErrorCode *status)
 Get the display name for a UCollator. More...

const char * ucol_getAvailable (int32_t index)
 Get a locale for which collation rules are available. More...

int32_t ucol_countAvailable (void)
 Determine how many locales have collation rules available. More...

const UChar * ucol_getRules (const UCollator *coll, int32_t *length)
 Get the collation rules from a UCollator. More...

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. More...

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. More...

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. More...

void ucol_getVersion (const UCollator *coll, UVersionInfo info)
 Gets the version information for a Collator. More...

void ucol_getUCAVersion (const UCollator *coll, UVersionInfo info)
 Gets the UCA version information for a Collator. More...

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. More...

void ucol_setAttribute (UCollator *coll, UColAttribute attr, UColAttributeValue value, UErrorCode *status)
 Universal attribute setter. More...

UColAttributeValue ucol_getAttribute (const UCollator *coll, UColAttribute attr, UErrorCode *status)
 Universal attribute getter. More...

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 less or equal than the variable top to be shifted when alternate handling is set to UCOL_SHIFTED. More...

uint32_t ucol_getVariableTop (const UCollator *coll, UErrorCode *status)
 Gets the variable top value of a Collator. More...

void ucol_restoreVariableTop (UCollator *coll, const uint32_t varTop, UErrorCode *status)
 Sets the variable top to a collation element value supplied. More...

UCollatorucol_safeClone (const UCollator *coll, void *stackBuffer, int32_t *pBufferSize, UErrorCode *status)
 Thread safe cloning operation. More...

int32_t ucol_getRulesEx (const UCollator *coll, UColRuleOption delta, UChar *buffer, int32_t bufferLen)
 Returns current rules. More...

const char * ucol_getLocale (const UCollator *coll, ULocDataLocaleType type, UErrorCode *status)
 gets the locale name of the collator. More...

const char * ucol_getLocaleByType (const UCollator *coll, ULocDataLocaleType type, UErrorCode *status)
 gets the locale name of the collator. More...

USetucol_getTailoredSet (const UCollator *coll, UErrorCode *status)
 Get an Unicode set that contains all the characters and sequences tailored in this collator. More...


Detailed Description

C API: Collator.

Collator C API

The C API for Collator performs locale-sensitive string comparison. You use this service to build searching and sorting routines for natural language text. Important: The ICU collation service has been reimplemented in order to achieve better performance and UCA compliance. For details, see the collation design document.

For more information about the collation service see the users guide.

Collation service provides correct sorting orders for most locales supported in ICU. If specific data for a locale is not available, the orders eventually falls back to the UCA sort order.

Sort ordering may be customized by providing your own set of rules. For more on this subject see the Collation customization section of the users guide.

See also:
UCollationResult , UNormalizationMode , UCollationStrength , UCollationElements

Definition in file ucol.h.


Define Documentation

#define U_COL_SAFECLONE_BUFFERSIZE   512
 

default memory size for the new clone.

It needs to be this large for os/400 large pointers

Stable:
ICU 2.0

Definition at line 761 of file ucol.h.


Typedef Documentation

typedef UColAttributeValue UCollationStrength
 

Base letter represents a primary difference.

Set comparison level to UCOL_PRIMARY to ignore secondary and tertiary differences. Use this to set the strength of a Collator object. Example of primary difference, "abc" < "abd"

Diacritical differences on the same base letter represent a secondary difference. Set comparison level to UCOL_SECONDARY to ignore tertiary differences. Use this to set the strength of a Collator object. Example of secondary difference, "ä" >> "a".

Uppercase and lowercase versions of the same character represents a tertiary difference. Set comparison level to UCOL_TERTIARY to include all comparison differences. Use this to set the strength of a Collator object. Example of tertiary difference, "abc" <<< "ABC".

Two characters are considered "identical" when they have the same unicode spellings. UCOL_IDENTICAL. For example, "ä" == "ä".

UCollationStrength is also used to determine the strength of sort keys generated from UCollator objects These values can be now found in the UColAttributeValue enum.

Stable:
ICU 2.0

Definition at line 169 of file ucol.h.

typedef struct UCollator UCollator
 

structure representing a collator object instance.

Stable:
ICU 2.0

Definition at line 69 of file ucol.h.

typedef struct collIterate collIterate
 

structure representing collation element iterator instance.

Stable:
ICU 2.0

Definition at line 60 of file ucol.h.


Enumeration Type Documentation

enum UColAttribute
 

Attributes that collation service understands.

All the attributes can take UCOL_DEFAULT value, as well as the values specific to each one.

Stable:
ICU 2.0
Enumeration values:
UCOL_FRENCH_COLLATION  Attribute for direction of secondary weights - used in French. Acceptable values are UCOL_ON, which results in secondary weights being considered backwards and UCOL_OFF which treats secondary weights in the order they appear.
UCOL_ALTERNATE_HANDLING  Attribute for handling variable elements. Acceptable values are UCOL_NON_IGNORABLE (default) which treats all the codepoints with non-ignorable primary weights in the same way, and UCOL_SHIFTED which causes codepoints with primary weights that are equal or below the variable top value to be ignored on primary level and moved to the quaternary level.
UCOL_CASE_FIRST  Controls the ordering of upper and lower case letters. Acceptable values are UCOL_OFF (default), which orders upper and lower case letters in accordance to their tertiary weights, UCOL_UPPER_FIRST which forces upper case letters to sort before lower case letters, and UCOL_LOWER_FIRST which does the opposite.
UCOL_CASE_LEVEL  Controls whether an extra case level (positioned before the third level) is generated or not. Acceptable values are UCOL_OFF (default), when case level is not generated, and UCOL_ON which causes the case level to be generated. Contents of the case level are affected by the value of UCOL_CASE_FIRST attribute. A simple way to ignore accent differences in a string is to set the strength to UCOL_PRIMARY and enable case level.
UCOL_NORMALIZATION_MODE  Controls whether the normalization check and necessary normalizations are performed. When set to UCOL_OFF (default) no normalization check is performed. The correctness of the result is guaranteed only if the input data is in so-called FCD form (see users manual for more info). When set to UCOL_ON, an incremental check is performed to see whether the input data is in the FCD form. If the data is not in the FCD form, incremental NFD normalization is performed.
UCOL_DECOMPOSITION_MODE  An alias for UCOL_NORMALIZATION_MODE attribute.
UCOL_STRENGTH  The strength attribute. Can be either UCOL_PRIMARY, UCOL_SECONDARY, UCOL_TERTIARY, UCOL_QUATERNARY or UCOL_IDENTICAL. The usual strength for most locales (except Japanese) is tertiary. Quaternary strength is useful when combined with shifted setting for alternate handling attribute and for JIS x 4061 collation, when it is used to distinguish between Katakana and Hiragana (this is achieved by setting the UCOL_HIRAGANA_QUATERNARY mode to on. Otherwise, quaternary level is affected only by the number of non ignorable code points in the string. Identical strength is rarely useful, as it amounts to codepoints of the NFD form of the string.
UCOL_HIRAGANA_QUATERNARY_MODE  when turned on, this attribute positions Hiragana before all non-ignorables on quaternary level This is a sneaky way to produce JIS sort order.
UCOL_NUMERIC_COLLATION  when turned on, this attribute generates a collation key for the numeric value of substrings of digits.

This is a way to get '100' to sort AFTER '2'.

UCOL_ATTRIBUTE_COUNT 

Definition at line 175 of file ucol.h.

enum UColAttributeValue
 

Enum containing attribute values for controling collation behavior.

Here are all the allowable values. Not every attribute can take every value. The only universal value is UCOL_DEFAULT, which resets the attribute value to the predefined value for that locale

Stable:
ICU 2.0
Enumeration values:
UCOL_DEFAULT  accepted by most attributes.
UCOL_PRIMARY  Primary collation strength.
UCOL_SECONDARY  Secondary collation strength.
UCOL_TERTIARY  Tertiary collation strength.
UCOL_DEFAULT_STRENGTH  Default collation strength.
UCOL_CE_STRENGTH_LIMIT 
UCOL_QUATERNARY  Quaternary collation strength.
UCOL_IDENTICAL  Identical collation strength.
UCOL_STRENGTH_LIMIT 
UCOL_OFF  Turn the feature off - works for UCOL_FRENCH_COLLATION, UCOL_CASE_LEVEL, UCOL_HIRAGANA_QUATERNARY_MODE & UCOL_DECOMPOSITION_MODE.
UCOL_ON  Turn the feature on - works for UCOL_FRENCH_COLLATION, UCOL_CASE_LEVEL, UCOL_HIRAGANA_QUATERNARY_MODE & UCOL_DECOMPOSITION_MODE.
UCOL_SHIFTED  Valid for UCOL_ALTERNATE_HANDLING.

Alternate handling will be shifted

UCOL_NON_IGNORABLE  Valid for UCOL_ALTERNATE_HANDLING.

Alternate handling will be non ignorable

UCOL_LOWER_FIRST  Valid for UCOL_CASE_FIRST - lower case sorts before upper case.
UCOL_UPPER_FIRST  upper case sorts before lower case.
UCOL_ATTRIBUTE_VALUE_COUNT 

Definition at line 100 of file ucol.h.

enum UColBoundMode
 

enum that is taken by ucol_getBound API See below for explanation do not change the values assigned to the members of this enum.

Underlying code depends on them having these numbers

Stable:
ICU 2.0
Enumeration values:
UCOL_BOUND_LOWER  lower bound.
UCOL_BOUND_UPPER  upper bound that will match strings of exact size.
UCOL_BOUND_UPPER_LONG  upper bound that will match all the strings that have the same initial substring as the given string.
UCOL_BOUND_VALUE_COUNT 

Definition at line 547 of file ucol.h.

enum UColRuleOption
 

Options for retrieving the rule string.

Stable:
ICU 2.0
Enumeration values:
UCOL_TAILORING_ONLY  Retrieve tailoring only.
UCOL_FULL_RULES  Retrieve UCA rules and tailoring.

Definition at line 244 of file ucol.h.

enum UCollationResult
 

UCOL_LESS is returned if source string is compared to be less than target string in the u_strcoll() method.

UCOL_EQUAL is returned if source string is compared to be equal to target string in the u_strcoll() method. UCOL_GREATER is returned if source string is compared to be greater than target string in the u_strcoll() method.

See also:
u_strcoll()

Possible values for a comparison result

Stable:
ICU 2.0
Enumeration values:
UCOL_EQUAL  string a == string b.
UCOL_GREATER  string a > string b.
UCOL_LESS  string a < string b.

Definition at line 84 of file ucol.h.


Function Documentation

void ucol_close UCollator   coll
 

Close a UCollator.

Once closed, a UCollator should not be used.\ Every open collator should be closed.\ Otherwise, a memory leak will result.

Parameters:
coll  The UCollator to close.
See also:
ucol_open , ucol_openRules , ucol_safeClone
Stable:
ICU 2.0

Referenced by RuleBasedCollator::setUCollator().

int32_t ucol_countAvailable void   
 

Determine how many locales have collation rules available.

This function is most useful as determining the loop ending condition for calls to \Ref{ucol_getAvailable}.

Returns:
The number of locales for which collation rules are available.
See also:
ucol_getAvailable
Stable:
ICU 2.0

UBool ucol_equal const UCollator   coll,
const UChar *    source,
int32_t    sourceLength,
const UChar *    target,
int32_t    targetLength
 

Compare two strings for equality.

This function is equivalent to \Ref{ucol_strcoll} == UCOL_EQUAL

Parameters:
coll  The UCollator containing the comparison rules.
source  The source string.
sourceLength  The length of source, or -1 if null-terminated.
target  The target string.
targetLength  The length of target, or -1 if null-terminated.
Returns:
TRUE if source is equal to target, FALSE otherwise
See also:
ucol_strcoll , ucol_greater , ucol_greaterOrEqual
Stable:
ICU 2.0

UColAttributeValue ucol_getAttribute const UCollator   coll,
UColAttribute    attr,
UErrorCode   status
 

Universal attribute getter.

Parameters:
coll  collator which attributes are to be changed
attr  attribute type
Returns:
attribute value
Parameters:
status  to indicate whether the operation went on smoothly or there were errors
See also:
UColAttribute , UColAttributeValue , ucol_setAttribute
Stable:
ICU 2.0

const char* ucol_getAvailable int32_t    index
 

Get a locale for which collation rules are available.

A UCollator in a locale returned by this function will perform the correct collation for the locale.

Parameters:
index  The index of the desired locale.
Returns:
A locale for which collation rules are available, or 0 if none.
See also:
ucol_countAvailable
Stable:
ICU 2.0

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.

Return value is always the number of bytes needed, regardless of whether the result buffer was big enough or even valid.
Resulting bounds can be used to produce a range of strings that are between upper and lower bounds. For example, if bounds are produced for a sortkey of string "smith", strings between upper and lower bounds with one level would include "Smith", "SMITH", "sMiTh".
There are two upper bounds that can be produced. If UCOL_BOUND_UPPER is produced, strings matched would be as above. However, if bound produced using UCOL_BOUND_UPPER_LONG is used, the above example will also match "Smithsonian" and similar.
For more on usage, see example in cintltst/capitst.c in procedure TestBounds. Sort keys may be compared using strcmp.

Parameters:
source  The source sortkey.
sourceLength  The length of source, or -1 if null-terminated. (If an unmodified sortkey is passed, it is always null terminated).
boundType  Type of bound required. It can be UCOL_BOUND_LOWER, which produces a lower inclusive bound, UCOL_BOUND_UPPER, that produces upper bound that matches strings of the same length or UCOL_BOUND_UPPER_LONG that matches strings that have the same starting substring as the source string.
noOfLevels  Number of levels required in the resulting bound (for most uses, the recommended value is 1). See users guide for explanation on number of levels a sortkey can have.
result  A pointer to a buffer to receive the resulting sortkey.
resultLength  The maximum size of result.
status  Used for returning error code if something went wrong. If the number of levels requested is higher than the number of levels in the source key, a warning (U_SORT_KEY_TOO_SHORT_WARNING) is issued.
Returns:
The size needed to fully store the bound.
See also:
ucol_keyHashCode
Stable:
ICU 2.1

int32_t ucol_getDisplayName const char *    objLoc,
const char *    dispLoc,
UChar *    result,
int32_t    resultLength,
UErrorCode   status
 

Get the display name for a UCollator.

The display name is suitable for presentation to a user.

Parameters:
objLoc  The locale of the collator in question.
dispLoc  The locale for display.
result  A pointer to a buffer to receive the attribute.
resultLength  The maximum size of result.
status  A pointer to an UErrorCode to receive any errors
Returns:
The total buffer size needed; if greater than resultLength, the output was truncated.
Stable:
ICU 2.0

const char* ucol_getLocale const UCollator   coll,
ULocDataLocaleType    type,
UErrorCode   status
 

gets the locale name of the collator.

If the collator is instantiated from the rules, then this function returns NULL.

Parameters:
coll  The UCollator for which the locale is needed
type  You can choose between requested, valid and actual locale. For description see the definition of ULocDataLocaleType in uloc.h
status  error code of the operation
Returns:
real locale name from which the collation data comes. If the collator was instantiated from rules, returns NULL.
Deprecated:
ICU 2.8 Use ucol_getLocaleByType instead

const char* ucol_getLocaleByType const UCollator   coll,
ULocDataLocaleType    type,
UErrorCode   status
 

gets the locale name of the collator.

If the collator is instantiated from the rules, then this function returns NULL.

Parameters:
coll  The UCollator for which the locale is needed
type  You can choose between requested, valid and actual locale. For description see the definition of ULocDataLocaleType in uloc.h
status  error code of the operation
Returns:
real locale name from which the collation data comes. If the collator was instantiated from rules, returns NULL.
Draft:
This API has been introduced in ICU 2.8. It is still in draft state and may be modified in a future release.

const UChar* ucol_getRules const UCollator   coll,
int32_t *    length
 

Get the collation rules from a UCollator.

The rules will follow the rule syntax.

Parameters:
coll  The UCollator to query.
length 
Returns:
The collation rules.
Stable:
ICU 2.0

int32_t ucol_getRulesEx const UCollator   coll,
UColRuleOption    delta,
UChar *    buffer,
int32_t    bufferLen
 

Returns current rules.

Delta defines whether full rules are returned or just the tailoring. Returns number of UChars needed to store rules. If buffer is NULL or bufferLen is not enough to store rules, will store up to available space.

Parameters:
coll  collator to get the rules from
delta  one of UCOL_TAILORING_ONLY, UCOL_FULL_RULES.
buffer  buffer to store the result in. If NULL, you'll get no rules.
bufferLen  lenght of buffer to store rules in. If less then needed you'll get only the part that fits in.
Returns:
current rules
Stable:
ICU 2.0

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.

Sort keys may be compared using strcmp.

Parameters:
coll  The UCollator containing the collation rules.
source  The string to transform.
sourceLength  The length of source, or -1 if null-terminated.
result  A pointer to a buffer to receive the attribute.
resultLength  The maximum size of result.
Returns:
The size needed to fully store the sort key..
See also:
ucol_keyHashCode
Stable:
ICU 2.0

UCollationStrength ucol_getStrength const UCollator   coll
 

Get the collation strength used in a UCollator.

The strength influences how strings are compared.

Parameters:
coll  The UCollator to query.
Returns:
The collation strength; one of UCOL_PRIMARY, UCOL_SECONDARY, UCOL_TERTIARY, UCOL_QUATERNARY, UCOL_IDENTICAL
See also:
ucol_setStrength
Stable:
ICU 2.0

USet* ucol_getTailoredSet const UCollator   coll,
UErrorCode   status
 

Get an Unicode set that contains all the characters and sequences tailored in this collator.

The result must be disposed of by using uset_close.

Parameters:
coll  The UCollator for which we want to get tailored chars
status  error code of the operation
Returns:
a pointer to newly created USet. Must be be disposed by using uset_close
See also:
ucol_openRules , uset_close
Draft:
This API has been introduced in ICU 2.4. It is still in draft state and may be modified in a future release.

void ucol_getUCAVersion const UCollator   coll,
UVersionInfo    info
 

Gets the UCA version information for a Collator.

Version is the UCA version number (3.1.1, 4.0).

Parameters:
coll  The UCollator to query.
info  the version # information, the result will be filled in
Stable:
ICU 2.0

uint32_t ucol_getVariableTop const UCollator   coll,
UErrorCode   status
 

Gets the variable top value of a Collator.

Lower 16 bits are undefined and should be ignored.

Parameters:
coll  collator which variable top needs to be retrieved
status  error code (not changed by function). If error code is set, the return value is undefined.
Returns:
the variable top value of a Collator.
See also:
ucol_setVariableTop , ucol_restoreVariableTop
Stable:
ICU 2.0

void ucol_getVersion const UCollator   coll,
UVersionInfo    info
 

Gets the version information for a Collator.

Version is currently an opaque 32-bit number which depends, among other things, on major versions of the collator tailoring and UCA.

Parameters:
coll  The UCollator to query.
info  the version # information, the result will be filled in
Stable:
ICU 2.0

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.

This function is equivalent to \Ref{ucol_strcoll} == UCOL_GREATER

Parameters:
coll  The UCollator containing the comparison rules.
source  The source string.
sourceLength  The length of source, or -1 if null-terminated.
target  The target string.
targetLength  The length of target, or -1 if null-terminated.
Returns:
TRUE if source is greater than target, FALSE otherwise.
See also:
ucol_strcoll , ucol_greaterOrEqual , ucol_equal
Stable:
ICU 2.0

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.

This function is equivalent to \Ref{ucol_strcoll} != UCOL_LESS

Parameters:
coll  The UCollator containing the comparison rules.
source  The source string.
sourceLength  The length of source, or -1 if null-terminated.
target  The target string.
targetLength  The length of target, or -1 if null-terminated.
Returns:
TRUE if source is greater than or equal to target, FALSE otherwise.
See also:
ucol_strcoll , ucol_greater , ucol_equal
Stable:
ICU 2.0

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.

The levels are merged with their corresponding counterparts (primaries with primaries, secondaries with secondaries etc.). Between the values from the same level a separator is inserted. example (uncompressed): 191B1D 01 050505 01 910505 00 and 1F2123 01 050505 01 910505 00 will be merged as 191B1D 02 1F212301 050505 02 050505 01 910505 02 910505 00 This allows for concatenating of first and last names for sorting, among other things. If the destination buffer is not big enough, the results are undefined. If any of source lengths are zero or any of source pointers are NULL/undefined, result is of size zero.

Parameters:
src1  pointer to the first sortkey
src1Length  length of the first sortkey
src2  pointer to the second sortkey
src2Length  length of the second sortkey
dest  buffer to hold the result
destCapacity  size of the buffer for the result
Returns:
size of the result. If the buffer is big enough size is always src1Length+src2Length-1
Stable:
ICU 2.0

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.

Caller needs to preserve state array between calls and to provide the same type of UCharIterator set with the same string. The destination buffer provided must be big enough to store the number of requested bytes. Generated sortkey is not compatible with sortkeys generated using ucol_getSortKey API, since we don't do any compression. If uncompressed sortkeys are required, this API can be used.

Parameters:
coll  The UCollator containing the collation rules.
iter  UCharIterator containing the string we need the sort key to be calculated for.
state  Opaque state of sortkey iteration.
dest  Buffer to hold the resulting sortkey part
count  number of sort key bytes required.
status  error code indicator.
Returns:
the actual number of bytes of a sortkey. It can be smaller than count if we have reached the end of the sort key.
Draft:
This API has been introduced in ICU 2.6. It is still in draft state and may be modified in a future release.

UCollator* ucol_open const char *    loc,
UErrorCode   status
 

Open a UCollator for comparing strings.

The UCollator pointer is used in all the calls to the Collation service. After finished, collator must be disposed of by calling \Ref{ucol_close}.

Parameters:
loc  The locale containing the required collation rules. Special values for locales can be passed in - if NULL is passed for the locale, the default locale collation rules will be used. If empty string ("") or "root" are passed, UCA rules will be used.
status  A pointer to an UErrorCode to receive any errors
Returns:
A pointer to a UCollator, or 0 if an error occurred.
See also:
ucol_openRules , ucol_safeClone , ucol_close
Stable:
ICU 2.0

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.

The rules are used to change the default ordering, defined in the UCA in a process called tailoring. The resulting UCollator pointer can be used in the same way as the one obtained by \Ref{ucol_strcoll}.

Parameters:
rules  A string describing the collation rules. For the syntax of the rules please see users guide.
rulesLength  The length of rules, or -1 if null-terminated.
normalizationMode  The normalization mode: One of UCOL_OFF (expect the text to not need normalization), UCOL_ON (normalize), or UCOL_DEFAULT (set the mode according to the rules)
strength  The default collation strength; one of UCOL_PRIMARY, UCOL_SECONDARY, UCOL_TERTIARY, UCOL_IDENTICAL,UCOL_DEFAULT_STRENGTH - can be also set in the rules.
parseError  A pointer to UParseError to recieve information about errors occurred during parsing. This argument can currently be set to NULL, but at users own risk. Please provide a real structure.
status  A pointer to an UErrorCode to receive any errors
Returns:
A pointer to a UCollator.\ It is not guaranteed that NULL be returned in case of error - please use status argument to check for errors.
See also:
ucol_open , ucol_safeClone , ucol_close
Stable:
ICU 2.0

void ucol_restoreVariableTop UCollator   coll,
const uint32_t    varTop,
UErrorCode   status
 

Sets the variable top to a collation element value supplied.

Variable top is set to the upper 16 bits. Lower 16 bits are ignored.

Parameters:
coll  collator which variable top needs to be changed
varTop  CE value, as returned by ucol_setVariableTop or ucol)getVariableTop
status  error code (not changed by function)
See also:
ucol_getVariableTop , ucol_setVariableTop
Stable:
ICU 2.0

UCollator* ucol_safeClone const UCollator   coll,
void *    stackBuffer,
int32_t *    pBufferSize,
UErrorCode   status
 

Thread safe cloning operation.

The result is a clone of a given collator.

Parameters:
coll  collator to be cloned
stackBuffer  user allocated space for the new clone. If NULL new memory will be allocated. If buffer is not large enough, new memory will be allocated. Clients can use the U_COL_SAFECLONE_BUFFERSIZE. This will probably be enough to avoid memory allocations.
pBufferSize  pointer to size of allocated space. If *pBufferSize == 0, a sufficient size for use in cloning will be returned ('pre-flighting') If *pBufferSize is not enough for a stack-based safe clone, new memory will be allocated.
status  to indicate whether the operation went on smoothly or there were errors An informational status value, U_SAFECLONE_ALLOCATED_ERROR, is used if any allocations were necessary.
Returns:
pointer to the new clone
See also:
ucol_open , ucol_openRules , ucol_close
Stable:
ICU 2.0

void ucol_setAttribute UCollator   coll,
UColAttribute    attr,
UColAttributeValue    value,
UErrorCode   status
 

Universal attribute setter.

Parameters:
coll  collator which attributes are to be changed
attr  attribute type
value  attribute value
status  to indicate whether the operation went on smoothly or there were errors
See also:
UColAttribute , UColAttributeValue , ucol_getAttribute
Stable:
ICU 2.0

void ucol_setStrength UCollator   coll,
UCollationStrength    strength
 

Set the collation strength used in a UCollator.

The strength influences how strings are compared.

Parameters:
coll  The UCollator to set.
strength  The desired collation strength; one of UCOL_PRIMARY, UCOL_SECONDARY, UCOL_TERTIARY, UCOL_QUATERNARY, UCOL_IDENTICAL, UCOL_DEFAULT
See also:
ucol_getStrength
Stable:
ICU 2.0

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 less or equal than the variable top to be shifted when alternate handling is set to UCOL_SHIFTED.

Sets the variable top to a collation element value of a string supplied.

Parameters:
coll  collator which variable top needs to be changed
varTop  one or more (if contraction) UChars to which the variable top should be set
len  length of variable top string. If -1 it is considered to be zero terminated.
status  error code. If error code is set, the return value is undefined. Errors set by this function are:
U_CE_NOT_FOUND_ERROR if more than one character was passed and there is no such a contraction
U_PRIMARY_TOO_LONG_ERROR if the primary for the variable top has more than two bytes
Returns:
a 32 bit value containing the value of the variable top in upper 16 bits. Lower 16 bits are undefined
See also:
ucol_getVariableTop , ucol_restoreVariableTop
Stable:
ICU 2.0

UCollationResult ucol_strcoll const UCollator   coll,
const UChar *    source,
int32_t    sourceLength,
const UChar *    target,
int32_t    targetLength
 

Compare two strings.

The strings will be compared using the options already specified.

Parameters:
coll  The UCollator containing the comparison rules.
source  The source string.
sourceLength  The length of source, or -1 if null-terminated.
target  The target string.
targetLength  The length of target, or -1 if null-terminated.
Returns:
The result of comparing the strings; one of UCOL_EQUAL, UCOL_GREATER, UCOL_LESS
See also:
ucol_greater , ucol_greaterOrEqual , ucol_equal
Stable:
ICU 2.0

UCollationResult ucol_strcollIter const UCollator   coll,
UCharIterator   sIter,
UCharIterator   tIter,
UErrorCode   status
 

Compare two UTF-8 encoded trings.

The strings will be compared using the options already specified.

Parameters:
coll  The UCollator containing the comparison rules.
sIter  The source string iterator.
tIter  The target string iterator.
Returns:
The result of comparing the strings; one of UCOL_EQUAL, UCOL_GREATER, UCOL_LESS
Parameters:
status  A pointer to an UErrorCode to receive any errors
See also:
ucol_strcoll
Draft:
This API has been introduced in ICU 2.6. It is still in draft state and may be modified in a future release.


Generated on Mon Nov 24 14:35:58 2003 for ICU 2.8 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001