| 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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 } | 267 } |
| 268 #endif | 268 #endif |
| 269 | 269 |
| 270 number_format = static_cast<icu::DecimalFormat*>( | 270 number_format = static_cast<icu::DecimalFormat*>( |
| 271 icu::NumberFormat::createInstance(icu_locale, format_style, status)); | 271 icu::NumberFormat::createInstance(icu_locale, format_style, status)); |
| 272 | 272 |
| 273 if (U_FAILURE(status)) { | 273 if (U_FAILURE(status)) { |
| 274 delete number_format; | 274 delete number_format; |
| 275 return NULL; | 275 return NULL; |
| 276 } | 276 } |
| 277 | |
| 278 UErrorCode status_digits = U_ZERO_ERROR; | |
| 279 #if U_ICU_VERSION_MAJOR_NUM >= 59 | |
| 280 uint32_t fraction_digits = ucurr_getDefaultFractionDigits( | |
| 281 icu::toUCharPtr(currency.getTerminatedBuffer()), &status_digits); | |
| 282 #else | |
| 283 uint32_t fraction_digits = ucurr_getDefaultFractionDigits( | |
| 284 currency.getTerminatedBuffer(), &status_digits); | |
| 285 #endif | |
| 286 if (U_SUCCESS(status_digits)) { | |
| 287 number_format->setMinimumFractionDigits(fraction_digits); | |
| 288 number_format->setMaximumFractionDigits(fraction_digits); | |
| 289 } else { | |
| 290 // Set min & max to default values (previously in i18n.js) | |
| 291 number_format->setMinimumFractionDigits(0); | |
| 292 number_format->setMaximumFractionDigits(3); | |
| 293 } | |
| 294 } else if (style == UNICODE_STRING_SIMPLE("percent")) { | 277 } else if (style == UNICODE_STRING_SIMPLE("percent")) { |
| 295 number_format = static_cast<icu::DecimalFormat*>( | 278 number_format = static_cast<icu::DecimalFormat*>( |
| 296 icu::NumberFormat::createPercentInstance(icu_locale, status)); | 279 icu::NumberFormat::createPercentInstance(icu_locale, status)); |
| 297 if (U_FAILURE(status)) { | 280 if (U_FAILURE(status)) { |
| 298 delete number_format; | 281 delete number_format; |
| 299 return NULL; | 282 return NULL; |
| 300 } | 283 } |
| 301 // Make sure 1.1% doesn't go into 2%. | 284 // Make sure 1.1% doesn't go into 2%. |
| 302 number_format->setMinimumFractionDigits(1); | 285 number_format->setMinimumFractionDigits(1); |
| 303 } else { | 286 } else { |
| (...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1207 return LocaleConvertCase(s, isolate, true, ""); | 1190 return LocaleConvertCase(s, isolate, true, ""); |
| 1208 } | 1191 } |
| 1209 | 1192 |
| 1210 MUST_USE_RESULT Object* ConvertCase(Handle<String> s, bool is_upper, | 1193 MUST_USE_RESULT Object* ConvertCase(Handle<String> s, bool is_upper, |
| 1211 Isolate* isolate) { | 1194 Isolate* isolate) { |
| 1212 return is_upper ? ConvertToUpper(s, isolate) : ConvertToLower(s, isolate); | 1195 return is_upper ? ConvertToUpper(s, isolate) : ConvertToLower(s, isolate); |
| 1213 } | 1196 } |
| 1214 | 1197 |
| 1215 } // namespace internal | 1198 } // namespace internal |
| 1216 } // namespace v8 | 1199 } // namespace v8 |
| OLD | NEW |