7 const uint8_t *current =
reinterpret_cast<const uint8_t *
>(utf8_str);
9 uint8_t c1 = *current++;
24 else if ((c1 & 0xE0) == 0xC0) {
25 uint8_t c2 = *current++;
28 if ((c2 & 0xC0) != 0x80) {
33 code_point = (c1 & 0x1F) << 6;
34 code_point |= (c2 & 0x3F);
37 if (code_point <= 0x7F) {
43 else if ((c1 & 0xF0) == 0xE0) {
44 uint8_t c2 = *current++;
45 uint8_t c3 = *current++;
48 if (((c2 & 0xC0) != 0x80) || ((c3 & 0xC0) != 0x80)) {
53 code_point = (c1 & 0x0F) << 12;
54 code_point |= (c2 & 0x3F) << 6;
55 code_point |= (c3 & 0x3F);
59 if (code_point <= 0x7FF || (code_point >= 0xD800 && code_point <= 0xDFFF)) {
65 else if ((c1 & 0xF8) == 0xF0) {
66 uint8_t c2 = *current++;
67 uint8_t c3 = *current++;
68 uint8_t c4 = *current++;
71 if (((c2 & 0xC0) != 0x80) || ((c3 & 0xC0) != 0x80) || ((c4 & 0xC0) != 0x80)) {
76 code_point = (c1 & 0x07) << 18;
77 code_point |= (c2 & 0x3F) << 12;
78 code_point |= (c3 & 0x3F) << 6;
79 code_point |= (c4 & 0x3F);
83 if (code_point <= 0xFFFF || code_point > 0x10FFFF) {
93 *
length = current -
reinterpret_cast<const uint8_t *
>(utf8_str);