You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because |WhiteSpace| is defined to include «any code point in general category “Space_Separator”», it is not guaranteed to be stable over time and therefore neither are the behavior of String.prototype.{trim,trimStart,trimEnd} or even parseInt/parseFloat/StringToNumber (e.g., the addition of a code point to general category Space_Separator in some version of the Unicode Standard means that implementations incorporating that version will consider it trimmable whitespace while implementations incorporating an earlier version will not). I think this merits an editorial note at the definition of |WhiteSpace| and at the functions and methods it affects.
Along the same lines, we would ideally also refactor StringToNumber to explicitly trim and then delegate to a lower-level operation shared with parseFloat (which already trims and should have the aforementioned note) and with GetSubstitution/ParseTimeZoneOffsetString/etc. (which don't trim and don't need the note).
StringToNumber ( str )
It converts str to a Number, ignoring leading and trailing white space and treating the empty String as 0.
Let trimmed be ! TrimString(str, START+END).
If trimmed is the empty String, return +0𝔽.
If StringToCodePoints(trimmed) satisfies the syntax of a |StrDecimalLiteral|, return DecimalStringToNumber(trimmed).
Let nonDecimalLiteral be ParseText(trimmed, |NonDecimalIntegerLiteral[~Sep]|).
If nonDecimalLiteral is a Parse Node, return 𝔽(MV of nonDecimalLiteral).
Return NaN.
DecimalStringToNumber ( str )
It converts a decimal string to a Number.
Let literal be ParseText(str, |StrDecimalLiteral|).
Assert: literal is a Parse Node.
Return StringNumericValue of literal.
The text was updated successfully, but these errors were encountered:
Because |WhiteSpace| is defined to include «any code point in general category “Space_Separator”», it is not guaranteed to be stable over time and therefore neither are the behavior of
String.prototype.{trim,trimStart,trimEnd}
or evenparseInt
/parseFloat
/StringToNumber (e.g., the addition of a code point to general category Space_Separator in some version of the Unicode Standard means that implementations incorporating that version will consider it trimmable whitespace while implementations incorporating an earlier version will not). I think this merits an editorial note at the definition of |WhiteSpace| and at the functions and methods it affects.Along the same lines, we would ideally also refactor StringToNumber to explicitly trim and then delegate to a lower-level operation shared with
parseFloat
(which already trims and should have the aforementioned note) and with GetSubstitution/ParseTimeZoneOffsetString/etc. (which don't trim and don't need the note).The text was updated successfully, but these errors were encountered: