00001 /* 00002 ******************************************************************************* 00003 * Copyright © {1996-1999}, International Business Machines Corporation and others. All Rights Reserved. 00004 ******************************************************************************* 00005 */ 00006 00007 #ifndef UCOL_H 00008 #define UCOL_H 00009 00010 #include "unicode/utypes.h" 00096 typedef void* UCollator; 00097 00108 enum UCollationResult { 00110 UCOL_EQUAL = 0, 00112 UCOL_GREATER = 1, 00114 UCOL_LESS = -1 00115 }; 00116 typedef enum UCollationResult UCollationResult; 00128 enum UNormalizationMode { 00130 UCOL_NO_NORMALIZATION, 00132 UCOL_DECOMP_CAN, 00134 UCOL_DECOMP_COMPAT, 00136 UCOL_DECOMP_CAN_COMP_COMPAT, 00138 UCOL_DECOMP_COMPAT_COMP_CAN, 00140 UCOL_DEFAULT_NORMALIZATION = UCOL_DECOMP_COMPAT 00141 }; 00142 typedef enum UNormalizationMode UNormalizationMode; 00143 00145 enum UNormalizationOption { 00147 UCOL_IGNORE_HANGUL = 1 00148 }; 00149 typedef enum UNormalizationOption UNormalizationOption; 00175 enum UCollationStrength { 00177 UCOL_PRIMARY = 0, 00179 UCOL_SECONDARY = 1, 00181 UCOL_TERTIARY = 2, 00183 UCOL_IDENTICAL = 3, 00185 UCOL_DEFAULT_STRENGTH = UCOL_TERTIARY 00186 } ; 00187 typedef enum UCollationStrength UCollationStrength; 00188 00265 U_CAPI int32_t 00266 u_normalize(const UChar* source, 00267 int32_t sourceLength, 00268 UNormalizationMode mode, 00269 int32_t options, 00270 UChar* result, 00271 int32_t resultLength, 00272 UErrorCode* status); 00273 00283 U_CAPI UCollator* 00284 ucol_open( const char *loc, 00285 UErrorCode *status); 00286 00302 U_CAPI UCollator* 00303 ucol_openRules( const UChar *rules, 00304 int32_t rulesLength, 00305 UNormalizationMode mode, 00306 UCollationStrength strength, 00307 UErrorCode *status); 00308 00315 U_CAPI void 00316 ucol_close(UCollator *coll); 00317 00334 U_CAPI UCollationResult 00335 ucol_strcoll( const UCollator *coll, 00336 const UChar *source, 00337 int32_t sourceLength, 00338 const UChar *target, 00339 int32_t targetLength); 00340 00355 U_CAPI UBool 00356 ucol_greater( const UCollator *coll, 00357 const UChar *source, 00358 int32_t sourceLength, 00359 const UChar *target, 00360 int32_t targetLength); 00361 00376 U_CAPI UBool 00377 ucol_greaterOrEqual( const UCollator *coll, 00378 const UChar *source, 00379 int32_t sourceLength, 00380 const UChar *target, 00381 int32_t targetLength); 00382 00397 U_CAPI UBool 00398 ucol_equal( const UCollator *coll, 00399 const UChar *source, 00400 int32_t sourceLength, 00401 const UChar *target, 00402 int32_t targetLength); 00403 00413 U_CAPI UCollationStrength 00414 ucol_getStrength(const UCollator *coll); 00415 00439 U_CAPI void 00440 ucol_setStrength( UCollator *coll, 00441 UCollationStrength strength); 00442 00453 U_CAPI UNormalizationMode 00454 ucol_getNormalization(const UCollator* coll); 00455 00466 U_CAPI void 00467 ucol_setNormalization( UCollator *coll, 00468 UNormalizationMode mode); 00469 00482 U_CAPI int32_t 00483 ucol_getDisplayName( const char *objLoc, 00484 const char *dispLoc, 00485 UChar *result, 00486 int32_t resultLength, 00487 UErrorCode *status); 00488 00498 U_CAPI const char* 00499 ucol_getAvailable(int32_t index); 00500 00509 U_CAPI int32_t 00510 ucol_countAvailable(void); 00511 00520 U_CAPI const UChar* 00521 ucol_getRules( const UCollator *coll, 00522 int32_t *length); 00523 00536 U_CAPI int32_t 00537 ucol_getSortKey(const UCollator *coll, 00538 const UChar *source, 00539 int32_t sourceLength, 00540 uint8_t *result, 00541 int32_t resultLength); 00542 00552 U_CAPI int32_t 00553 ucol_keyHashCode( const uint8_t* key, 00554 int32_t length); 00555 00556 00560 struct UCollationElements; 00561 typedef struct UCollationElements UCollationElements; 00620 U_CAPI UCollationElements* 00621 ucol_openElements( const UCollator *coll, 00622 const UChar *text, 00623 int32_t textLength, 00624 UErrorCode *status); 00625 00626 /* Bit mask for primary collation strength. */ 00627 #define UCOL_PRIMARYMASK 0xFFFF0000 00628 00629 /* Bit mask for secondary collation strength. */ 00630 #define UCOL_SECONDARYMASK 0x0000FF00 00631 00632 /* Bit mask for tertiary collation strength. */ 00633 #define UCOL_TERTIARYMASK 0x000000FF 00634 00638 #define UCOL_NULLORDER 0xFFFFFFFF 00639 00646 U_CAPI void 00647 ucol_closeElements(UCollationElements *elems); 00648 00657 U_CAPI void 00658 ucol_reset(UCollationElements *elems); 00659 00669 U_CAPI int32_t 00670 ucol_next( UCollationElements *elems, 00671 UErrorCode *status); 00672 00682 U_CAPI int32_t 00683 ucol_previous( UCollationElements *elems, 00684 UErrorCode *status); 00685 00696 U_CAPI int32_t 00697 ucol_getMaxExpansion( const UCollationElements *elems, 00698 int32_t order); 00699 00710 U_CAPI void 00711 ucol_setText( UCollationElements *elems, 00712 const UChar *text, 00713 int32_t textLength, 00714 UErrorCode *status); 00715 00725 U_CAPI UTextOffset 00726 ucol_getOffset(const UCollationElements *elems); 00727 00737 U_CAPI void 00738 ucol_setOffset( UCollationElements *elems, 00739 UTextOffset offset, 00740 UErrorCode *status); 00741 00747 U_CAPI void U_EXPORT2 00748 ucol_getVersion(const UCollator* coll, UVersionInfo info); 00749 00759 U_CAPI uint8_t * 00760 ucol_cloneRuleData(UCollator *coll, int32_t *length, UErrorCode *status); 00761 00762 00763 #endif