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)); |