| 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 <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "src/api.h" | 10 #include "src/api.h" |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 } | 261 } |
| 262 #endif | 262 #endif |
| 263 | 263 |
| 264 number_format = static_cast<icu::DecimalFormat*>( | 264 number_format = static_cast<icu::DecimalFormat*>( |
| 265 icu::NumberFormat::createInstance(icu_locale, format_style, status)); | 265 icu::NumberFormat::createInstance(icu_locale, format_style, status)); |
| 266 | 266 |
| 267 if (U_FAILURE(status)) { | 267 if (U_FAILURE(status)) { |
| 268 delete number_format; | 268 delete number_format; |
| 269 return NULL; | 269 return NULL; |
| 270 } | 270 } |
| 271 | |
| 272 UErrorCode status_digits = U_ZERO_ERROR; | |
| 273 uint32_t fraction_digits = ucurr_getDefaultFractionDigits( | |
| 274 currency.getTerminatedBuffer(), &status_digits); | |
| 275 if (U_SUCCESS(status_digits)) { | |
| 276 number_format->setMinimumFractionDigits(fraction_digits); | |
| 277 number_format->setMaximumFractionDigits(fraction_digits); | |
| 278 } else { | |
| 279 // Set min & max to default values (previously in i18n.js) | |
| 280 number_format->setMinimumFractionDigits(0); | |
| 281 number_format->setMaximumFractionDigits(3); | |
| 282 } | |
| 283 } else if (style == UNICODE_STRING_SIMPLE("percent")) { | 271 } else if (style == UNICODE_STRING_SIMPLE("percent")) { |
| 284 number_format = static_cast<icu::DecimalFormat*>( | 272 number_format = static_cast<icu::DecimalFormat*>( |
| 285 icu::NumberFormat::createPercentInstance(icu_locale, status)); | 273 icu::NumberFormat::createPercentInstance(icu_locale, status)); |
| 286 if (U_FAILURE(status)) { | 274 if (U_FAILURE(status)) { |
| 287 delete number_format; | 275 delete number_format; |
| 288 return NULL; | 276 return NULL; |
| 289 } | 277 } |
| 290 // Make sure 1.1% doesn't go into 2%. | 278 // Make sure 1.1% doesn't go into 2%. |
| 291 number_format->setMinimumFractionDigits(1); | 279 number_format->setMinimumFractionDigits(1); |
| 292 } else { | 280 } else { |
| (...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 | 882 |
| 895 void V8BreakIterator::DeleteBreakIterator( | 883 void V8BreakIterator::DeleteBreakIterator( |
| 896 const v8::WeakCallbackInfo<void>& data) { | 884 const v8::WeakCallbackInfo<void>& data) { |
| 897 delete reinterpret_cast<icu::BreakIterator*>(data.GetInternalField(0)); | 885 delete reinterpret_cast<icu::BreakIterator*>(data.GetInternalField(0)); |
| 898 delete reinterpret_cast<icu::UnicodeString*>(data.GetInternalField(1)); | 886 delete reinterpret_cast<icu::UnicodeString*>(data.GetInternalField(1)); |
| 899 GlobalHandles::Destroy(reinterpret_cast<Object**>(data.GetParameter())); | 887 GlobalHandles::Destroy(reinterpret_cast<Object**>(data.GetParameter())); |
| 900 } | 888 } |
| 901 | 889 |
| 902 } // namespace internal | 890 } // namespace internal |
| 903 } // namespace v8 | 891 } // namespace v8 |
| OLD | NEW |