-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Open
Labels
area-System.Globalizationbugtracking-external-issueThe issue is caused by external problem (e.g. OS) - nothing we can do to fix it directlyThe issue is caused by external problem (e.g. OS) - nothing we can do to fix it directly
Milestone
Description
Repro (.NET 5 on ICU):
var ci = CultureInfo.InvariantCulture.CompareInfo;
int idx = ci.IndexOf("\u0600x", "x", CompareOptions.None);
bool isSuffix = ci.IsSuffix("\u0600x", "x", CompareOptions.None);
Console.WriteLine($"idx = {idx}, isSuffix = {isSuffix}");This sample prints idx = -1, isSuffix = True. These return values are inconsistent with respect to each other. If IsSuffix returns true, then IndexOf must return a non-negative value. It's the contrapositive of the code comment at:
runtime/src/libraries/System.Private.CoreLib/src/System/String.Searching.cs
Lines 270 to 273 in eb187d1
| * If there exists in set S any entry with the tuple values (startPos = <anything>, endPos = searchString.Length), | |
| * we say "'searchString' ends with 'value'", and the expression "searchString.EndsWith(value, comparer)" | |
| * should evaluate to true. If there exists no such entry in set S, then we say "'searchString' does not | |
| * start with 'value'", and the expression "searchString.EndsWith(value, comparer)" should evaluate to false. |
Metadata
Metadata
Assignees
Labels
area-System.Globalizationbugtracking-external-issueThe issue is caused by external problem (e.g. OS) - nothing we can do to fix it directlyThe issue is caused by external problem (e.g. OS) - nothing we can do to fix it directly