• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #ifndef V8_INTL_SUPPORT
6 #error Internationalization is expected to be enabled.
7 #endif  // V8_INTL_SUPPORT
8 
9 #ifndef V8_INTL_H_
10 #define V8_INTL_H_
11 
12 #include <string>
13 
14 #include "src/base/timezone-cache.h"
15 #include "src/objects.h"
16 #include "src/objects/string.h"
17 #include "unicode/uversion.h"
18 
19 namespace U_ICU_NAMESPACE {
20 class TimeZone;
21 }
22 
23 namespace v8 {
24 namespace internal {
25 
26 enum class IcuService {
27   kBreakIterator,
28   kCollator,
29   kDateFormat,
30   kNumberFormat,
31   kPluralRules,
32   kResourceBundle,
33   kRelativeDateTimeFormatter,
34   kListFormatter
35 };
36 
37 const UChar* GetUCharBufferFromFlat(const String::FlatContent& flat,
38                                     std::unique_ptr<uc16[]>* dest,
39                                     int32_t length);
40 MaybeHandle<String> LocaleConvertCase(Handle<String> s, Isolate* isolate,
41                                       bool is_to_upper, const char* lang);
42 MaybeHandle<String> ConvertToLower(Handle<String> s, Isolate* isolate);
43 MaybeHandle<String> ConvertToUpper(Handle<String> s, Isolate* isolate);
44 MaybeHandle<String> ConvertCase(Handle<String> s, bool is_upper,
45                                 Isolate* isolate);
46 
47 V8_WARN_UNUSED_RESULT String* ConvertOneByteToLower(String* src, String* dst);
48 
49 const uint8_t* ToLatin1LowerTable();
50 
51 // ICUTimezoneCache calls out to ICU for TimezoneCache
52 // functionality in a straightforward way.
53 class ICUTimezoneCache : public base::TimezoneCache {
54  public:
55   ICUTimezoneCache();
56 
57   ~ICUTimezoneCache() override;
58 
59   const char* LocalTimezone(double time_ms) override;
60 
61   double DaylightSavingsOffset(double time_ms) override;
62 
63   double LocalTimeOffset(double time_ms, bool is_utc) override;
64 
65   void Clear() override;
66 
67  private:
68   icu::TimeZone* GetTimeZone();
69 
70   bool GetOffsets(double time_ms, bool is_utc, int32_t* raw_offset,
71                   int32_t* dst_offset);
72 
73   icu::TimeZone* timezone_;
74 
75   std::string timezone_name_;
76   std::string dst_timezone_name_;
77 };
78 
79 }  // namespace internal
80 }  // namespace v8
81 
82 #endif  // V8_INTL_H_
83