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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 } | 266 } |
267 #endif | 267 #endif |
268 | 268 |
269 number_format = static_cast<icu::DecimalFormat*>( | 269 number_format = static_cast<icu::DecimalFormat*>( |
270 icu::NumberFormat::createInstance(icu_locale, format_style, status)); | 270 icu::NumberFormat::createInstance(icu_locale, format_style, status)); |
271 | 271 |
272 if (U_FAILURE(status)) { | 272 if (U_FAILURE(status)) { |
273 delete number_format; | 273 delete number_format; |
274 return NULL; | 274 return NULL; |
275 } | 275 } |
276 | |
277 UErrorCode status_digits = U_ZERO_ERROR; | |
278 #if U_ICU_VERSION_MAJOR_NUM >= 59 | |
279 uint32_t fraction_digits = ucurr_getDefaultFractionDigits( | |
280 icu::toUCharPtr(currency.getTerminatedBuffer()), &status_digits); | |
281 #else | |
282 uint32_t fraction_digits = ucurr_getDefaultFractionDigits( | |
283 currency.getTerminatedBuffer(), &status_digits); | |
284 #endif | |
285 if (U_SUCCESS(status_digits)) { | |
286 number_format->setMinimumFractionDigits(fraction_digits); | |
287 number_format->setMaximumFractionDigits(fraction_digits); | |
288 } else { | |
289 // Set min & max to default values (previously in i18n.js) | |
290 number_format->setMinimumFractionDigits(0); | |
291 number_format->setMaximumFractionDigits(3); | |
292 } | |
293 } else if (style == UNICODE_STRING_SIMPLE("percent")) { | 276 } else if (style == UNICODE_STRING_SIMPLE("percent")) { |
294 number_format = static_cast<icu::DecimalFormat*>( | 277 number_format = static_cast<icu::DecimalFormat*>( |
295 icu::NumberFormat::createPercentInstance(icu_locale, status)); | 278 icu::NumberFormat::createPercentInstance(icu_locale, status)); |
296 if (U_FAILURE(status)) { | 279 if (U_FAILURE(status)) { |
297 delete number_format; | 280 delete number_format; |
298 return NULL; | 281 return NULL; |
299 } | 282 } |
300 // Make sure 1.1% doesn't go into 2%. | 283 // Make sure 1.1% doesn't go into 2%. |
301 number_format->setMinimumFractionDigits(1); | 284 number_format->setMinimumFractionDigits(1); |
302 } else { | 285 } else { |
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
904 | 887 |
905 void V8BreakIterator::DeleteBreakIterator( | 888 void V8BreakIterator::DeleteBreakIterator( |
906 const v8::WeakCallbackInfo<void>& data) { | 889 const v8::WeakCallbackInfo<void>& data) { |
907 delete reinterpret_cast<icu::BreakIterator*>(data.GetInternalField(0)); | 890 delete reinterpret_cast<icu::BreakIterator*>(data.GetInternalField(0)); |
908 delete reinterpret_cast<icu::UnicodeString*>(data.GetInternalField(1)); | 891 delete reinterpret_cast<icu::UnicodeString*>(data.GetInternalField(1)); |
909 GlobalHandles::Destroy(reinterpret_cast<Object**>(data.GetParameter())); | 892 GlobalHandles::Destroy(reinterpret_cast<Object**>(data.GetParameter())); |
910 } | 893 } |
911 | 894 |
912 } // namespace internal | 895 } // namespace internal |
913 } // namespace v8 | 896 } // namespace v8 |
OLD | NEW |