9 return (int32_t) ((uint32_t)
value << shift);
12template <
typename T>
static constexpr bool is_align2(
T x) {
return 0 == (
x & 1); }
14template <
typename T>
static constexpr bool is_align4(
T x) {
return 0 == (
x & 3); }
31 }
else if (c < 0xC0) {
33 }
else if (c >= 0xF5 || (c & 0xFE) == 0xC0) {
36 int value = (((0xe5 << 24) >> ((
unsigned)c >> 4 << 1)) & 3) + 1;
48 if (!
utf8 && byteLength) {
52 const char* stop =
utf8 + byteLength;
74 const uint16_t*
src = (
const uint16_t*)utf16;
75 const uint16_t* stop =
src + (byteLength >> 1);
97 if (!
is_align4(intptr_t(utf32)) || !
is_align4(byteLength) || !SkTFitsIn<int>(byteLength >> 2)) {
100 const uint32_t kInvalidUnicharMask = 0xFF000000;
101 const uint32_t* ptr = (
const uint32_t*)utf32;
102 const uint32_t* stop = ptr + (byteLength >> 2);
104 if (*ptr & kInvalidUnicharMask) {
109 return (
int)(byteLength >> 2);
122 const uint8_t*
p = (
const uint8_t*)*ptr;
123 if (!
p ||
p >= (
const uint8_t*)
end) {
133 uint32_t mask = (uint32_t)~0x3F;
137 if (
p >= (
const uint8_t*)
end) {
141 uint8_t nextByte = *
p;
145 c = (c << 6) | (nextByte & 0x3F);
150 *ptr = (
const char*)
p + 1;
156 return val < 0 ? 0xFFFD : val;
163 const uint16_t*
src = *ptr;
176 uint16_t low = *
src++;
201 const int32_t*
s = *ptr;
206 const uint32_t kInvalidUnicharMask = 0xFF000000;
207 if (
value & kInvalidUnicharMask) {
215 if ((uint32_t)uni > 0x10FFFF) {
227 while (uni > 0x7F >>
count) {
228 *
p++ = (char)(0x80 | (uni & 0x3F));
235 while (
p < tmp +
count - 1) {
238 *--
utf8 = (char)(~(0xFF >>
count) | uni);
244 if ((uint32_t)uni > 0x10FFFF) {
247 int extra = (uni > 0xFFFF);
250 utf16[0] = (uint16_t)((0xD800 - 64) + (uni >> 10));
251 utf16[1] = (uint16_t)(0xDC00 | (uni & 0x3FF));
253 utf16[0] = (uint16_t)uni;
265 uint16_t* endDst =
dst + dstCapacity;
266 const char* endSrc =
src + srcByteLength;
267 while (
src < endSrc) {
281 uint16_t* elems = utf16;
282 while (dst < endDst && count > 0) {
297 const char* endDst =
dst + dstCapacity;
298 const uint16_t* endSrc =
src + srcLength;
299 while (
src < endSrc) {
313 const char* elems =
utf8;
314 while (dst < endDst && count > 0) {
static constexpr bool is_align4(T x)
static int utf8_byte_type(uint8_t c)
static constexpr bool is_align2(T x)
static constexpr int32_t left_shift(int32_t value, int32_t shift)
static constexpr bool utf16_is_high_surrogate(uint16_t c)
static bool utf8_byte_is_continuation(uint8_t c)
static SkUnichar next_fail(const T **ptr, const T *end)
static bool utf8_type_is_valid_leading_byte(int type)
static constexpr bool utf16_is_low_surrogate(uint16_t c)
SK_SPI size_t ToUTF8(SkUnichar uni, char utf8[kMaxBytesInUTF8Sequence]=nullptr)
SK_SPI int UTF8ToUTF16(uint16_t dst[], int dstCapacity, const char src[], size_t srcByteLength)
constexpr unsigned kMaxBytesInUTF8Sequence
SK_SPI int CountUTF16(const uint16_t *utf16, size_t byteLength)
SK_SPI SkUnichar NextUTF16(const uint16_t **ptr, const uint16_t *end)
SK_SPI SkUnichar NextUTF8WithReplacement(const char **ptr, const char *end)
SK_SPI SkUnichar NextUTF8(const char **ptr, const char *end)
SK_SPI size_t ToUTF16(SkUnichar uni, uint16_t utf16[2]=nullptr)
SK_SPI int CountUTF8(const char *utf8, size_t byteLength)
SK_SPI SkUnichar NextUTF32(const int32_t **ptr, const int32_t *end)
SK_SPI int CountUTF32(const int32_t *utf32, size_t byteLength)
SK_SPI int UTF16ToUTF8(char dst[], int dstCapacity, const uint16_t src[], size_t srcLength)