| OLD | NEW | 
|---|
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 | 4 | 
| 5 | 5 | 
| 6 #ifdef V8_I18N_SUPPORT | 6 #ifdef V8_I18N_SUPPORT | 
| 7 #include "src/runtime/runtime-utils.h" | 7 #include "src/runtime/runtime-utils.h" | 
| 8 | 8 | 
| 9 #include <memory> | 9 #include <memory> | 
| 10 | 10 | 
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 525 | 525 | 
| 526   icu::UnicodeString result; | 526   icu::UnicodeString result; | 
| 527   number_format->format(value->Number(), result); | 527   number_format->format(value->Number(), result); | 
| 528 | 528 | 
| 529   RETURN_RESULT_OR_FAILURE( | 529   RETURN_RESULT_OR_FAILURE( | 
| 530       isolate, isolate->factory()->NewStringFromTwoByte(Vector<const uint16_t>( | 530       isolate, isolate->factory()->NewStringFromTwoByte(Vector<const uint16_t>( | 
| 531                    reinterpret_cast<const uint16_t*>(result.getBuffer()), | 531                    reinterpret_cast<const uint16_t*>(result.getBuffer()), | 
| 532                    result.length()))); | 532                    result.length()))); | 
| 533 } | 533 } | 
| 534 | 534 | 
|  | 535 RUNTIME_FUNCTION(Runtime_CurrencyDigits) { | 
|  | 536   DCHECK_EQ(1, args.length()); | 
|  | 537 | 
|  | 538   CONVERT_ARG_HANDLE_CHECKED(String, currency, 0); | 
|  | 539 | 
|  | 540   // TODO(littledan): Avoid transcoding the string twice | 
|  | 541   v8::String::Utf8Value currency_string(v8::Utils::ToLocal(currency)); | 
|  | 542   icu::UnicodeString currency_icu = | 
|  | 543       icu::UnicodeString::fromUTF8(*currency_string); | 
|  | 544 | 
|  | 545   DisallowHeapAllocation no_gc; | 
|  | 546   UErrorCode status = U_ZERO_ERROR; | 
|  | 547 #if U_ICU_VERSION_MAJOR_NUM >= 59 | 
|  | 548   uint32_t fraction_digits = ucurr_getDefaultFractionDigits( | 
|  | 549       icu::toUCharPtr(currency_icu.getTerminatedBuffer()), &status); | 
|  | 550 #else | 
|  | 551   uint32_t fraction_digits = ucurr_getDefaultFractionDigits( | 
|  | 552       currency_icu.getTerminatedBuffer(), &status); | 
|  | 553 #endif | 
|  | 554   // For missing currency codes, default to the most common, 2 | 
|  | 555   if (!U_SUCCESS(status)) fraction_digits = 2; | 
|  | 556   return Smi::FromInt(fraction_digits); | 
|  | 557 } | 
| 535 | 558 | 
| 536 RUNTIME_FUNCTION(Runtime_CreateCollator) { | 559 RUNTIME_FUNCTION(Runtime_CreateCollator) { | 
| 537   HandleScope scope(isolate); | 560   HandleScope scope(isolate); | 
| 538 | 561 | 
| 539   DCHECK_EQ(3, args.length()); | 562   DCHECK_EQ(3, args.length()); | 
| 540 | 563 | 
| 541   CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); | 564   CONVERT_ARG_HANDLE_CHECKED(String, locale, 0); | 
| 542   CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); | 565   CONVERT_ARG_HANDLE_CHECKED(JSObject, options, 1); | 
| 543   CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); | 566   CONVERT_ARG_HANDLE_CHECKED(JSObject, resolved, 2); | 
| 544 | 567 | 
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 815   Handle<FixedArray> date_cache_version = | 838   Handle<FixedArray> date_cache_version = | 
| 816       Handle<FixedArray>::cast(isolate->eternal_handles()->GetSingleton( | 839       Handle<FixedArray>::cast(isolate->eternal_handles()->GetSingleton( | 
| 817           EternalHandles::DATE_CACHE_VERSION)); | 840           EternalHandles::DATE_CACHE_VERSION)); | 
| 818   return date_cache_version->get(0); | 841   return date_cache_version->get(0); | 
| 819 } | 842 } | 
| 820 | 843 | 
| 821 }  // namespace internal | 844 }  // namespace internal | 
| 822 }  // namespace v8 | 845 }  // namespace v8 | 
| 823 | 846 | 
| 824 #endif  // V8_I18N_SUPPORT | 847 #endif  // V8_I18N_SUPPORT | 
| OLD | NEW | 
|---|