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

Unified Diff: src/i18n.cc

Issue 1231613006: Make NumberFormat use the ICU currency data, fix bug in NumberFormat (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Use short form of license Created 5 years, 5 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 | « AUTHORS ('k') | src/i18n.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/i18n.cc
diff --git a/src/i18n.cc b/src/i18n.cc
index 1d735c97f1f04876c1adc250be22e214c55ead54..c10890e89e5937928930963a8c27367f937c177d 100644
--- a/src/i18n.cc
+++ b/src/i18n.cc
@@ -258,7 +258,24 @@ icu::DecimalFormat* CreateICUNumberFormat(
#endif
number_format = static_cast<icu::DecimalFormat*>(
- icu::NumberFormat::createInstance(icu_locale, format_style, status));
+ icu::NumberFormat::createInstance(icu_locale, format_style, status));
+
+ if (U_FAILURE(status)) {
+ delete number_format;
+ return NULL;
+ }
+
mnita 2015/07/17 15:48:53 Two main worries: 1. Looks like the code uses the
+ UErrorCode status_digits = U_ZERO_ERROR;
+ uint32_t fraction_digits = ucurr_getDefaultFractionDigits(
+ currency.getTerminatedBuffer(), &status_digits);
+ if (U_SUCCESS(status_digits)) {
+ number_format->setMinimumFractionDigits(fraction_digits);
+ number_format->setMaximumFractionDigits(fraction_digits);
+ } else {
+ // Set min & max to default values (previously in i18n.js)
+ number_format->setMinimumFractionDigits(0);
+ number_format->setMaximumFractionDigits(3);
+ }
} else if (style == UNICODE_STRING_SIMPLE("percent")) {
number_format = static_cast<icu::DecimalFormat*>(
icu::NumberFormat::createPercentInstance(icu_locale, status));
« no previous file with comments | « AUTHORS ('k') | src/i18n.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698