LibJS: Update spec comments for replacing digits in Intl.NumberFormat

This is an editorial change in the ECMA-402 spec. See:
https://github.com/tc39/ecma402/commit/06d95ed

Note the new spec steps basically match our implementation in LibLocale.
This commit is contained in:
Timothy Flynn 2022-12-15 11:01:34 -05:00 committed by Linus Groh
parent 01fc025e9d
commit 2dfa87814e
Notes: sideshowbarker 2024-07-17 03:08:26 +09:00

View File

@ -756,8 +756,20 @@ Vector<PatternPartition> partition_notation_sub_pattern(NumberFormat& number_for
// iii. Else if p is equal to "number", then
else if (part == "number"sv) {
// 1. If the numberFormat.[[NumberingSystem]] matches one of the values in the "Numbering System" column of Table 12 below, then
// a. Let digits be a List whose 10 String valued elements are the UTF-16 string representations of the 10 digits specified in the "Digits" column of the matching row in Table 12.
// b. Replace each digit in n with the value of digits[digit].
// a. Let digits be a List whose elements are the code points specified in the "Digits" column of the matching row in Table 13.
// b. Assert: The length of digits is 10.
// c. Let transliterated be the empty String.
// d. Let len be the length of n.
// e. Let position be 0.
// f. Repeat, while position < len,
// i. Let c be the code unit at index position within n.
// ii. If 0x0030 ≤ c ≤ 0x0039, then
// i. NOTE: c is an ASCII digit.
// ii. Let i be c - 0x0030.
// iii. Set c to CodePointsToString(« digits[i] »).
// iii. Set transliterated to the string-concatenation of transliterated and c.
// iv. Set position to position + 1.
// g. Set n to transliterated.
// 2. Else use an implementation dependent algorithm to map n to the appropriate representation of n in the given numbering system.
formatted_string = ::Locale::replace_digits_for_number_system(number_format.numbering_system(), formatted_string);