Repro code:
Console.WriteLine(CultureInfo.InvariantCulture.CompareInfo.IndexOf(string.Empty, "\u200c"));
This should print 0 on all platforms unless we're running under the invariant globalization mode, in which case it should return -1. The reason for this is an incorrect early-exit in CompareInfo.IndexOf, as shown below.
|
if (source.Length == 0) |
|
{ |
|
if (value.Length == 0) |
|
{ |
|
return 0; |
|
} |
|
return -1; |
|
} |
This early exit does not account for the fact that empty strings and non-empty strings may compare as equal under certain collations if the non-empty strings consist only of zero-weight code points.
Repro code:
This should print
0on all platforms unless we're running under the invariant globalization mode, in which case it should return-1. The reason for this is an incorrect early-exit inCompareInfo.IndexOf, as shown below.runtime/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs
Lines 940 to 947 in 1ae617b
This early exit does not account for the fact that empty strings and non-empty strings may compare as equal under certain collations if the non-empty strings consist only of zero-weight code points.