Chromium Code Reviews| Index: src/runtime/runtime-i18n.cc |
| diff --git a/src/runtime/runtime-i18n.cc b/src/runtime/runtime-i18n.cc |
| index 0b45381914641a824e36e99eaa0d315bf96252aa..df60891c2527ad9b8c83c0654ef1f3070ce33794 100644 |
| --- a/src/runtime/runtime-i18n.cc |
| +++ b/src/runtime/runtime-i18n.cc |
| @@ -551,6 +551,25 @@ 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)); |
| + icu::UnicodeString currency_icu = |
| + icu::UnicodeString::fromUTF8(*currency_string); |
| + |
| + { |
|
adamk
2017/03/16 22:47:49
Nit: no need for this block, since its ending brac
Dan Ehrenberg
2017/03/17 09:36:01
Fixed
|
| + DisallowHeapAllocation no_gc; |
| + UErrorCode status = U_ZERO_ERROR; |
| + uint32_t fraction_digits = ucurr_getDefaultFractionDigits( |
| + currency_icu.getTerminatedBuffer(), &status); |
| + // 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); |