00001
00002
00003
00004
00005
00006
00007
00008 #ifndef UCOL_H
00009 #define UCOL_H
00010
00011 #include "unicode/utypes.h"
00012
00013 #if !UCONFIG_NO_COLLATION
00014
00015 #include "unicode/unorm.h"
00016 #include "unicode/parseerr.h"
00017 #include "unicode/uloc.h"
00018 #include "unicode/uset.h"
00019
00056 struct UCollator;
00060 typedef struct UCollator UCollator;
00061
00062
00075 typedef enum {
00077 UCOL_EQUAL = 0,
00079 UCOL_GREATER = 1,
00081 UCOL_LESS = -1
00082 } UCollationResult ;
00083
00084
00091 typedef enum {
00093 UCOL_DEFAULT = -1,
00094
00096 UCOL_PRIMARY = 0,
00098 UCOL_SECONDARY = 1,
00100 UCOL_TERTIARY = 2,
00102 UCOL_DEFAULT_STRENGTH = UCOL_TERTIARY,
00103 UCOL_CE_STRENGTH_LIMIT,
00105 UCOL_QUATERNARY=3,
00107 UCOL_IDENTICAL=15,
00108 UCOL_STRENGTH_LIMIT,
00109
00113 UCOL_OFF = 16,
00117 UCOL_ON = 17,
00118
00120 UCOL_SHIFTED = 20,
00122 UCOL_NON_IGNORABLE = 21,
00123
00126 UCOL_LOWER_FIRST = 24,
00128 UCOL_UPPER_FIRST = 25,
00129
00130 UCOL_ATTRIBUTE_VALUE_COUNT
00131
00132 } UColAttributeValue;
00133
00160 typedef UColAttributeValue UCollationStrength;
00161
00166 typedef enum {
00171 UCOL_FRENCH_COLLATION,
00180 UCOL_ALTERNATE_HANDLING,
00187 UCOL_CASE_FIRST,
00195 UCOL_CASE_LEVEL,
00203 UCOL_NORMALIZATION_MODE,
00205 UCOL_DECOMPOSITION_MODE = UCOL_NORMALIZATION_MODE,
00216 UCOL_STRENGTH,
00222 UCOL_HIRAGANA_QUATERNARY_MODE,
00228 UCOL_NUMERIC_COLLATION,
00229 UCOL_ATTRIBUTE_COUNT
00230 } UColAttribute;
00231
00235 typedef enum {
00237 UCOL_TAILORING_ONLY,
00239 UCOL_FULL_RULES
00240 } UColRuleOption ;
00241
00259 U_STABLE UCollator* U_EXPORT2
00260 ucol_open(const char *loc, UErrorCode *status);
00261
00287 U_STABLE UCollator* U_EXPORT2
00288 ucol_openRules( const UChar *rules,
00289 int32_t rulesLength,
00290 UColAttributeValue normalizationMode,
00291 UCollationStrength strength,
00292 UParseError *parseError,
00293 UErrorCode *status);
00294
00329 U_CAPI UCollator* U_EXPORT2
00330 ucol_openFromShortString( const char *definition,
00331 UBool forceDefaults,
00332 UParseError *parseError,
00333 UErrorCode *status);
00334
00348 U_CAPI int32_t U_EXPORT2
00349 ucol_getContractions( const UCollator *coll,
00350 USet *conts,
00351 UErrorCode *status);
00352
00364 U_CAPI void U_EXPORT2
00365 ucol_getContractionsAndExpansions( const UCollator *coll,
00366 USet *contractions, USet *expansions,
00367 UBool addPrefixes, UErrorCode *status);
00368
00379 U_STABLE void U_EXPORT2
00380 ucol_close(UCollator *coll);
00381
00397 U_STABLE UCollationResult U_EXPORT2
00398 ucol_strcoll( const UCollator *coll,
00399 const UChar *source,
00400 int32_t sourceLength,
00401 const UChar *target,
00402 int32_t targetLength);
00403
00418 U_STABLE UBool U_EXPORT2
00419 ucol_greater(const UCollator *coll,
00420 const UChar *source, int32_t sourceLength,
00421 const UChar *target, int32_t targetLength);
00422
00437 U_STABLE UBool U_EXPORT2
00438 ucol_greaterOrEqual(const UCollator *coll,
00439 const UChar *source, int32_t sourceLength,
00440 const UChar *target, int32_t targetLength);
00441
00456 U_STABLE UBool U_EXPORT2
00457 ucol_equal(const UCollator *coll,
00458 const UChar *source, int32_t sourceLength,
00459 const UChar *target, int32_t targetLength);
00460
00473 U_STABLE UCollationResult U_EXPORT2
00474 ucol_strcollIter( const UCollator *coll,
00475 UCharIterator *sIter,
00476 UCharIterator *tIter,
00477 UErrorCode *status);
00478
00488 U_STABLE UCollationStrength U_EXPORT2
00489 ucol_getStrength(const UCollator *coll);
00490
00500 U_STABLE void U_EXPORT2
00501 ucol_setStrength(UCollator *coll,
00502 UCollationStrength strength);
00503
00516 U_STABLE int32_t U_EXPORT2
00517 ucol_getDisplayName( const char *objLoc,
00518 const char *dispLoc,
00519 UChar *result,
00520 int32_t resultLength,
00521 UErrorCode *status);
00522
00532 U_STABLE const char* U_EXPORT2
00533 ucol_getAvailable(int32_t index);
00534
00543 U_STABLE int32_t U_EXPORT2
00544 ucol_countAvailable(void);
00545
00546 #if !UCONFIG_NO_SERVICE
00547
00555 U_DRAFT UEnumeration* U_EXPORT2
00556 ucol_openAvailableLocales(UErrorCode *status);
00557 #endif
00558
00568 U_DRAFT UEnumeration* U_EXPORT2
00569 ucol_getKeywords(UErrorCode *status);
00570
00582 U_DRAFT UEnumeration* U_EXPORT2
00583 ucol_getKeywordValues(const char *keyword, UErrorCode *status);
00584
00615 U_DRAFT int32_t U_EXPORT2
00616 ucol_getFunctionalEquivalent(char* result, int32_t resultCapacity,
00617 const char* keyword, const char* locale,
00618 UBool* isAvailable, UErrorCode* status);
00619
00628 U_STABLE const UChar* U_EXPORT2
00629 ucol_getRules( const UCollator *coll,
00630 int32_t *length);
00631
00652 U_CAPI int32_t U_EXPORT2
00653 ucol_getShortDefinitionString(const UCollator *coll,
00654 const char *locale,
00655 char *buffer,
00656 int32_t capacity,
00657 UErrorCode *status);
00658
00679 U_CAPI int32_t U_EXPORT2
00680 ucol_normalizeShortDefinitionString(const char *source,
00681 char *destination,
00682 int32_t capacity,
00683 UParseError *parseError,
00684 UErrorCode *status);
00685
00686
00699 U_STABLE int32_t U_EXPORT2
00700 ucol_getSortKey(const UCollator *coll,
00701 const UChar *source,
00702 int32_t sourceLength,
00703 uint8_t *result,
00704 int32_t resultLength);
00705
00706
00727 U_STABLE int32_t U_EXPORT2
00728 ucol_nextSortKeyPart(const UCollator *coll,
00729 UCharIterator *iter,
00730 uint32_t state[2],
00731 uint8_t *dest, int32_t count,
00732 UErrorCode *status);
00733
00741 typedef enum {
00743 UCOL_BOUND_LOWER = 0,
00745 UCOL_BOUND_UPPER = 1,
00747 UCOL_BOUND_UPPER_LONG = 2,
00748 UCOL_BOUND_VALUE_COUNT
00749 } UColBoundMode;
00750
00788 U_STABLE int32_t U_EXPORT2
00789 ucol_getBound(const uint8_t *source,
00790 int32_t sourceLength,
00791 UColBoundMode boundType,
00792 uint32_t noOfLevels,
00793 uint8_t *result,
00794 int32_t resultLength,
00795 UErrorCode *status);
00796
00805 U_STABLE void U_EXPORT2
00806 ucol_getVersion(const UCollator* coll, UVersionInfo info);
00807
00815 U_DRAFT void U_EXPORT2
00816 ucol_getUCAVersion(const UCollator* coll, UVersionInfo info);
00817
00840 U_STABLE int32_t U_EXPORT2
00841 ucol_mergeSortkeys(const uint8_t *src1, int32_t src1Length,
00842 const uint8_t *src2, int32_t src2Length,
00843 uint8_t *dest, int32_t destCapacity);
00844
00856 U_STABLE void U_EXPORT2
00857 ucol_setAttribute(UCollator *coll, UColAttribute attr, UColAttributeValue value, UErrorCode *status);
00858
00870 U_STABLE UColAttributeValue U_EXPORT2
00871 ucol_getAttribute(const UCollator *coll, UColAttribute attr, UErrorCode *status);
00872
00892 U_STABLE uint32_t U_EXPORT2
00893 ucol_setVariableTop(UCollator *coll,
00894 const UChar *varTop, int32_t len,
00895 UErrorCode *status);
00896
00908 U_STABLE uint32_t U_EXPORT2 ucol_getVariableTop(const UCollator *coll, UErrorCode *status);
00909
00921 U_STABLE void U_EXPORT2
00922 ucol_restoreVariableTop(UCollator *coll, const uint32_t varTop, UErrorCode *status);
00923
00946 U_STABLE UCollator* U_EXPORT2
00947 ucol_safeClone(const UCollator *coll,
00948 void *stackBuffer,
00949 int32_t *pBufferSize,
00950 UErrorCode *status);
00951
00955 #define U_COL_SAFECLONE_BUFFERSIZE 512
00956
00968 U_STABLE int32_t U_EXPORT2
00969 ucol_getRulesEx(const UCollator *coll, UColRuleOption delta, UChar *buffer, int32_t bufferLen);
00970
00985 U_DEPRECATED const char * U_EXPORT2
00986 ucol_getLocale(const UCollator *coll, ULocDataLocaleType type, UErrorCode *status);
00987
00988
01003 U_DRAFT const char * U_EXPORT2
01004 ucol_getLocaleByType(const UCollator *coll, ULocDataLocaleType type, UErrorCode *status);
01005
01016 U_STABLE USet * U_EXPORT2
01017 ucol_getTailoredSet(const UCollator *coll, UErrorCode *status);
01018
01024 #define UCOL_SIT_COLLATOR_NOT_ENCODABLE 0x80000000
01025
01039 U_INTERNAL uint32_t U_EXPORT2
01040 ucol_collatorToIdentifier(const UCollator *coll,
01041 const char *locale,
01042 UErrorCode *status);
01043
01060 U_INTERNAL UCollator* U_EXPORT2
01061 ucol_openFromIdentifier(uint32_t identifier,
01062 UBool forceDefaults,
01063 UErrorCode *status);
01064
01065
01082 U_INTERNAL int32_t U_EXPORT2
01083 ucol_identifierToShortString(uint32_t identifier,
01084 char *buffer,
01085 int32_t capacity,
01086 UBool forceDefaults,
01087 UErrorCode *status);
01088
01103 U_INTERNAL uint32_t U_EXPORT2
01104 ucol_shortStringToIdentifier(const char *definition,
01105 UBool forceDefaults,
01106 UErrorCode *status);
01107
01108
01109
01121 U_INTERNAL UColAttributeValue U_EXPORT2
01122 ucol_getAttributeOrDefault(const UCollator *coll, UColAttribute attr, UErrorCode *status);
01123
01132 U_INTERNAL UBool U_EXPORT2
01133 ucol_equals(const UCollator *source, const UCollator *target);
01134
01146 U_INTERNAL int32_t U_EXPORT2
01147 ucol_getUnsafeSet( const UCollator *coll,
01148 USet *unsafe,
01149 UErrorCode *status);
01150
01154 U_INTERNAL void U_EXPORT2
01155 ucol_forgetUCA(void);
01156
01177 U_INTERNAL void U_EXPORT2
01178 ucol_prepareShortStringOpen( const char *definition,
01179 UBool forceDefaults,
01180 UParseError *parseError,
01181 UErrorCode *status);
01182
01194 U_DRAFT int32_t U_EXPORT2
01195 ucol_cloneBinary(const UCollator *coll,
01196 uint8_t *buffer, int32_t capacity,
01197 UErrorCode *status);
01198
01216 U_DRAFT UCollator* U_EXPORT2
01217 ucol_openBinary(const uint8_t *bin, int32_t length,
01218 const UCollator *base,
01219 UErrorCode *status);
01220
01221
01222 #endif
01223
01224 #endif
01225