Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Unified Diff: src/runtime/runtime-i18n.cc

Issue 2717613005: [intl] Fix NumberFormat options handling spec compliance issues (Closed)
Patch Set: Remove test262 failure expectation line Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime/runtime.h ('k') | test/test262/test262.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-i18n.cc
diff --git a/src/runtime/runtime-i18n.cc b/src/runtime/runtime-i18n.cc
index 7b5ea181e1368a44cc7b9c205af1909c3e669fb2..80c8a9cd012a89210dfa54accd5a386bd8739a03 100644
--- a/src/runtime/runtime-i18n.cc
+++ b/src/runtime/runtime-i18n.cc
@@ -532,6 +532,29 @@ RUNTIME_FUNCTION(Runtime_InternalNumberFormat) {
result.length())));
}
+RUNTIME_FUNCTION(Runtime_CurrencyDigits) {
+ DCHECK_EQ(1, args.length());
+
+ CONVERT_ARG_HANDLE_CHECKED(String, currency, 0);
+
+ // TODO(littledan): Avoid transcoding the string twice
+ v8::String::Utf8Value currency_string(v8::Utils::ToLocal(currency));
+ 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_icu.getTerminatedBuffer()), &status);
+#else
+ uint32_t fraction_digits = ucurr_getDefaultFractionDigits(
+ currency_icu.getTerminatedBuffer(), &status);
+#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);
« no previous file with comments | « src/runtime/runtime.h ('k') | test/test262/test262.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698