mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-13 08:53:20 +00:00
ICU-1897
Synching up comments and identical search function with Java X-SVN-Rev: 8636
This commit is contained in:
parent
2d1434b30f
commit
5e02c2eb16
4 changed files with 29 additions and 12 deletions
|
@ -22,7 +22,7 @@ U_NAMESPACE_BEGIN
|
|||
* in a {@link RuleBasedCollator} object.
|
||||
* StringSearch ensures that language eccentricity can be
|
||||
* handled, e.g. for the German collator, characters ß and SS will be matched
|
||||
* if case is chosen to be ignored.
|
||||
* if case is chosen to be ignored.
|
||||
* See the <a href=http://oss.software.ibm.com/icu/develop/collation/ICU_collation_design.htm>
|
||||
* "ICU Collation Design Document"</a> for more information.
|
||||
* <p>
|
||||
|
@ -107,10 +107,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());
|
||||
* }
|
||||
|
|
|
@ -111,9 +111,9 @@
|
|||
* UStringSearch *search = usearch_open(pattern, -1, target, -1, "en_US",
|
||||
* &status);
|
||||
* if (U_SUCCESS(status)) {
|
||||
* for (int pos = usearch_first(search);
|
||||
* for (int pos = usearch_first(search, &status);
|
||||
* pos != USEARCH_DONE;
|
||||
* pos = usearch_next(search)) {
|
||||
* pos = usearch_next(search, &status)) {
|
||||
* printf("Found match at %d pos, length is %d\n", pos,
|
||||
* usearch_getMatchLength(search));
|
||||
* }
|
||||
|
|
|
@ -861,12 +861,27 @@ inline UBool checkIdentical(const UStringSearch *strsrch, int32_t start,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
if (strsrch->pattern.textLength != length) {
|
||||
return FALSE;
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
int decomplength = unorm_decompose(NULL, -1,
|
||||
strsrch->search->text + start, length,
|
||||
FALSE, FALSE, &status);
|
||||
if (decomplength != unorm_decompose(NULL, -1, strsrch->pattern.text,
|
||||
strsrch->pattern.textLength, FALSE,
|
||||
FALSE, &status)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (uprv_memcmp(strsrch->pattern.text, strsrch->search->text + start,
|
||||
length * sizeof(UChar)) == 0);
|
||||
decomplength ++;
|
||||
UChar *text = (UChar *)uprv_malloc(decomplength * sizeof(UChar));
|
||||
UChar *pattern = (UChar *)uprv_malloc(decomplength * sizeof(UChar));
|
||||
unorm_decompose(text, decomplength, strsrch->search->text + start,
|
||||
length, FALSE, FALSE, &status);
|
||||
unorm_decompose(pattern, decomplength, strsrch->pattern.text,
|
||||
strsrch->pattern.textLength, FALSE, FALSE, &status);
|
||||
UBool result = (uprv_memcmp(pattern, text, decomplength * sizeof(UChar))
|
||||
== 0);
|
||||
uprv_free(text);
|
||||
uprv_free(pattern);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -81,6 +81,8 @@ static const SearchData STRENGTH[] = {
|
|||
{"A channel, another CHANNEL, more Channels, and one last channel...",
|
||||
"channel", "es", UCOL_PRIMARY, NULL, {2, 19, 33, 56, -1},
|
||||
{7, 7, 7, 7}},
|
||||
{"\\u00c0 should match but not A", "A\\u0300", "en", UCOL_IDENTICAL,
|
||||
NULL, {0, -1}, {1, 0}},
|
||||
{NULL, NULL, NULL, UCOL_TERTIARY, NULL, {-1}, {0}}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue