Skip to content

Commit 321b02c

Browse files
tarekghdotnet-bot
authored andcommitted
Fix French Decimal number parsing (dotnet/coreclr#25154)
Signed-off-by: dotnet-bot <dotnet-bot@microsoft.com>
1 parent 18a4099 commit 321b02c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

netcore/System.Private.CoreLib/shared/System/Number.Parsing.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -1886,6 +1886,8 @@ private static bool TrailingZeros(ReadOnlySpan<char> value, int index)
18861886
return true;
18871887
}
18881888

1889+
private static bool IsSpaceReplacingChar(char c) => c == '\u00a0' || c == '\u202f';
1890+
18891891
private static unsafe char* MatchChars(char* p, char* pEnd, string value)
18901892
{
18911893
Debug.Assert(p != null && pEnd != null && p <= pEnd && value != null);
@@ -1895,12 +1897,12 @@ private static bool TrailingZeros(ReadOnlySpan<char> value, int index)
18951897
if (*str != '\0')
18961898
{
18971899
// We only hurt the failure case
1898-
// This fix is for French or Kazakh cultures. Since a user cannot type 0xA0 as a
1900+
// This fix is for French or Kazakh cultures. Since a user cannot type 0xA0 or 0x202F as a
18991901
// space character we use 0x20 space character instead to mean the same.
19001902
while (true)
19011903
{
19021904
char cp = p < pEnd ? *p : '\0';
1903-
if (cp != *str && !(*str == '\u00a0' && cp == '\u0020'))
1905+
if (cp != *str && !(IsSpaceReplacingChar(*str) && cp == '\u0020'))
19041906
{
19051907
break;
19061908
}

0 commit comments

Comments
 (0)