Flutter Engine
The Flutter Engine
Static Public Member Functions | Static Public Attributes | List of all members
dart::Utf16 Class Reference

#include <unicode.h>

Inheritance diagram for dart::Utf16:
dart::AllStatic

Static Public Member Functions

static intptr_t Length (int32_t ch)
 
static bool IsSurrogate (uint32_t ch)
 
static bool IsLeadSurrogate (uint32_t ch)
 
static bool IsTrailSurrogate (uint32_t ch)
 
static int32_t Next (const uint16_t *characters, intptr_t *i, intptr_t len)
 
static int32_t Decode (uint16_t lead, uint16_t trail)
 
static void Encode (int32_t codepoint, uint16_t *dst)
 

Static Public Attributes

static constexpr int32_t kMaxCodeUnit = 0xFFFF
 
static constexpr int32_t kLeadSurrogateStart = 0xD800
 
static constexpr int32_t kLeadSurrogateEnd = 0xDBFF
 
static constexpr int32_t kTrailSurrogateStart = 0xDC00
 
static constexpr int32_t kTrailSurrogateEnd = 0xDFFF
 

Detailed Description

Definition at line 115 of file unicode.h.

Member Function Documentation

◆ Decode()

static int32_t dart::Utf16::Decode ( uint16_t  lead,
uint16_t  trail 
)
inlinestatic

Definition at line 151 of file unicode.h.

151 {
152 return 0x10000 + ((lead & 0x000003FF) << 10) + (trail & 0x3FF);
153 }

◆ Encode()

void dart::Utf16::Encode ( int32_t  codepoint,
uint16_t *  dst 
)
static

Definition at line 273 of file unicode.cc.

273 {
274 ASSERT(codepoint > Utf16::kMaxCodeUnit);
275 ASSERT(dst != nullptr);
276 dst[0] = (Utf16::kLeadSurrogateOffset + (codepoint >> 10));
277 dst[1] = (0xDC00 + (codepoint & 0x3FF));
278}
static constexpr int32_t kMaxCodeUnit
Definition: unicode.h:158
#define ASSERT(E)
dst
Definition: cp.py:12

◆ IsLeadSurrogate()

static bool dart::Utf16::IsLeadSurrogate ( uint32_t  ch)
inlinestatic

Definition at line 126 of file unicode.h.

126 {
127 return (ch & 0xFFFFFC00) == 0xD800;
128 }

◆ IsSurrogate()

static bool dart::Utf16::IsSurrogate ( uint32_t  ch)
inlinestatic

Definition at line 123 of file unicode.h.

123{ return (ch & 0xFFFFF800) == 0xD800; }

◆ IsTrailSurrogate()

static bool dart::Utf16::IsTrailSurrogate ( uint32_t  ch)
inlinestatic

Definition at line 131 of file unicode.h.

131 {
132 return (ch & 0xFFFFFC00) == 0xDC00;
133 }

◆ Length()

static intptr_t dart::Utf16::Length ( int32_t  ch)
inlinestatic

Definition at line 118 of file unicode.h.

118 {
119 return (ch <= Utf16::kMaxCodeUnit) ? 1 : 2;
120 }

◆ Next()

static int32_t dart::Utf16::Next ( const uint16_t *  characters,
intptr_t *  i,
intptr_t  len 
)
inlinestatic

Definition at line 137 of file unicode.h.

137 {
138 int32_t ch = LoadUnaligned(&characters[*i]);
139 if (Utf16::IsLeadSurrogate(ch) && (*i < (len - 1))) {
140 int32_t ch2 = LoadUnaligned(&characters[*i + 1]);
141 if (Utf16::IsTrailSurrogate(ch2)) {
142 ch = Utf16::Decode(ch, ch2);
143 *i += 1;
144 }
145 }
146 *i += 1;
147 return ch;
148 }
static int32_t Decode(uint16_t lead, uint16_t trail)
Definition: unicode.h:151
static bool IsLeadSurrogate(uint32_t ch)
Definition: unicode.h:126
static bool IsTrailSurrogate(uint32_t ch)
Definition: unicode.h:131
static T LoadUnaligned(const T *ptr)
Definition: unaligned.h:14

Member Data Documentation

◆ kLeadSurrogateEnd

constexpr int32_t dart::Utf16::kLeadSurrogateEnd = 0xDBFF
staticconstexpr

Definition at line 160 of file unicode.h.

◆ kLeadSurrogateStart

constexpr int32_t dart::Utf16::kLeadSurrogateStart = 0xD800
staticconstexpr

Definition at line 159 of file unicode.h.

◆ kMaxCodeUnit

constexpr int32_t dart::Utf16::kMaxCodeUnit = 0xFFFF
staticconstexpr

Definition at line 158 of file unicode.h.

◆ kTrailSurrogateEnd

constexpr int32_t dart::Utf16::kTrailSurrogateEnd = 0xDFFF
staticconstexpr

Definition at line 162 of file unicode.h.

◆ kTrailSurrogateStart

constexpr int32_t dart::Utf16::kTrailSurrogateStart = 0xDC00
staticconstexpr

Definition at line 161 of file unicode.h.


The documentation for this class was generated from the following files: