OLD | NEW |
---|---|
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // limitations under the License. | 4 // limitations under the License. |
5 | 5 |
6 #include "src/i18n.h" | 6 #include "src/i18n.h" |
7 | 7 |
8 #include "unicode/brkiter.h" | 8 #include "unicode/brkiter.h" |
9 #include "unicode/calendar.h" | 9 #include "unicode/calendar.h" |
10 #include "unicode/coll.h" | 10 #include "unicode/coll.h" |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
251 if (display == UNICODE_STRING_SIMPLE("code")) { | 251 if (display == UNICODE_STRING_SIMPLE("code")) { |
252 format_style = UNUM_CURRENCY_ISO; | 252 format_style = UNUM_CURRENCY_ISO; |
253 } else if (display == UNICODE_STRING_SIMPLE("name")) { | 253 } else if (display == UNICODE_STRING_SIMPLE("name")) { |
254 format_style = UNUM_CURRENCY_PLURAL; | 254 format_style = UNUM_CURRENCY_PLURAL; |
255 } else { | 255 } else { |
256 format_style = UNUM_CURRENCY; | 256 format_style = UNUM_CURRENCY; |
257 } | 257 } |
258 #endif | 258 #endif |
259 | 259 |
260 number_format = static_cast<icu::DecimalFormat*>( | 260 number_format = static_cast<icu::DecimalFormat*>( |
261 icu::NumberFormat::createInstance(icu_locale, format_style, status)); | 261 icu::NumberFormat::createInstance(icu_locale, format_style, status)); |
262 | |
263 if (U_FAILURE(status)) { | |
264 delete number_format; | |
265 return NULL; | |
266 } | |
267 | |
mnita
2015/07/17 15:48:53
Two main worries:
1. Looks like the code uses the
| |
268 UErrorCode status_digits = U_ZERO_ERROR; | |
269 uint32_t fraction_digits = ucurr_getDefaultFractionDigits( | |
270 currency.getTerminatedBuffer(), &status_digits); | |
271 if (U_SUCCESS(status_digits)) { | |
272 number_format->setMinimumFractionDigits(fraction_digits); | |
273 number_format->setMaximumFractionDigits(fraction_digits); | |
274 } else { | |
275 // Set min & max to default values (previously in i18n.js) | |
276 number_format->setMinimumFractionDigits(0); | |
277 number_format->setMaximumFractionDigits(3); | |
278 } | |
262 } else if (style == UNICODE_STRING_SIMPLE("percent")) { | 279 } else if (style == UNICODE_STRING_SIMPLE("percent")) { |
263 number_format = static_cast<icu::DecimalFormat*>( | 280 number_format = static_cast<icu::DecimalFormat*>( |
264 icu::NumberFormat::createPercentInstance(icu_locale, status)); | 281 icu::NumberFormat::createPercentInstance(icu_locale, status)); |
265 if (U_FAILURE(status)) { | 282 if (U_FAILURE(status)) { |
266 delete number_format; | 283 delete number_format; |
267 return NULL; | 284 return NULL; |
268 } | 285 } |
269 // Make sure 1.1% doesn't go into 2%. | 286 // Make sure 1.1% doesn't go into 2%. |
270 number_format->setMinimumFractionDigits(1); | 287 number_format->setMinimumFractionDigits(1); |
271 } else { | 288 } else { |
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
942 | 959 |
943 void BreakIterator::DeleteBreakIterator( | 960 void BreakIterator::DeleteBreakIterator( |
944 const v8::WeakCallbackData<v8::Value, void>& data) { | 961 const v8::WeakCallbackData<v8::Value, void>& data) { |
945 DeleteNativeObjectAt<icu::BreakIterator>(data, 0); | 962 DeleteNativeObjectAt<icu::BreakIterator>(data, 0); |
946 DeleteNativeObjectAt<icu::UnicodeString>(data, 1); | 963 DeleteNativeObjectAt<icu::UnicodeString>(data, 1); |
947 DestroyGlobalHandle(data); | 964 DestroyGlobalHandle(data); |
948 } | 965 } |
949 | 966 |
950 } // namespace internal | 967 } // namespace internal |
951 } // namespace v8 | 968 } // namespace v8 |
OLD | NEW |