mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-07 22:44:49 +00:00
ICU-1229 deprecate UCOL_ constants in UNormalizationMode
X-SVN-Rev: 5893
This commit is contained in:
parent
bdd236186e
commit
88bce4404c
8 changed files with 66 additions and 77 deletions
|
@ -331,12 +331,11 @@ static void TestTertiary()
|
|||
rules=(UChar*)malloc(sizeof(UChar*) * (len+1));
|
||||
u_uastrcpy(rules, str);
|
||||
|
||||
myCollation=ucol_openRules(rules, len, UCOL_NO_NORMALIZATION, UCOL_DEFAULT_STRENGTH, NULL, &status);
|
||||
myCollation=ucol_openRules(rules, len, UCOL_OFF, UCOL_DEFAULT_STRENGTH, NULL, &status);
|
||||
if(U_FAILURE(status)){
|
||||
log_err("ERROR: in creation of rule based collator :%s\n", myErrorName(status));
|
||||
}
|
||||
|
||||
/* ucol_setNormalization(myCollation, UCOL_DEFAULT_NORMALIZATION); */
|
||||
ucol_setStrength(myCollation, UCOL_TERTIARY);
|
||||
for (i = 0; i < 17 ; i++)
|
||||
{
|
||||
|
@ -358,7 +357,7 @@ static void TestPrimary( )
|
|||
rules=(UChar*)malloc(sizeof(UChar*) * (len+1));
|
||||
u_uastrcpy(rules, str);
|
||||
|
||||
myCollation=ucol_openRules(rules, len, UCOL_NO_NORMALIZATION, UCOL_DEFAULT_STRENGTH,NULL, &status);
|
||||
myCollation=ucol_openRules(rules, len, UCOL_OFF, UCOL_DEFAULT_STRENGTH,NULL, &status);
|
||||
if(U_FAILURE(status)){
|
||||
log_err("ERROR: in creation of rule based collator :%s\n", myErrorName(status));
|
||||
}
|
||||
|
@ -386,7 +385,7 @@ static void TestSecondary()
|
|||
rules=(UChar*)malloc(sizeof(UChar*) * (len+1));
|
||||
u_uastrcpy(rules, str);
|
||||
|
||||
myCollation=ucol_openRules(rules, len, UCOL_NO_NORMALIZATION, UCOL_DEFAULT_STRENGTH,NULL, &status);
|
||||
myCollation=ucol_openRules(rules, len, UCOL_OFF, UCOL_DEFAULT_STRENGTH,NULL, &status);
|
||||
if(U_FAILURE(status)){
|
||||
log_err("ERROR: in creation of rule based collator :%s\n", myErrorName(status));
|
||||
}
|
||||
|
@ -412,7 +411,7 @@ static void TestIdentical()
|
|||
rules=(UChar*)malloc(sizeof(UChar*) * (len+1));
|
||||
u_uastrcpy(rules, str);
|
||||
|
||||
myCollation=ucol_openRules(rules, len, UCOL_NO_NORMALIZATION, UCOL_IDENTICAL, NULL,&status);
|
||||
myCollation=ucol_openRules(rules, len, UCOL_OFF, UCOL_IDENTICAL, NULL,&status);
|
||||
if(U_FAILURE(status)){
|
||||
log_err("ERROR: in creation of rule based collator :%s\n", myErrorName(status));
|
||||
}
|
||||
|
@ -437,11 +436,10 @@ static void TestExtra()
|
|||
rules=(UChar*)malloc(sizeof(UChar*) * (len+1));
|
||||
u_uastrcpy(rules, str);
|
||||
|
||||
myCollation=ucol_openRules(rules, len, UCOL_NO_NORMALIZATION, UCOL_DEFAULT_STRENGTH,NULL, &status);
|
||||
myCollation=ucol_openRules(rules, len, UCOL_OFF, UCOL_DEFAULT_STRENGTH,NULL, &status);
|
||||
if(U_FAILURE(status)){
|
||||
log_err("ERROR: in creation of rule based collator :%s\n", myErrorName(status));
|
||||
}
|
||||
ucol_setNormalization(myCollation, UCOL_DEFAULT_NORMALIZATION);
|
||||
ucol_setStrength(myCollation, UCOL_TERTIARY);
|
||||
for (i = 0; i < COUNT_TEST_CASES-1 ; i++)
|
||||
{
|
||||
|
@ -531,7 +529,7 @@ static void TestVariableTop(void)
|
|||
u_uastrcpy(rules, str);
|
||||
|
||||
enCollation = ucol_open("en_US", &status);
|
||||
myCollation = ucol_openRules(rules, len, UCOL_NO_NORMALIZATION,
|
||||
myCollation = ucol_openRules(rules, len, UCOL_OFF,
|
||||
UCOL_PRIMARY,NULL, &status);
|
||||
if (U_FAILURE(status)) {
|
||||
log_err("ERROR: in creation of rule based collator :%s\n",
|
||||
|
@ -606,7 +604,7 @@ static void TestSurrogates(void)
|
|||
rlen = u_unescape(str, rules, len);
|
||||
|
||||
enCollation = ucol_open("en_US", &status);
|
||||
myCollation = ucol_openRules(rules, rlen - 1, UCOL_NO_NORMALIZATION,
|
||||
myCollation = ucol_openRules(rules, rlen - 1, UCOL_OFF,
|
||||
UCOL_TERTIARY,NULL, &status);
|
||||
if (U_FAILURE(status)) {
|
||||
log_err("ERROR: in creation of rule based collator :%s\n",
|
||||
|
@ -684,7 +682,7 @@ TestInvalidRules(){
|
|||
u_memset(parseError.preContext,0x0000,U_PARSE_CONTEXT_LEN);
|
||||
u_memset(parseError.postContext,0x0000,U_PARSE_CONTEXT_LEN);
|
||||
/* open the rules and test */
|
||||
coll = ucol_openRules(rules,u_strlen(rules),UCOL_NO_NORMALIZATION,UCOL_DEFAULT_STRENGTH,&parseError,&status);
|
||||
coll = ucol_openRules(rules,u_strlen(rules),UCOL_OFF,UCOL_DEFAULT_STRENGTH,&parseError,&status);
|
||||
if(u_strcmp(parseError.preContext,preContextExp)!=0){
|
||||
log_err("preContext in UParseError for ucol_openRules does not match\n");
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ static void TestTertiary( )
|
|||
return;
|
||||
}
|
||||
log_verbose("Testing German Collation with Tertiary strength\n");
|
||||
ucol_setNormalization(myCollation, UCOL_DECOMP_CAN_COMP_COMPAT);
|
||||
ucol_setNormalization(myCollation, UNORM_NFC);
|
||||
ucol_setStrength(myCollation, UCOL_TERTIARY);
|
||||
for (i = 0; i < 12 ; i++)
|
||||
{
|
||||
|
@ -124,7 +124,6 @@ static void TestPrimary()
|
|||
return;
|
||||
}
|
||||
log_verbose("Testing German Collation with primary strength\n");
|
||||
ucol_setNormalization(myCollation, UCOL_DEFAULT_NORMALIZATION);
|
||||
ucol_setStrength(myCollation, UCOL_PRIMARY);
|
||||
for (i = 0; i < 12 ; i++)
|
||||
{
|
||||
|
|
|
@ -152,7 +152,7 @@ static void TestG7Locales()
|
|||
|
||||
defRules = ucol_getRules(myCollation, &rlen);
|
||||
status = U_ZERO_ERROR;
|
||||
tblColl1 = ucol_openRules(defRules, rlen, UCOL_NO_NORMALIZATION,
|
||||
tblColl1 = ucol_openRules(defRules, rlen, UCOL_OFF,
|
||||
UCOL_DEFAULT_STRENGTH,NULL, &status);
|
||||
if (U_FAILURE(status))
|
||||
{
|
||||
|
@ -192,8 +192,7 @@ static void TestDemo1()
|
|||
|
||||
log_verbose("Demo Test 1 : Create a new table collation with rules \" & Z < p, P \" \n");
|
||||
|
||||
myCollation = ucol_openRules(temp, len, UCOL_NO_NORMALIZATION,
|
||||
UCOL_DEFAULT_STRENGTH,NULL, &status);
|
||||
myCollation = ucol_openRules(temp, len, UCOL_OFF, UCOL_DEFAULT_STRENGTH,NULL, &status);
|
||||
|
||||
if (U_FAILURE(status))
|
||||
{
|
||||
|
@ -225,8 +224,7 @@ static void TestDemo2()
|
|||
|
||||
log_verbose("Demo Test 2 : Create a new table collation with rules \"& C < ch , cH, Ch, CH\"");
|
||||
|
||||
myCollation = ucol_openRules(temp, len, UCOL_NO_NORMALIZATION,
|
||||
UCOL_DEFAULT_STRENGTH, NULL, &status);
|
||||
myCollation = ucol_openRules(temp, len, UCOL_OFF, UCOL_DEFAULT_STRENGTH, NULL, &status);
|
||||
|
||||
if (U_FAILURE(status))
|
||||
{
|
||||
|
@ -256,8 +254,7 @@ static void TestDemo3()
|
|||
|
||||
log_verbose("Demo Test 3 : Create a new table collation with rules \"& Question'-'mark ; '?' & Hash'-'mark ; '#' & Ampersand ; '&'\" \n");
|
||||
|
||||
myCollation = ucol_openRules(temp, len, UCOL_NO_NORMALIZATION,
|
||||
UCOL_DEFAULT_STRENGTH, NULL, &status);
|
||||
myCollation = ucol_openRules(temp, len, UCOL_OFF, UCOL_DEFAULT_STRENGTH, NULL, &status);
|
||||
|
||||
if (U_FAILURE(status))
|
||||
{
|
||||
|
@ -288,8 +285,7 @@ static void TestDemo4()
|
|||
|
||||
log_verbose("Demo Test 4 : Create a new table collation with rules \" & aa ; a'-' & ee ; e'-' & ii ; i'-' & oo ; o'-' & uu ; u'-' \"\n");
|
||||
|
||||
myCollation = ucol_openRules(temp, len, UCOL_NO_NORMALIZATION,
|
||||
UCOL_DEFAULT_STRENGTH, NULL, &status);
|
||||
myCollation = ucol_openRules(temp, len, UCOL_OFF, UCOL_DEFAULT_STRENGTH, NULL, &status);
|
||||
|
||||
if (U_FAILURE(status))
|
||||
{
|
||||
|
|
|
@ -361,7 +361,7 @@ static void TestNormalization()
|
|||
UChar source[10];
|
||||
UCollationElements *iter;
|
||||
|
||||
coll = ucol_openRules(rule, rulelen, UNORM_NFD, UCOL_TERTIARY, NULL, &status);
|
||||
coll = ucol_openRules(rule, rulelen, UCOL_ON, UCOL_TERTIARY, NULL, &status);
|
||||
ucol_setAttribute(coll, UCOL_NORMALIZATION_MODE, UCOL_ON, &status);
|
||||
if (U_FAILURE(status)){
|
||||
log_err("ERROR: in creation of collator using ucol_openRules()\n %s\n",
|
||||
|
@ -441,7 +441,7 @@ static void TestPrevious()
|
|||
|
||||
/* Test with a contracting character sequence */
|
||||
u_uastrcpy(rule, "&a,A < b,B < c,C, d,D < z,Z < ch,cH,Ch,CH");
|
||||
c1 = ucol_openRules(rule, u_strlen(rule), UCOL_NO_NORMALIZATION, UCOL_DEFAULT_STRENGTH, NULL, &status);
|
||||
c1 = ucol_openRules(rule, u_strlen(rule), UCOL_OFF, UCOL_DEFAULT_STRENGTH, NULL, &status);
|
||||
|
||||
log_verbose("Contraction rule testing back and forth with no normalization\n");
|
||||
|
||||
|
@ -465,7 +465,7 @@ static void TestPrevious()
|
|||
|
||||
/* Test with an expanding character sequence */
|
||||
u_uastrcpy(rule, "&a < b < c/abd < d");
|
||||
c2 = ucol_openRules(rule, u_strlen(rule), UCOL_NO_NORMALIZATION, UCOL_DEFAULT_STRENGTH, NULL, &status);
|
||||
c2 = ucol_openRules(rule, u_strlen(rule), UCOL_OFF, UCOL_DEFAULT_STRENGTH, NULL, &status);
|
||||
log_verbose("Expansion rule testing back and forth with no normalization\n");
|
||||
if (c2 == NULL || U_FAILURE(status))
|
||||
{
|
||||
|
@ -485,7 +485,7 @@ static void TestPrevious()
|
|||
ucol_close(c2);
|
||||
/* Now try both */
|
||||
u_uastrcpy(rule, "&a < b < c/aba < d < z < ch");
|
||||
c3 = ucol_openRules(rule, u_strlen(rule), UCOL_DEFAULT_NORMALIZATION, UCOL_DEFAULT_STRENGTH,NULL, &status);
|
||||
c3 = ucol_openRules(rule, u_strlen(rule), UCOL_DEFAULT, UCOL_DEFAULT_STRENGTH,NULL, &status);
|
||||
log_verbose("Expansion/contraction rule testing back and forth with no normalization\n");
|
||||
|
||||
if (c3 == NULL || U_FAILURE(status))
|
||||
|
@ -834,7 +834,7 @@ static void TestMaxExpansion()
|
|||
|
||||
UChar rule[256];
|
||||
u_uastrcpy(rule, "&a < ab < c/aba < d < z < ch");
|
||||
coll = ucol_openRules(rule, u_strlen(rule), UCOL_DEFAULT_NORMALIZATION,
|
||||
coll = ucol_openRules(rule, u_strlen(rule), UCOL_DEFAULT,
|
||||
UCOL_DEFAULT_STRENGTH,NULL, &status);
|
||||
iter = ucol_openElements(coll, &ch, 1, &status);
|
||||
|
||||
|
@ -930,7 +930,7 @@ static void TestMaxExpansion()
|
|||
rule[8] = 0x71;
|
||||
rule[9] = 0;
|
||||
|
||||
coll = ucol_openRules(rule, u_strlen(rule), UCOL_DEFAULT_NORMALIZATION,
|
||||
coll = ucol_openRules(rule, u_strlen(rule), UCOL_DEFAULT,
|
||||
UCOL_DEFAULT_STRENGTH,NULL, &status);
|
||||
iter = ucol_openElements(coll, &ch, 1, &status);
|
||||
|
||||
|
@ -1438,8 +1438,7 @@ static void TestDiscontiguos() {
|
|||
UCollationElements *iter;
|
||||
UCollationElements *resultiter;
|
||||
|
||||
coll = ucol_openRules(rule, rulelen, UCOL_NO_NORMALIZATION,
|
||||
UCOL_DEFAULT_STRENGTH,NULL, &status);
|
||||
coll = ucol_openRules(rule, rulelen, UCOL_OFF, UCOL_DEFAULT_STRENGTH,NULL, &status);
|
||||
iter = ucol_openElements(coll, rule, 1, &status);
|
||||
resultiter = ucol_openElements(coll, rule, 1, &status);
|
||||
|
||||
|
@ -1512,8 +1511,7 @@ static void TestCEBufferOverflow()
|
|||
UCollationElements *iter;
|
||||
|
||||
u_uastrcpy(rule, "&z < AB");
|
||||
coll = ucol_openRules(rule, u_strlen(rule), UCOL_NO_NORMALIZATION,
|
||||
UCOL_DEFAULT_STRENGTH, NULL,&status);
|
||||
coll = ucol_openRules(rule, u_strlen(rule), UCOL_OFF, UCOL_DEFAULT_STRENGTH, NULL,&status);
|
||||
if (U_FAILURE(status)) {
|
||||
log_err("Rule based collator not created for testing ce buffer overflow\n");
|
||||
}
|
||||
|
|
|
@ -118,13 +118,13 @@ void TestDecomp()
|
|||
for(x=0; x < ARRAY_LENGTH(canonTests); x++)
|
||||
{
|
||||
source=CharsToUChars(canonTests[x][0]);
|
||||
neededLen= unorm_normalize(source, u_strlen(source), UCOL_DECOMP_CAN, UCOL_IGNORE_HANGUL, NULL, 0, &status);
|
||||
neededLen= unorm_normalize(source, u_strlen(source), UNORM_NFD, UCOL_IGNORE_HANGUL, NULL, 0, &status);
|
||||
if(status==U_BUFFER_OVERFLOW_ERROR)
|
||||
{
|
||||
status=U_ZERO_ERROR;
|
||||
resLen=neededLen+1;
|
||||
result=(UChar*)malloc(sizeof(UChar*) * resLen);
|
||||
unorm_normalize(source, u_strlen(source), UCOL_DECOMP_CAN, UCOL_IGNORE_HANGUL, result, resLen, &status);
|
||||
unorm_normalize(source, u_strlen(source), UNORM_NFD, UCOL_IGNORE_HANGUL, result, resLen, &status);
|
||||
}
|
||||
if(U_FAILURE(status)){
|
||||
log_err("ERROR in unorm_normalize at %s: %s\n", austrdup(source), myErrorName(status) );
|
||||
|
@ -152,13 +152,13 @@ void TestCompatDecomp()
|
|||
for(x=0; x < ARRAY_LENGTH(compatTests); x++)
|
||||
{
|
||||
source=CharsToUChars(compatTests[x][0]);
|
||||
neededLen= unorm_normalize(source, u_strlen(source), UCOL_DECOMP_COMPAT, UCOL_IGNORE_HANGUL, NULL, 0, &status);
|
||||
neededLen= unorm_normalize(source, u_strlen(source), UNORM_NFKD, UCOL_IGNORE_HANGUL, NULL, 0, &status);
|
||||
if(status==U_BUFFER_OVERFLOW_ERROR)
|
||||
{
|
||||
status=U_ZERO_ERROR;
|
||||
resLen=neededLen+1;
|
||||
result=(UChar*)malloc(sizeof(UChar*) * resLen);
|
||||
unorm_normalize(source, u_strlen(source), UCOL_DECOMP_COMPAT,UCOL_IGNORE_HANGUL, result, resLen, &status);
|
||||
unorm_normalize(source, u_strlen(source), UNORM_NFKD,UCOL_IGNORE_HANGUL, result, resLen, &status);
|
||||
}
|
||||
if(U_FAILURE(status)){
|
||||
log_err("ERROR in unorm_normalize at %s: %s\n", austrdup(source), myErrorName(status) );
|
||||
|
@ -186,13 +186,13 @@ void TestCanonDecompCompose()
|
|||
for(x=0; x < ARRAY_LENGTH(canonTests); x++)
|
||||
{
|
||||
source=CharsToUChars(canonTests[x][0]);
|
||||
neededLen= unorm_normalize(source, u_strlen(source), UCOL_DECOMP_CAN_COMP_COMPAT, UCOL_IGNORE_HANGUL, NULL, 0, &status);
|
||||
neededLen= unorm_normalize(source, u_strlen(source), UNORM_NFC, UCOL_IGNORE_HANGUL, NULL, 0, &status);
|
||||
if(status==U_BUFFER_OVERFLOW_ERROR)
|
||||
{
|
||||
status=U_ZERO_ERROR;
|
||||
resLen=neededLen+1;
|
||||
result=(UChar*)malloc(sizeof(UChar*) * resLen);
|
||||
unorm_normalize(source, u_strlen(source), UCOL_DECOMP_CAN_COMP_COMPAT, UCOL_IGNORE_HANGUL, result, resLen, &status);
|
||||
unorm_normalize(source, u_strlen(source), UNORM_NFC, UCOL_IGNORE_HANGUL, result, resLen, &status);
|
||||
}
|
||||
if(U_FAILURE(status)){
|
||||
log_err("ERROR in unorm_normalize at %s: %s\n", austrdup(source),myErrorName(status) );
|
||||
|
@ -220,13 +220,13 @@ void TestCompatDecompCompose()
|
|||
for(x=0; x < ARRAY_LENGTH(compatTests); x++)
|
||||
{
|
||||
source=CharsToUChars(compatTests[x][0]);
|
||||
neededLen= unorm_normalize(source, u_strlen(source), UCOL_DECOMP_COMPAT_COMP_CAN, UCOL_IGNORE_HANGUL, NULL, 0, &status);
|
||||
neededLen= unorm_normalize(source, u_strlen(source), UNORM_NFKC, UCOL_IGNORE_HANGUL, NULL, 0, &status);
|
||||
if(status==U_BUFFER_OVERFLOW_ERROR)
|
||||
{
|
||||
status=U_ZERO_ERROR;
|
||||
resLen=neededLen+1;
|
||||
result=(UChar*)malloc(sizeof(UChar*) * resLen);
|
||||
unorm_normalize(source, u_strlen(source), UCOL_DECOMP_COMPAT_COMP_CAN, UCOL_IGNORE_HANGUL, result, resLen, &status);
|
||||
unorm_normalize(source, u_strlen(source), UNORM_NFKC, UCOL_IGNORE_HANGUL, result, resLen, &status);
|
||||
}
|
||||
if(U_FAILURE(status)){
|
||||
log_err("ERROR in unorm_normalize at %s: %s\n", austrdup(source), myErrorName(status) );
|
||||
|
@ -319,22 +319,22 @@ void TestNull()
|
|||
source_comp_len,
|
||||
expect_comp,
|
||||
expect_comp_len,
|
||||
UCOL_DECOMP_CAN_COMP_COMPAT,
|
||||
"UCOL_DECOMP_CAN_COMP_COMPAT");
|
||||
UNORM_NFC,
|
||||
"UNORM_NFC");
|
||||
|
||||
TestNull_check(source_dcmp,
|
||||
source_dcmp_len,
|
||||
expect_dcmp,
|
||||
expect_dcmp_len,
|
||||
UCOL_DECOMP_CAN,
|
||||
"UCOL_DECOMP_CAN");
|
||||
UNORM_NFD,
|
||||
"UNORM_NFD");
|
||||
|
||||
TestNull_check(source_comp,
|
||||
source_comp_len,
|
||||
expect_comp,
|
||||
expect_comp_len,
|
||||
UCOL_DECOMP_COMPAT_COMP_CAN,
|
||||
"UCOL_DECOMP_COMPAT_COMP_CAN");
|
||||
UNORM_NFKC,
|
||||
"UNORM_NFKC");
|
||||
|
||||
|
||||
}
|
||||
|
@ -358,25 +358,25 @@ static void TestQuickCheckResultNO()
|
|||
|
||||
for (; count < SIZE; count ++)
|
||||
{
|
||||
if (unorm_quickCheck(&(CPNFD[count]), 1, UCOL_DECOMP_CAN, &error) !=
|
||||
if (unorm_quickCheck(&(CPNFD[count]), 1, UNORM_NFD, &error) !=
|
||||
UNORM_NO)
|
||||
{
|
||||
log_err("ERROR in NFD quick check at U+%04x\n", CPNFD[count]);
|
||||
return;
|
||||
}
|
||||
if (unorm_quickCheck(&(CPNFC[count]), 1, UCOL_DECOMP_CAN_COMP_COMPAT, &error) !=
|
||||
if (unorm_quickCheck(&(CPNFC[count]), 1, UNORM_NFC, &error) !=
|
||||
UNORM_NO)
|
||||
{
|
||||
log_err("ERROR in NFC quick check at U+%04x\n", CPNFC[count]);
|
||||
return;
|
||||
}
|
||||
if (unorm_quickCheck(&(CPNFKD[count]), 1, UCOL_DECOMP_COMPAT, &error) !=
|
||||
if (unorm_quickCheck(&(CPNFKD[count]), 1, UNORM_NFKD, &error) !=
|
||||
UNORM_NO)
|
||||
{
|
||||
log_err("ERROR in NFKD quick check at U+%04x\n", CPNFKD[count]);
|
||||
return;
|
||||
}
|
||||
if (unorm_quickCheck(&(CPNFKC[count]), 1, UCOL_DECOMP_COMPAT_COMP_CAN, &error) !=
|
||||
if (unorm_quickCheck(&(CPNFKC[count]), 1, UNORM_NFKC, &error) !=
|
||||
UNORM_NO)
|
||||
{
|
||||
log_err("ERROR in NFKC quick check at U+%04x\n", CPNFKC[count]);
|
||||
|
@ -404,23 +404,23 @@ static void TestQuickCheckResultYES()
|
|||
UChar cp = 0;
|
||||
while (cp < 0xA0)
|
||||
{
|
||||
if (unorm_quickCheck(&cp, 1, UCOL_DECOMP_CAN, &error) != UNORM_YES)
|
||||
if (unorm_quickCheck(&cp, 1, UNORM_NFD, &error) != UNORM_YES)
|
||||
{
|
||||
log_err("ERROR in NFD quick check at U+%04x\n", cp);
|
||||
return;
|
||||
}
|
||||
if (unorm_quickCheck(&cp, 1, UCOL_DECOMP_CAN_COMP_COMPAT, &error) !=
|
||||
if (unorm_quickCheck(&cp, 1, UNORM_NFC, &error) !=
|
||||
UNORM_YES)
|
||||
{
|
||||
log_err("ERROR in NFC quick check at U+%04x\n", cp);
|
||||
return;
|
||||
}
|
||||
if (unorm_quickCheck(&cp, 1, UCOL_DECOMP_COMPAT, &error) != UNORM_YES)
|
||||
if (unorm_quickCheck(&cp, 1, UNORM_NFKD, &error) != UNORM_YES)
|
||||
{
|
||||
log_err("ERROR in NFKD quick check at U+%04x\n", cp);
|
||||
return;
|
||||
}
|
||||
if (unorm_quickCheck(&cp, 1, UCOL_DECOMP_COMPAT_COMP_CAN, &error) !=
|
||||
if (unorm_quickCheck(&cp, 1, UNORM_NFKC, &error) !=
|
||||
UNORM_YES)
|
||||
{
|
||||
log_err("ERROR in NFKC quick check at U+%04x\n", cp);
|
||||
|
@ -431,25 +431,25 @@ static void TestQuickCheckResultYES()
|
|||
|
||||
for (; count < SIZE; count ++)
|
||||
{
|
||||
if (unorm_quickCheck(&(CPNFD[count]), 1, UCOL_DECOMP_CAN, &error) !=
|
||||
if (unorm_quickCheck(&(CPNFD[count]), 1, UNORM_NFD, &error) !=
|
||||
UNORM_YES)
|
||||
{
|
||||
log_err("ERROR in NFD quick check at U+%04x\n", CPNFD[count]);
|
||||
return;
|
||||
}
|
||||
if (unorm_quickCheck(&(CPNFC[count]), 1, UCOL_DECOMP_CAN_COMP_COMPAT, &error)
|
||||
if (unorm_quickCheck(&(CPNFC[count]), 1, UNORM_NFC, &error)
|
||||
!= UNORM_YES)
|
||||
{
|
||||
log_err("ERROR in NFC quick check at U+%04x\n", CPNFC[count]);
|
||||
return;
|
||||
}
|
||||
if (unorm_quickCheck(&(CPNFKD[count]), 1, UCOL_DECOMP_COMPAT, &error) !=
|
||||
if (unorm_quickCheck(&(CPNFKD[count]), 1, UNORM_NFKD, &error) !=
|
||||
UNORM_YES)
|
||||
{
|
||||
log_err("ERROR in NFKD quick check at U+%04x\n", CPNFKD[count]);
|
||||
return;
|
||||
}
|
||||
if (unorm_quickCheck(&(CPNFKC[count]), 1, UCOL_DECOMP_COMPAT_COMP_CAN, &error) !=
|
||||
if (unorm_quickCheck(&(CPNFKC[count]), 1, UNORM_NFKC, &error) !=
|
||||
UNORM_YES)
|
||||
{
|
||||
log_err("ERROR in NFKC quick check at U+%04x\n", CPNFKC[count]);
|
||||
|
@ -474,13 +474,13 @@ static void TestQuickCheckResultMAYBE()
|
|||
/* NFD and NFKD does not have any MAYBE codepoints */
|
||||
for (; count < SIZE; count ++)
|
||||
{
|
||||
if (unorm_quickCheck(&(CPNFC[count]), 1, UCOL_DECOMP_CAN_COMP_COMPAT, &error) !=
|
||||
if (unorm_quickCheck(&(CPNFC[count]), 1, UNORM_NFC, &error) !=
|
||||
UNORM_MAYBE)
|
||||
{
|
||||
log_err("ERROR in NFC quick check at U+%04x\n", CPNFC[count]);
|
||||
return;
|
||||
}
|
||||
if (unorm_quickCheck(&(CPNFKC[count]), 1, UCOL_DECOMP_COMPAT_COMP_CAN, &error) !=
|
||||
if (unorm_quickCheck(&(CPNFKC[count]), 1, UNORM_NFKC, &error) !=
|
||||
UNORM_MAYBE)
|
||||
{
|
||||
log_err("ERROR in NFKC quick check at U+%04x\n", CPNFKC[count]);
|
||||
|
@ -500,14 +500,14 @@ static void TestQuickCheckStringResult()
|
|||
{
|
||||
d = CharsToUChars(canonTests[count][1]);
|
||||
c = CharsToUChars(canonTests[count][2]);
|
||||
if (unorm_quickCheck(d, u_strlen(d), UCOL_DECOMP_CAN, &error) !=
|
||||
if (unorm_quickCheck(d, u_strlen(d), UNORM_NFD, &error) !=
|
||||
UNORM_YES)
|
||||
{
|
||||
log_err("ERROR in NFD quick check for string at count %d\n", count);
|
||||
return;
|
||||
}
|
||||
|
||||
if (unorm_quickCheck(c, u_strlen(c), UCOL_DECOMP_CAN_COMP_COMPAT, &error) ==
|
||||
if (unorm_quickCheck(c, u_strlen(c), UNORM_NFC, &error) ==
|
||||
UNORM_NO)
|
||||
{
|
||||
log_err("ERROR in NFC quick check for string at count %d\n", count);
|
||||
|
@ -522,14 +522,14 @@ static void TestQuickCheckStringResult()
|
|||
{
|
||||
d = CharsToUChars(compatTests[count][1]);
|
||||
c = CharsToUChars(compatTests[count][2]);
|
||||
if (unorm_quickCheck(d, u_strlen(d), UCOL_DECOMP_COMPAT, &error) !=
|
||||
if (unorm_quickCheck(d, u_strlen(d), UNORM_NFKD, &error) !=
|
||||
UNORM_YES)
|
||||
{
|
||||
log_err("ERROR in NFKD quick check for string at count %d\n", count);
|
||||
return;
|
||||
}
|
||||
|
||||
if (unorm_quickCheck(c, u_strlen(c), UCOL_DECOMP_COMPAT_COMP_CAN, &error) !=
|
||||
if (unorm_quickCheck(c, u_strlen(c), UNORM_NFKC, &error) !=
|
||||
UNORM_YES)
|
||||
{
|
||||
log_err("ERROR in NFKC quick check for string at count %d\n", count);
|
||||
|
@ -622,7 +622,7 @@ void TestCheckFCD()
|
|||
while (size != 19) {
|
||||
data[size] = datachar[(rand() * 50) / RAND_MAX];
|
||||
log_verbose("0x%x", data[size]);
|
||||
normsize += unorm_normalize(data + size, 1, UCOL_DECOMP_CAN, UCOL_IGNORE_HANGUL,
|
||||
normsize += unorm_normalize(data + size, 1, UNORM_NFD, UCOL_IGNORE_HANGUL,
|
||||
norm + normsize, 100 - normsize, &status);
|
||||
if (U_FAILURE(status)) {
|
||||
log_err("unorm_quickCheck(FCD) failed: exception occured at data generation\n");
|
||||
|
@ -632,7 +632,7 @@ void TestCheckFCD()
|
|||
}
|
||||
log_verbose("\n");
|
||||
|
||||
nfdsize = unorm_normalize(data, size, UCOL_DECOMP_CAN, UCOL_IGNORE_HANGUL,
|
||||
nfdsize = unorm_normalize(data, size, UNORM_NFD, UCOL_IGNORE_HANGUL,
|
||||
nfd, 100, &status);
|
||||
if (U_FAILURE(status)) {
|
||||
log_err("unorm_quickCheck(FCD) failed: exception occured at normalized data generation\n");
|
||||
|
|
|
@ -1389,7 +1389,7 @@ UCollator *openRulesCollator() {
|
|||
buf[i] = 0;
|
||||
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
UCollator *coll = ucol_openRules(buf, u_strlen(buf), UCOL_NO_NORMALIZATION,
|
||||
UCollator *coll = ucol_openRules(buf, u_strlen(buf), UCOL_OFF,
|
||||
UCOL_DEFAULT_STRENGTH, NULL, &status);
|
||||
if (U_FAILURE(status)) {
|
||||
fprintf(stderr, "ICU ucol_openRules() open failed.: %d\n", status);
|
||||
|
|
|
@ -66,7 +66,7 @@ static UColAttributeValue ATTRIBUTE_[UCOL_ATTRIBUTE_COUNT] = {
|
|||
UCOL_DEFAULT
|
||||
};
|
||||
|
||||
static UNormalizationMode NORMALIZATION_ = UCOL_DEFAULT_NORMALIZATION;
|
||||
static UColAttributeValue NORMALIZATION_ = UCOL_DEFAULT;
|
||||
|
||||
typedef struct {
|
||||
int value;
|
||||
|
@ -101,13 +101,11 @@ static const EnumNameValuePair ATTRIBUTE_VALUE_[] = {
|
|||
};
|
||||
|
||||
static const EnumNameValuePair NORMALIZATION_VALUE_[] = {
|
||||
{UCOL_NO_NORMALIZATION, "UCOL_NO_NORMALIZATION|UNORM_NONE"},
|
||||
{UCOL_DECOMP_CAN, "UCOL_DECOMP_CAN|UNORM_NFD"},
|
||||
{UCOL_DECOMP_COMPAT,
|
||||
"UCOL_DECOMP_COMPAT|UNORM_NFKD|UCOL_DEFAULT_NORMALIZATION"},
|
||||
{UCOL_DECOMP_CAN_COMP_COMPAT,
|
||||
"UCOL_DECOMP_CAN_COMP_COMPAT|UNORM_DEFAULT|UNORM_NFC"},
|
||||
{UCOL_DECOMP_COMPAT_COMP_CAN, "UCOL_DECOMP_COMPAT_COMP_CAN|UNORM_NFKC"},
|
||||
{UNORM_NONE, "UNORM_NONE"},
|
||||
{UNORM_NFD, "UNORM_NFD"},
|
||||
{UNORM_NFKD, "UNORM_NFKD"},
|
||||
{UNORM_NFC, "UNORM_NFC|UNORM_DEFAULT"},
|
||||
{UNORM_NFKC, "UNORM_NFKC"},
|
||||
NULL
|
||||
};
|
||||
|
||||
|
@ -451,7 +449,7 @@ void setAttributes(UCollator *collator, UErrorCode *error)
|
|||
*/
|
||||
void setNormalization(UCollator *collator)
|
||||
{
|
||||
if (NORMALIZATION_ != UCOL_DEFAULT_NORMALIZATION) {
|
||||
if (NORMALIZATION_ != UCOL_DEFAULT) {
|
||||
ucol_setNormalization(collator, NORMALIZATION_);
|
||||
}
|
||||
}
|
||||
|
@ -732,7 +730,7 @@ void parseNormalization() {
|
|||
fprintf(stdout, "Normalization mode not found: %s\n", str);
|
||||
return;
|
||||
}
|
||||
NORMALIZATION_ = (UNormalizationMode)norm;
|
||||
NORMALIZATION_ = (UColAttributeValue)norm;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -559,7 +559,7 @@ parseCollationElements(char *tag, uint32_t startline, UErrorCode *status)
|
|||
UChar *rules = NULL;
|
||||
UParseError parseError;
|
||||
coll = ucol_openRules(tokenValue->fChars, tokenValue->fLength,
|
||||
UNORM_NONE, UCOL_DEFAULT_STRENGTH,&parseError, &intStatus);
|
||||
UCOL_OFF, UCOL_DEFAULT_STRENGTH,&parseError, &intStatus);
|
||||
|
||||
if (U_SUCCESS(intStatus) && coll != NULL)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue