Chromium Code Reviews| Index: src/runtime/runtime-i18n.cc |
| diff --git a/src/runtime/runtime-i18n.cc b/src/runtime/runtime-i18n.cc |
| index e89175a37db11aa6990888e26e6bb989cf7c36b5..46df4fa47d2fa20c1e60b30a81364f32ed3b75f4 100644 |
| --- a/src/runtime/runtime-i18n.cc |
| +++ b/src/runtime/runtime-i18n.cc |
| @@ -552,6 +552,28 @@ RUNTIME_FUNCTION(Runtime_InternalNumberFormat) { |
| result.length()))); |
| } |
| +RUNTIME_FUNCTION(Runtime_CurrencyDigits) { |
| + DCHECK_EQ(1, args.length()); |
| + |
| + CONVERT_ARG_HANDLE_CHECKED(String, currency, 0); |
| + |
| + v8::String::Utf8Value currency_string(v8::Utils::ToLocal(currency)); |
|
jungshik at Google
2017/03/21 20:29:34
JFYI: I tried to avoid this pattern ( see lines 41
Dan Ehrenberg
2017/04/07 11:34:00
What's the right way to avoid it when constructing
|
| + icu::UnicodeString currency_icu = |
| + icu::UnicodeString::fromUTF8(*currency_string); |
| + |
| + DisallowHeapAllocation no_gc; |
| + UErrorCode status = U_ZERO_ERROR; |
| +#if U_ICU_VERSION_MAJOR_NUM >= 59 |
| + uint32_t fraction_digits = ucurr_getDefaultFractionDigits( |
| + icu::toUCharPtr(currency.getTerminatedBuffer()), &status_digits); |
|
jungshik at Google
2017/03/21 20:29:35
You meant currency_icu here? It seems that it's a
Dan Ehrenberg
2017/04/07 11:34:00
Oops, fixed
|
| +#else |
| + uint32_t fraction_digits = ucurr_getDefaultFractionDigits( |
| + currency.getTerminatedBuffer(), &status_digits); |
|
jungshik at Google
2017/03/21 20:29:35
same here..
It's a pity that ucurr_getDefaultFra
|
| +#endif |
| + // For missing currency codes, default to the most common, 2 |
| + if (!U_SUCCESS(status)) fraction_digits = 2; |
| + return Smi::FromInt(fraction_digits); |
| +} |
| RUNTIME_FUNCTION(Runtime_CreateCollator) { |
| HandleScope scope(isolate); |