Commit 87563c38 authored by Frank Tang's avatar Frank Tang Committed by Commit Bot

Fix minimumIntegerDigits in NumberFormat

The resolvedOptions of Intl.NumberFormat depends on the ICU's
skeleton. sffc change the output of the wildcard from + to *
in ICU67
(https://github.com/unicode-org/icu/commit/ac4540f8a45775ba1aafdb352e2561c0d1527329)

Change the v8 code to use * instead.

Bug: chromium:1108810
Change-Id: I8b0249a5bc4cc199f454c5070635100f68d1f48d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2318272Reviewed-by: 's avatarShu-yu Guo <syg@chromium.org>
Commit-Queue: Frank Tang <ftang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#69152}
parent 171a3182
......@@ -482,16 +482,16 @@ Handle<String> SignDisplayString(Isolate* isolate,
} // anonymous namespace
// Return the minimum integer digits by counting the number of '0' after
// "integer-width/+" in the skeleton.
// "integer-width/*" in the skeleton.
// Ex: Return 15 for skeleton as
// “currency/TWD .00 rounding-mode-half-up integer-width/+000000000000000”
// “currency/TWD .00 rounding-mode-half-up integer-width/*000000000000000”
// 1
// 123456789012345
// Return default value as 1 if there are no "integer-width/+".
// Return default value as 1 if there are no "integer-width/*".
int32_t JSNumberFormat::MinimumIntegerDigitsFromSkeleton(
const icu::UnicodeString& skeleton) {
// count the number of 0 after "integer-width/+"
icu::UnicodeString search("integer-width/+");
// count the number of 0 after "integer-width/*"
icu::UnicodeString search("integer-width/*");
int32_t index = skeleton.indexOf(search);
if (index < 0) return 1; // return 1 if cannot find it.
index += search.length();
......
// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Test Intl.NumberFormat returns correct minimumIntegerDigits when
// resolvedOptions called
let formatter = new Intl.NumberFormat('en-US', {
minimumIntegerDigits: 5,
useGrouping: false,
});
assertEquals("00001", formatter.format(1));
assertEquals("00012", formatter.format(12));
assertEquals("00123", formatter.format(123));
assertEquals("01234", formatter.format(1234));
assertEquals("12345", formatter.format(12345));
assertEquals("123456", formatter.format(123456));
assertEquals("1234567", formatter.format(1234567));
assertEquals(5, formatter.resolvedOptions().minimumIntegerDigits);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment