Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ public static IEnumerable<object[]> IsPrefix_TestData()
else
{
yield return new object[] { s_hungarianCompare, "dzsdzsfoobar", "ddzsf", CompareOptions.None, false, 0 };
// Bug in ICU (non-Apple) implementation, correct result should be true (https://github.com/dotnet/runtime/issues/118521)
yield return new object[] { s_invariantCompare, "''Tests", "Tests", CompareOptions.IgnoreSymbols, PlatformDetection.IsHybridGlobalizationOnApplePlatform ? true : false, 0 };
yield return new object[] { s_invariantCompare, "''Tests", "Tests", CompareOptions.IgnoreSymbols, true, 7 };
yield return new object[] { s_frenchCompare, "\u0153", "oe", CompareOptions.None, false, 0 };
if (PlatformDetection.IsNotHybridGlobalizationOnApplePlatform)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public static IEnumerable<object[]> IsSuffix_TestData()

// Ignore symbols
yield return new object[] { s_invariantCompare, "More Test's", "Tests", CompareOptions.IgnoreSymbols, true, 6 };
yield return new object[] { s_invariantCompare, "Tests''", "Tests", CompareOptions.IgnoreSymbols, true, 7 };
yield return new object[] { s_invariantCompare, "More Test's", "Tests", CompareOptions.None, false, 0 };

// NULL character
Expand Down
27 changes: 6 additions & 21 deletions src/native/libs/System.Globalization.Native/pal_collation.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,29 +407,14 @@ static UCollator* CloneCollatorWithOptions(const UCollator* pCollator, int32_t o
return pClonedCollator;
}

// Returns TRUE if all the collation elements in str are completely ignorable
// Returns TRUE if str is completely ignorable by the collator.
static int CanIgnoreAllCollationElements(const UCollator* pColl, const UChar* lpStr, int32_t length)
{
int result = true;
UErrorCode err = U_ZERO_ERROR;
UCollationElements* pCollElem = ucol_openElements(pColl, lpStr, length, &err);

if (U_SUCCESS(err))
{
int32_t curCollElem = UCOL_NULLORDER;
while ((curCollElem = ucol_next(pCollElem, &err)) != UCOL_NULLORDER)
{
if (curCollElem != UCOL_IGNORABLE)
{
result = false;
break;
}
}

ucol_closeElements(pCollElem);
}

return U_SUCCESS(err) ? result : false;
// Collation element iterators expose raw elements and do not apply shifted
// alternate handling. Compare against an empty string so all collator
// options, including IgnoreSymbols, are honored.
UChar emptyString = 0;
return ucol_strcoll(pColl, lpStr, length, &emptyString, 0) == UCOL_EQUAL;
}

static void CreateSortHandle(SortHandle** ppSortHandle)
Expand Down
Loading