Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Fix French Decimal number parsing #25154

Merged
merged 1 commit into from
Jun 14, 2019
Merged
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
6 changes: 4 additions & 2 deletions src/System.Private.CoreLib/shared/System/Number.Parsing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1886,6 +1886,8 @@ private static bool TrailingZeros(ReadOnlySpan<char> value, int index)
return true;
}

private static bool IsSpaceReplacingChar(char c) => c == '\u00a0' || c == '\u202f';

private static unsafe char* MatchChars(char* p, char* pEnd, string value)
{
Debug.Assert(p != null && pEnd != null && p <= pEnd && value != null);
Expand All @@ -1895,12 +1897,12 @@ private static bool TrailingZeros(ReadOnlySpan<char> value, int index)
if (*str != '\0')
{
// We only hurt the failure case
// This fix is for French or Kazakh cultures. Since a user cannot type 0xA0 as a
// This fix is for French or Kazakh cultures. Since a user cannot type 0xA0 or 0x202F as a
// space character we use 0x20 space character instead to mean the same.
while (true)
{
char cp = p < pEnd ? *p : '\0';
if (cp != *str && !(*str == '\u00a0' && cp == '\u0020'))
if (cp != *str && !(IsSpaceReplacingChar(*str) && cp == '\u0020'))
{
break;
}
Expand Down