diff --git a/icu4c/source/i18n/unicode/search.h b/icu4c/source/i18n/unicode/search.h index af1d7bc25d..0b5a674a82 100644 --- a/icu4c/source/i18n/unicode/search.h +++ b/icu4c/source/i18n/unicode/search.h @@ -47,10 +47,10 @@ U_NAMESPACE_BEGIN * UnicodeString target("The quick brown fox jumped over the lazy fox"); * UnicodeString pattern("fox"); * - * SearchIterator *iter = new StringSearch(pattern, target); - * - * for (int pos = iter->first(); pos != USEARCH_DONE; - * pos = iter->next()) { + * SearchIterator *iter = new StringSearch(pattern, target); + * UErrorCode error = U_ZERO_ERROR; + * for (int pos = iter->first(error); pos != USEARCH_DONE; + * pos = iter->next(error)) { * printf("Found match at %d pos, length is %d\n", pos, * iter.getMatchLength()); * } diff --git a/icu4c/source/i18n/usearch.cpp b/icu4c/source/i18n/usearch.cpp index 7b6493b4f0..ce3af243b5 100644 --- a/icu4c/source/i18n/usearch.cpp +++ b/icu4c/source/i18n/usearch.cpp @@ -2447,9 +2447,6 @@ U_CAPI UStringSearch * U_EXPORT2 usearch_openFromCollator( result->collator = collator; result->strength = ucol_getStrength(collator); - result->toNormalize = ucol_getAttribute(collator, - UCOL_NORMALIZATION_MODE, - status) == UCOL_ON; result->ceMask = getMask(result->strength); result->toShift = ucol_getAttribute(collator, UCOL_ALTERNATE_HANDLING, status) == @@ -2694,6 +2691,10 @@ U_CAPI void U_EXPORT2 usearch_setText( UStringSearch *strsrch, strsrch->search->matchedIndex = USEARCH_DONE; strsrch->search->matchedLength = 0; strsrch->search->reset = TRUE; + if (strsrch->search->breakIter != NULL) { + ubrk_setText(strsrch->search->breakIter, text, + textlength, status); + } } } } @@ -2724,9 +2725,6 @@ U_CAPI void U_EXPORT2 usearch_setCollator( UStringSearch *strsrch, } strsrch->collator = collator; strsrch->strength = ucol_getStrength(collator); - strsrch->toNormalize = ucol_getAttribute(collator, - UCOL_NORMALIZATION_MODE, - status) == UCOL_ON; strsrch->ceMask = getMask(strsrch->strength); // if status is a failure, ucol_getAttribute returns UCOL_DEFAULT strsrch->toShift = @@ -2740,6 +2738,7 @@ U_CAPI void U_EXPORT2 usearch_setCollator( UStringSearch *strsrch, init_collIterate(collator, strsrch->search->text, strsrch->search->textLength, &(strsrch->textIter->iteratordata_)); + strsrch->utilIter->iteratordata_.coll = collator; } } } @@ -3036,9 +3035,6 @@ U_CAPI void U_EXPORT2 usearch_reset(UStringSearch *strsrch) uint32_t varTop; strsrch->strength = ucol_getStrength(strsrch->collator); - strsrch->toNormalize = ucol_getAttribute(strsrch->collator, - UCOL_NORMALIZATION_MODE, - &status) == UCOL_ON; ceMask = getMask(strsrch->strength); if (strsrch->ceMask != ceMask) { strsrch->ceMask = ceMask;