Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(289)

Side by Side Diff: src/runtime/runtime-i18n.cc

Issue 2239523002: Expose getCanonicalLocales() for Intl object (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: disable failing tests with comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 CopyChars(dest->get(), flat.ToOneByteVector().start(), length); 56 CopyChars(dest->get(), flat.ToOneByteVector().start(), length);
57 } 57 }
58 return reinterpret_cast<const UChar*>(dest->get()); 58 return reinterpret_cast<const UChar*>(dest->get());
59 } else { 59 } else {
60 return reinterpret_cast<const UChar*>(flat.ToUC16Vector().start()); 60 return reinterpret_cast<const UChar*>(flat.ToUC16Vector().start());
61 } 61 }
62 } 62 }
63 63
64 } // namespace 64 } // namespace
65 65
66 // ECMA 402 6.2.3
66 RUNTIME_FUNCTION(Runtime_CanonicalizeLanguageTag) { 67 RUNTIME_FUNCTION(Runtime_CanonicalizeLanguageTag) {
67 HandleScope scope(isolate); 68 HandleScope scope(isolate);
68 Factory* factory = isolate->factory(); 69 Factory* factory = isolate->factory();
69 70
70 DCHECK(args.length() == 1); 71 DCHECK(args.length() == 1);
71 CONVERT_ARG_HANDLE_CHECKED(String, locale_id_str, 0); 72 CONVERT_ARG_HANDLE_CHECKED(String, locale_id_str, 0);
72 73
73 v8::String::Utf8Value locale_id(v8::Utils::ToLocal(locale_id_str)); 74 v8::String::Utf8Value locale_id(v8::Utils::ToLocal(locale_id_str));
74 75
75 // Return value which denotes invalid language tag. 76 // Return value which denotes invalid language tag.
77 // TODO(jshin): Can uloc_{for,to}TanguageTag fail even for structually valid
78 // language tags? If not, just add CHECK instead of returning 'invalid-tag'.
76 const char* const kInvalidTag = "invalid-tag"; 79 const char* const kInvalidTag = "invalid-tag";
77 80
78 UErrorCode error = U_ZERO_ERROR; 81 UErrorCode error = U_ZERO_ERROR;
79 char icu_result[ULOC_FULLNAME_CAPACITY]; 82 char icu_result[ULOC_FULLNAME_CAPACITY];
80 int icu_length = 0; 83 int icu_length = 0;
81 84
82 uloc_forLanguageTag(*locale_id, icu_result, ULOC_FULLNAME_CAPACITY, 85 uloc_forLanguageTag(*locale_id, icu_result, ULOC_FULLNAME_CAPACITY,
83 &icu_length, &error); 86 &icu_length, &error);
84 if (U_FAILURE(error) || icu_length == 0) { 87 if (U_FAILURE(error) || icu_length == 0) {
85 return *factory->NewStringFromAsciiChecked(kInvalidTag); 88 return *factory->NewStringFromAsciiChecked(kInvalidTag);
(...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 Handle<FixedArray> date_cache_version = 1154 Handle<FixedArray> date_cache_version =
1152 Handle<FixedArray>::cast(isolate->eternal_handles()->GetSingleton( 1155 Handle<FixedArray>::cast(isolate->eternal_handles()->GetSingleton(
1153 EternalHandles::DATE_CACHE_VERSION)); 1156 EternalHandles::DATE_CACHE_VERSION));
1154 return date_cache_version->get(0); 1157 return date_cache_version->get(0);
1155 } 1158 }
1156 1159
1157 } // namespace internal 1160 } // namespace internal
1158 } // namespace v8 1161 } // namespace v8
1159 1162
1160 #endif // V8_I18N_SUPPORT 1163 #endif // V8_I18N_SUPPORT
OLDNEW
« src/js/i18n.js ('K') | « src/js/i18n.js ('k') | test/test262/test262.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698