summaryrefslogtreecommitdiff
path: root/deps/v8/src/intl.h
blob: a2b393bdaa3b0a39284d486c81024e5d1bfac298 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Copyright 2013 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_INTL_SUPPORT
#error Internationalization is expected to be enabled.
#endif  // V8_INTL_SUPPORT

#ifndef V8_INTL_H_
#define V8_INTL_H_

#include <string>

#include "src/base/timezone-cache.h"
#include "src/objects.h"
#include "src/objects/string.h"
#include "unicode/uversion.h"

namespace U_ICU_NAMESPACE {
class TimeZone;
}

namespace v8 {
namespace internal {

enum class ICUService {
  kBreakIterator,
  kCollator,
  kDateFormat,
  kNumberFormat,
  kPluralRules,
  kRelativeDateTimeFormatter,
  kListFormatter,
  kSegmenter
};

const UChar* GetUCharBufferFromFlat(const String::FlatContent& flat,
                                    std::unique_ptr<uc16[]>* dest,
                                    int32_t length);
MaybeHandle<String> LocaleConvertCase(Handle<String> s, Isolate* isolate,
                                      bool is_to_upper, const char* lang);
MaybeHandle<String> ConvertToLower(Handle<String> s, Isolate* isolate);
MaybeHandle<String> ConvertToUpper(Handle<String> s, Isolate* isolate);
MaybeHandle<String> ConvertCase(Handle<String> s, bool is_upper,
                                Isolate* isolate);

V8_WARN_UNUSED_RESULT String* ConvertOneByteToLower(String* src, String* dst);

const uint8_t* ToLatin1LowerTable();

// ICUTimezoneCache calls out to ICU for TimezoneCache
// functionality in a straightforward way.
class ICUTimezoneCache : public base::TimezoneCache {
 public:
  ICUTimezoneCache();

  ~ICUTimezoneCache() override;

  const char* LocalTimezone(double time_ms) override;

  double DaylightSavingsOffset(double time_ms) override;

  double LocalTimeOffset(double time_ms, bool is_utc) override;

  void Clear() override;

 private:
  icu::TimeZone* GetTimeZone();

  bool GetOffsets(double time_ms, bool is_utc, int32_t* raw_offset,
                  int32_t* dst_offset);

  icu::TimeZone* timezone_;

  std::string timezone_name_;
  std::string dst_timezone_name_;
};

}  // namespace internal
}  // namespace v8

#endif  // V8_INTL_H_