michael@0: /* michael@0: ******************************************************************************* michael@0: * michael@0: * Copyright (C) 2001-2011, International Business Machines michael@0: * Corporation and others. All Rights Reserved. michael@0: * michael@0: ******************************************************************************* michael@0: * file name: unormcmp.cpp michael@0: * encoding: US-ASCII michael@0: * tab size: 8 (not used) michael@0: * indentation:4 michael@0: * michael@0: * created on: 2004sep13 michael@0: * created by: Markus W. Scherer michael@0: * michael@0: * unorm_compare() function moved here from unorm.cpp for better modularization. michael@0: * Depends on both normalization and case folding. michael@0: * Allows unorm.cpp to not depend on any character properties code. michael@0: */ michael@0: michael@0: #include "unicode/utypes.h" michael@0: michael@0: #if !UCONFIG_NO_NORMALIZATION michael@0: michael@0: #include "unicode/unorm.h" michael@0: #include "unicode/ustring.h" michael@0: #include "cmemory.h" michael@0: #include "normalizer2impl.h" michael@0: #include "ucase.h" michael@0: #include "uprops.h" michael@0: #include "ustr_imp.h" michael@0: michael@0: U_NAMESPACE_USE michael@0: michael@0: #define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0])) michael@0: michael@0: /* compare canonically equivalent ------------------------------------------- */ michael@0: michael@0: /* michael@0: * Compare two strings for canonical equivalence. michael@0: * Further options include case-insensitive comparison and michael@0: * code point order (as opposed to code unit order). michael@0: * michael@0: * In this function, canonical equivalence is optional as well. michael@0: * If canonical equivalence is tested, then both strings must fulfill michael@0: * the FCD check. michael@0: * michael@0: * Semantically, this is equivalent to michael@0: * strcmp[CodePointOrder](NFD(foldCase(s1)), NFD(foldCase(s2))) michael@0: * where code point order, NFD and foldCase are all optional. michael@0: * michael@0: * String comparisons almost always yield results before processing both strings michael@0: * completely. michael@0: * They are generally more efficient working incrementally instead of michael@0: * performing the sub-processing (strlen, normalization, case-folding) michael@0: * on the entire strings first. michael@0: * michael@0: * It is also unnecessary to not normalize identical characters. michael@0: * michael@0: * This function works in principle as follows: michael@0: * michael@0: * loop { michael@0: * get one code unit c1 from s1 (-1 if end of source) michael@0: * get one code unit c2 from s2 (-1 if end of source) michael@0: * michael@0: * if(either string finished) { michael@0: * return result; michael@0: * } michael@0: * if(c1==c2) { michael@0: * continue; michael@0: * } michael@0: * michael@0: * // c1!=c2 michael@0: * try to decompose/case-fold c1/c2, and continue if one does; michael@0: * michael@0: * // still c1!=c2 and neither decomposes/case-folds, return result michael@0: * return c1-c2; michael@0: * } michael@0: * michael@0: * When a character decomposes, then the pointer for that source changes to michael@0: * the decomposition, pushing the previous pointer onto a stack. michael@0: * When the end of the decomposition is reached, then the code unit reader michael@0: * pops the previous source from the stack. michael@0: * (Same for case-folding.) michael@0: * michael@0: * This is complicated further by operating on variable-width UTF-16. michael@0: * The top part of the loop works on code units, while lookups for decomposition michael@0: * and case-folding need code points. michael@0: * Code points are assembled after the equality/end-of-source part. michael@0: * The source pointer is only advanced beyond all code units when the code point michael@0: * actually decomposes/case-folds. michael@0: * michael@0: * If we were on a trail surrogate unit when assembling a code point, michael@0: * and the code point decomposes/case-folds, then the decomposition/folding michael@0: * result must be compared with the part of the other string that corresponds to michael@0: * this string's lead surrogate. michael@0: * Since we only assemble a code point when hitting a trail unit when the michael@0: * preceding lead units were identical, we back up the other string by one unit michael@0: * in such a case. michael@0: * michael@0: * The optional code point order comparison at the end works with michael@0: * the same fix-up as the other code point order comparison functions. michael@0: * See ustring.c and the comment near the end of this function. michael@0: * michael@0: * Assumption: A decomposition or case-folding result string never contains michael@0: * a single surrogate. This is a safe assumption in the Unicode Standard. michael@0: * Therefore, we do not need to check for surrogate pairs across michael@0: * decomposition/case-folding boundaries. michael@0: * michael@0: * Further assumptions (see verifications tstnorm.cpp): michael@0: * The API function checks for FCD first, while the core function michael@0: * first case-folds and then decomposes. This requires that case-folding does not michael@0: * un-FCD any strings. michael@0: * michael@0: * The API function may also NFD the input and turn off decomposition. michael@0: * This requires that case-folding does not un-NFD strings either. michael@0: * michael@0: * TODO If any of the above two assumptions is violated, michael@0: * then this entire code must be re-thought. michael@0: * If this happens, then a simple solution is to case-fold both strings up front michael@0: * and to turn off UNORM_INPUT_IS_FCD. michael@0: * We already do this when not both strings are in FCD because makeFCD michael@0: * would be a partial NFD before the case folding, which does not work. michael@0: * Note that all of this is only a problem when case-folding _and_ michael@0: * canonical equivalence come together. michael@0: * (Comments in unorm_compare() are more up to date than this TODO.) michael@0: */ michael@0: michael@0: /* stack element for previous-level source/decomposition pointers */ michael@0: struct CmpEquivLevel { michael@0: const UChar *start, *s, *limit; michael@0: }; michael@0: typedef struct CmpEquivLevel CmpEquivLevel; michael@0: michael@0: /** michael@0: * Internal option for unorm_cmpEquivFold() for decomposing. michael@0: * If not set, just do strcasecmp(). michael@0: */ michael@0: #define _COMPARE_EQUIV 0x80000 michael@0: michael@0: /* internal function */ michael@0: static int32_t michael@0: unorm_cmpEquivFold(const UChar *s1, int32_t length1, michael@0: const UChar *s2, int32_t length2, michael@0: uint32_t options, michael@0: UErrorCode *pErrorCode) { michael@0: const Normalizer2Impl *nfcImpl; michael@0: const UCaseProps *csp; michael@0: michael@0: /* current-level start/limit - s1/s2 as current */ michael@0: const UChar *start1, *start2, *limit1, *limit2; michael@0: michael@0: /* decomposition and case folding variables */ michael@0: const UChar *p; michael@0: int32_t length; michael@0: michael@0: /* stacks of previous-level start/current/limit */ michael@0: CmpEquivLevel stack1[2], stack2[2]; michael@0: michael@0: /* buffers for algorithmic decompositions */ michael@0: UChar decomp1[4], decomp2[4]; michael@0: michael@0: /* case folding buffers, only use current-level start/limit */ michael@0: UChar fold1[UCASE_MAX_STRING_LENGTH+1], fold2[UCASE_MAX_STRING_LENGTH+1]; michael@0: michael@0: /* track which is the current level per string */ michael@0: int32_t level1, level2; michael@0: michael@0: /* current code units, and code points for lookups */ michael@0: UChar32 c1, c2, cp1, cp2; michael@0: michael@0: /* no argument error checking because this itself is not an API */ michael@0: michael@0: /* michael@0: * assume that at least one of the options _COMPARE_EQUIV and U_COMPARE_IGNORE_CASE is set michael@0: * otherwise this function must behave exactly as uprv_strCompare() michael@0: * not checking for that here makes testing this function easier michael@0: */ michael@0: michael@0: /* normalization/properties data loaded? */ michael@0: if((options&_COMPARE_EQUIV)!=0) { michael@0: nfcImpl=Normalizer2Factory::getNFCImpl(*pErrorCode); michael@0: } else { michael@0: nfcImpl=NULL; michael@0: } michael@0: if((options&U_COMPARE_IGNORE_CASE)!=0) { michael@0: csp=ucase_getSingleton(); michael@0: } else { michael@0: csp=NULL; michael@0: } michael@0: if(U_FAILURE(*pErrorCode)) { michael@0: return 0; michael@0: } michael@0: michael@0: /* initialize */ michael@0: start1=s1; michael@0: if(length1==-1) { michael@0: limit1=NULL; michael@0: } else { michael@0: limit1=s1+length1; michael@0: } michael@0: michael@0: start2=s2; michael@0: if(length2==-1) { michael@0: limit2=NULL; michael@0: } else { michael@0: limit2=s2+length2; michael@0: } michael@0: michael@0: level1=level2=0; michael@0: c1=c2=-1; michael@0: michael@0: /* comparison loop */ michael@0: for(;;) { michael@0: /* michael@0: * here a code unit value of -1 means "get another code unit" michael@0: * below it will mean "this source is finished" michael@0: */ michael@0: michael@0: if(c1<0) { michael@0: /* get next code unit from string 1, post-increment */ michael@0: for(;;) { michael@0: if(s1==limit1 || ((c1=*s1)==0 && (limit1==NULL || (options&_STRNCMP_STYLE)))) { michael@0: if(level1==0) { michael@0: c1=-1; michael@0: break; michael@0: } michael@0: } else { michael@0: ++s1; michael@0: break; michael@0: } michael@0: michael@0: /* reached end of level buffer, pop one level */ michael@0: do { michael@0: --level1; michael@0: start1=stack1[level1].start; /*Not uninitialized*/ michael@0: } while(start1==NULL); michael@0: s1=stack1[level1].s; /*Not uninitialized*/ michael@0: limit1=stack1[level1].limit; /*Not uninitialized*/ michael@0: } michael@0: } michael@0: michael@0: if(c2<0) { michael@0: /* get next code unit from string 2, post-increment */ michael@0: for(;;) { michael@0: if(s2==limit2 || ((c2=*s2)==0 && (limit2==NULL || (options&_STRNCMP_STYLE)))) { michael@0: if(level2==0) { michael@0: c2=-1; michael@0: break; michael@0: } michael@0: } else { michael@0: ++s2; michael@0: break; michael@0: } michael@0: michael@0: /* reached end of level buffer, pop one level */ michael@0: do { michael@0: --level2; michael@0: start2=stack2[level2].start; /*Not uninitialized*/ michael@0: } while(start2==NULL); michael@0: s2=stack2[level2].s; /*Not uninitialized*/ michael@0: limit2=stack2[level2].limit; /*Not uninitialized*/ michael@0: } michael@0: } michael@0: michael@0: /* michael@0: * compare c1 and c2 michael@0: * either variable c1, c2 is -1 only if the corresponding string is finished michael@0: */ michael@0: if(c1==c2) { michael@0: if(c1<0) { michael@0: return 0; /* c1==c2==-1 indicating end of strings */ michael@0: } michael@0: c1=c2=-1; /* make us fetch new code units */ michael@0: continue; michael@0: } else if(c1<0) { michael@0: return -1; /* string 1 ends before string 2 */ michael@0: } else if(c2<0) { michael@0: return 1; /* string 2 ends before string 1 */ michael@0: } michael@0: /* c1!=c2 && c1>=0 && c2>=0 */ michael@0: michael@0: /* get complete code points for c1, c2 for lookups if either is a surrogate */ michael@0: cp1=c1; michael@0: if(U_IS_SURROGATE(c1)) { michael@0: UChar c; michael@0: michael@0: if(U_IS_SURROGATE_LEAD(c1)) { michael@0: if(s1!=limit1 && U16_IS_TRAIL(c=*s1)) { michael@0: /* advance ++s1; only below if cp1 decomposes/case-folds */ michael@0: cp1=U16_GET_SUPPLEMENTARY(c1, c); michael@0: } michael@0: } else /* isTrail(c1) */ { michael@0: if(start1<=(s1-2) && U16_IS_LEAD(c=*(s1-2))) { michael@0: cp1=U16_GET_SUPPLEMENTARY(c, c1); michael@0: } michael@0: } michael@0: } michael@0: michael@0: cp2=c2; michael@0: if(U_IS_SURROGATE(c2)) { michael@0: UChar c; michael@0: michael@0: if(U_IS_SURROGATE_LEAD(c2)) { michael@0: if(s2!=limit2 && U16_IS_TRAIL(c=*s2)) { michael@0: /* advance ++s2; only below if cp2 decomposes/case-folds */ michael@0: cp2=U16_GET_SUPPLEMENTARY(c2, c); michael@0: } michael@0: } else /* isTrail(c2) */ { michael@0: if(start2<=(s2-2) && U16_IS_LEAD(c=*(s2-2))) { michael@0: cp2=U16_GET_SUPPLEMENTARY(c, c2); michael@0: } michael@0: } michael@0: } michael@0: michael@0: /* michael@0: * go down one level for each string michael@0: * continue with the main loop as soon as there is a real change michael@0: */ michael@0: michael@0: if( level1==0 && (options&U_COMPARE_IGNORE_CASE) && michael@0: (length=ucase_toFullFolding(csp, (UChar32)cp1, &p, options))>=0 michael@0: ) { michael@0: /* cp1 case-folds to the code point "length" or to p[length] */ michael@0: if(U_IS_SURROGATE(c1)) { michael@0: if(U_IS_SURROGATE_LEAD(c1)) { michael@0: /* advance beyond source surrogate pair if it case-folds */ michael@0: ++s1; michael@0: } else /* isTrail(c1) */ { michael@0: /* michael@0: * we got a supplementary code point when hitting its trail surrogate, michael@0: * therefore the lead surrogate must have been the same as in the other string; michael@0: * compare this decomposition with the lead surrogate in the other string michael@0: * remember that this simulates bulk text replacement: michael@0: * the decomposition would replace the entire code point michael@0: */ michael@0: --s2; michael@0: c2=*(s2-1); michael@0: } michael@0: } michael@0: michael@0: /* push current level pointers */ michael@0: stack1[0].start=start1; michael@0: stack1[0].s=s1; michael@0: stack1[0].limit=limit1; michael@0: ++level1; michael@0: michael@0: /* copy the folding result to fold1[] */ michael@0: if(length<=UCASE_MAX_STRING_LENGTH) { michael@0: u_memcpy(fold1, p, length); michael@0: } else { michael@0: int32_t i=0; michael@0: U16_APPEND_UNSAFE(fold1, i, length); michael@0: length=i; michael@0: } michael@0: michael@0: /* set next level pointers to case folding */ michael@0: start1=s1=fold1; michael@0: limit1=fold1+length; michael@0: michael@0: /* get ready to read from decomposition, continue with loop */ michael@0: c1=-1; michael@0: continue; michael@0: } michael@0: michael@0: if( level2==0 && (options&U_COMPARE_IGNORE_CASE) && michael@0: (length=ucase_toFullFolding(csp, (UChar32)cp2, &p, options))>=0 michael@0: ) { michael@0: /* cp2 case-folds to the code point "length" or to p[length] */ michael@0: if(U_IS_SURROGATE(c2)) { michael@0: if(U_IS_SURROGATE_LEAD(c2)) { michael@0: /* advance beyond source surrogate pair if it case-folds */ michael@0: ++s2; michael@0: } else /* isTrail(c2) */ { michael@0: /* michael@0: * we got a supplementary code point when hitting its trail surrogate, michael@0: * therefore the lead surrogate must have been the same as in the other string; michael@0: * compare this decomposition with the lead surrogate in the other string michael@0: * remember that this simulates bulk text replacement: michael@0: * the decomposition would replace the entire code point michael@0: */ michael@0: --s1; michael@0: c1=*(s1-1); michael@0: } michael@0: } michael@0: michael@0: /* push current level pointers */ michael@0: stack2[0].start=start2; michael@0: stack2[0].s=s2; michael@0: stack2[0].limit=limit2; michael@0: ++level2; michael@0: michael@0: /* copy the folding result to fold2[] */ michael@0: if(length<=UCASE_MAX_STRING_LENGTH) { michael@0: u_memcpy(fold2, p, length); michael@0: } else { michael@0: int32_t i=0; michael@0: U16_APPEND_UNSAFE(fold2, i, length); michael@0: length=i; michael@0: } michael@0: michael@0: /* set next level pointers to case folding */ michael@0: start2=s2=fold2; michael@0: limit2=fold2+length; michael@0: michael@0: /* get ready to read from decomposition, continue with loop */ michael@0: c2=-1; michael@0: continue; michael@0: } michael@0: michael@0: if( level1<2 && (options&_COMPARE_EQUIV) && michael@0: 0!=(p=nfcImpl->getDecomposition((UChar32)cp1, decomp1, length)) michael@0: ) { michael@0: /* cp1 decomposes into p[length] */ michael@0: if(U_IS_SURROGATE(c1)) { michael@0: if(U_IS_SURROGATE_LEAD(c1)) { michael@0: /* advance beyond source surrogate pair if it decomposes */ michael@0: ++s1; michael@0: } else /* isTrail(c1) */ { michael@0: /* michael@0: * we got a supplementary code point when hitting its trail surrogate, michael@0: * therefore the lead surrogate must have been the same as in the other string; michael@0: * compare this decomposition with the lead surrogate in the other string michael@0: * remember that this simulates bulk text replacement: michael@0: * the decomposition would replace the entire code point michael@0: */ michael@0: --s2; michael@0: c2=*(s2-1); michael@0: } michael@0: } michael@0: michael@0: /* push current level pointers */ michael@0: stack1[level1].start=start1; michael@0: stack1[level1].s=s1; michael@0: stack1[level1].limit=limit1; michael@0: ++level1; michael@0: michael@0: /* set empty intermediate level if skipped */ michael@0: if(level1<2) { michael@0: stack1[level1++].start=NULL; michael@0: } michael@0: michael@0: /* set next level pointers to decomposition */ michael@0: start1=s1=p; michael@0: limit1=p+length; michael@0: michael@0: /* get ready to read from decomposition, continue with loop */ michael@0: c1=-1; michael@0: continue; michael@0: } michael@0: michael@0: if( level2<2 && (options&_COMPARE_EQUIV) && michael@0: 0!=(p=nfcImpl->getDecomposition((UChar32)cp2, decomp2, length)) michael@0: ) { michael@0: /* cp2 decomposes into p[length] */ michael@0: if(U_IS_SURROGATE(c2)) { michael@0: if(U_IS_SURROGATE_LEAD(c2)) { michael@0: /* advance beyond source surrogate pair if it decomposes */ michael@0: ++s2; michael@0: } else /* isTrail(c2) */ { michael@0: /* michael@0: * we got a supplementary code point when hitting its trail surrogate, michael@0: * therefore the lead surrogate must have been the same as in the other string; michael@0: * compare this decomposition with the lead surrogate in the other string michael@0: * remember that this simulates bulk text replacement: michael@0: * the decomposition would replace the entire code point michael@0: */ michael@0: --s1; michael@0: c1=*(s1-1); michael@0: } michael@0: } michael@0: michael@0: /* push current level pointers */ michael@0: stack2[level2].start=start2; michael@0: stack2[level2].s=s2; michael@0: stack2[level2].limit=limit2; michael@0: ++level2; michael@0: michael@0: /* set empty intermediate level if skipped */ michael@0: if(level2<2) { michael@0: stack2[level2++].start=NULL; michael@0: } michael@0: michael@0: /* set next level pointers to decomposition */ michael@0: start2=s2=p; michael@0: limit2=p+length; michael@0: michael@0: /* get ready to read from decomposition, continue with loop */ michael@0: c2=-1; michael@0: continue; michael@0: } michael@0: michael@0: /* michael@0: * no decomposition/case folding, max level for both sides: michael@0: * return difference result michael@0: * michael@0: * code point order comparison must not just return cp1-cp2 michael@0: * because when single surrogates are present then the surrogate pairs michael@0: * that formed cp1 and cp2 may be from different string indexes michael@0: * michael@0: * example: { d800 d800 dc01 } vs. { d800 dc00 }, compare at second code units michael@0: * c1=d800 cp1=10001 c2=dc00 cp2=10000 michael@0: * cp1-cp2>0 but c1-c2<0 and in fact in UTF-32 it is { d800 10001 } < { 10000 } michael@0: * michael@0: * therefore, use same fix-up as in ustring.c/uprv_strCompare() michael@0: * except: uprv_strCompare() fetches c=*s while this functions fetches c=*s++ michael@0: * so we have slightly different pointer/start/limit comparisons here michael@0: */ michael@0: michael@0: if(c1>=0xd800 && c2>=0xd800 && (options&U_COMPARE_CODE_POINT_ORDER)) { michael@0: /* subtract 0x2800 from BMP code points to make them smaller than supplementary ones */ michael@0: if( michael@0: (c1<=0xdbff && s1!=limit1 && U16_IS_TRAIL(*s1)) || michael@0: (U16_IS_TRAIL(c1) && start1!=(s1-1) && U16_IS_LEAD(*(s1-2))) michael@0: ) { michael@0: /* part of a surrogate pair, leave >=d800 */ michael@0: } else { michael@0: /* BMP code point - may be surrogate code point - make =d800 */ michael@0: } else { michael@0: /* BMP code point - may be surrogate code point - make spanQuickCheckYes(str, *pErrorCode); michael@0: if (U_FAILURE(*pErrorCode)) { michael@0: return FALSE; michael@0: } michael@0: /* michael@0: * ICU 2.4 had a further optimization: michael@0: * If both strings were not in FCD, then they were both NFD'ed, michael@0: * and the _COMPARE_EQUIV option was turned off. michael@0: * It is not entirely clear that this is valid with the current michael@0: * definition of the canonical caseless match. michael@0: * Therefore, ICU 2.6 removes that optimization. michael@0: */ michael@0: if(spanQCYesnormalizeSecondAndAppend(normalized, unnormalized, *pErrorCode); michael@0: if (U_SUCCESS(*pErrorCode)) { michael@0: return TRUE; michael@0: } michael@0: } michael@0: return FALSE; michael@0: } michael@0: michael@0: U_CAPI int32_t U_EXPORT2 michael@0: unorm_compare(const UChar *s1, int32_t length1, michael@0: const UChar *s2, int32_t length2, michael@0: uint32_t options, michael@0: UErrorCode *pErrorCode) { michael@0: /* argument checking */ michael@0: if(U_FAILURE(*pErrorCode)) { michael@0: return 0; michael@0: } michael@0: if(s1==0 || length1<-1 || s2==0 || length2<-1) { michael@0: *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; michael@0: return 0; michael@0: } michael@0: michael@0: UnicodeString fcd1, fcd2; michael@0: int32_t normOptions=(int32_t)(options>>UNORM_COMPARE_NORM_OPTIONS_SHIFT); michael@0: options|=_COMPARE_EQUIV; michael@0: michael@0: /* michael@0: * UAX #21 Case Mappings, as fixed for Unicode version 4 michael@0: * (see Jitterbug 2021), defines a canonical caseless match as michael@0: * michael@0: * A string X is a canonical caseless match michael@0: * for a string Y if and only if michael@0: * NFD(toCasefold(NFD(X))) = NFD(toCasefold(NFD(Y))) michael@0: * michael@0: * For better performance, we check for FCD (or let the caller tell us that michael@0: * both strings are in FCD) for the inner normalization. michael@0: * BasicNormalizerTest::FindFoldFCDExceptions() makes sure that michael@0: * case-folding preserves the FCD-ness of a string. michael@0: * The outer normalization is then only performed by unorm_cmpEquivFold() michael@0: * when there is a difference. michael@0: * michael@0: * Exception: When using the Turkic case-folding option, we do perform michael@0: * full NFD first. This is because in the Turkic case precomposed characters michael@0: * with 0049 capital I or 0069 small i fold differently whether they michael@0: * are first decomposed or not, so an FCD check - a check only for michael@0: * canonical order - is not sufficient. michael@0: */ michael@0: if(!(options&UNORM_INPUT_IS_FCD) || (options&U_FOLD_CASE_EXCLUDE_SPECIAL_I)) { michael@0: const Normalizer2 *n2; michael@0: if(options&U_FOLD_CASE_EXCLUDE_SPECIAL_I) { michael@0: n2=Normalizer2Factory::getNFDInstance(*pErrorCode); michael@0: } else { michael@0: n2=Normalizer2Factory::getFCDInstance(*pErrorCode); michael@0: } michael@0: if (U_FAILURE(*pErrorCode)) { michael@0: return 0; michael@0: } michael@0: michael@0: if(normOptions&UNORM_UNICODE_3_2) { michael@0: const UnicodeSet *uni32=uniset_getUnicode32Instance(*pErrorCode); michael@0: FilteredNormalizer2 fn2(*n2, *uni32); michael@0: if(_normalize(&fn2, s1, length1, fcd1, pErrorCode)) { michael@0: s1=fcd1.getBuffer(); michael@0: length1=fcd1.length(); michael@0: } michael@0: if(_normalize(&fn2, s2, length2, fcd2, pErrorCode)) { michael@0: s2=fcd2.getBuffer(); michael@0: length2=fcd2.length(); michael@0: } michael@0: } else { michael@0: if(_normalize(n2, s1, length1, fcd1, pErrorCode)) { michael@0: s1=fcd1.getBuffer(); michael@0: length1=fcd1.length(); michael@0: } michael@0: if(_normalize(n2, s2, length2, fcd2, pErrorCode)) { michael@0: s2=fcd2.getBuffer(); michael@0: length2=fcd2.length(); michael@0: } michael@0: } michael@0: } michael@0: michael@0: if(U_SUCCESS(*pErrorCode)) { michael@0: return unorm_cmpEquivFold(s1, length1, s2, length2, options, pErrorCode); michael@0: } else { michael@0: return 0; michael@0: } michael@0: } michael@0: michael@0: #endif /* #if !UCONFIG_NO_NORMALIZATION */