59[[nodiscard]]
constexpr bool is_trail(uint8_t oc)
61 return (oc >> 6) == 0x2;
72 (cp !=
one_of(0xfffeu, 0xffffu));
79 }
else if ((lead >> 5) == 0x06) {
81 }
else if ((lead >> 4) == 0x0e) {
83 }
else if ((lead >> 3) == 0x1e) {
99template<
typename octet_iterator>
101 uint32_t* code_point)
104 uint32_t cp = narrow_cast<unsigned char>(*it);
121 if (std::distance(it,
end) < length) {
131 cp = ((cp << 6) & 0x7ff) + ((*it) & 0x3f);
139 cp = ((cp << 12) & 0xffff) + ((*it << 6) & 0xfff);
143 std::advance(it, -2);
153 cp = ((cp << 18) & 0x1fffff) + ((*it << 12) & 0x3ffff);
155 cp += (*it << 6) & 0xfff;
159 std::advance(it, -3);
163 std::advance(it, -2);
174 repeat(length - 1, [&] { --it; });
183 std::advance(it, -(length-1));
186 }
else if (cp < 0x800) {
188 std::advance(it, -(length-1));
191 }
else if (cp < 0x10000) {
193 std::advance(it, -(length-1));
202template<
typename octet_iterator>
211template<
typename octet_iterator>
212[[nodiscard]]
constexpr octet_iterator
find_invalid(octet_iterator start, octet_iterator
end)
215 while (result !=
end) {
224template<
typename octet_iterator>
225[[nodiscard]]
constexpr bool is_valid(octet_iterator start, octet_iterator
end)
230template<
typename octet_iterator>
231[[nodiscard]]
constexpr bool is_bom(octet_iterator it)
234 constexpr std::array<uint8_t, 3> bom = {0xef, 0xbb, 0xbf};
236 return ((*it++ == bom[0]) &&
241template<
typename octet_iterator>
248template<
typename octet_iterator>
257[[nodiscard]]
constexpr bool is_pua(uint32_t cp)
259 return ((0x00E000 <= cp) && (cp <= 0x00F8FF)) ||
260 ((0x0F0000 <= cp) && (cp <= 0x0FFFFD)) ||
261 ((0x100000 <= cp) && (cp <= 0x10FFFD));
constexpr bool is_code_point_valid(uint32_t cp)
constexpr uint16_t LEAD_SURROGATE_MAX
constexpr uint32_t SURROGATE_OFFSET
constexpr uint16_t TRAIL_SURROGATE_MAX
constexpr uint16_t TRAIL_SURROGATE_MIN
constexpr bool is_trail(uint8_t oc)
constexpr uint16_t LEAD_OFFSET
constexpr uint32_t CODE_POINT_MAX
constexpr uint16_t LEAD_SURROGATE_MIN
constexpr bool is_surrogate(uint32_t cp)
constexpr utf_error validate_next(octet_iterator &it, octet_iterator end, uint32_t *code_point)
constexpr unsigned sequence_length(uint8_t lead)
constexpr octet_iterator find_invalid(octet_iterator start, octet_iterator end)
The library API - functions intended to be called by the users.
constexpr bool is_valid(octet_iterator start, octet_iterator end)
constexpr octet_iterator sync_backward(octet_iterator it)
constexpr bool is_bom(octet_iterator it)
constexpr octet_iterator sync_forward(octet_iterator it)
constexpr bool is_pua(uint32_t cp)
constexpr void repeat(T n, Op op)
Repeat the given operation 'op' 'n' times.
constexpr auto end(const zstring_view &x)