1 #pragma once // Source encoding: UTF-8 with BOM (π is a lowercase Greek "pi"). 22 int m_n_bad_groups = 0;
23 int m_n_noncanonical_groups = 0;
29 template<
class In_iterator >
33 auto& it = it_ref.get();
35 or
CPPX_FAIL(
"Called with an empty byte sequence `it == beyond`" );
37 const Byte byte_value = *it; ++it;
52 const int n_first_bits = (8 - (n_bytes + 1));
53 const uint32_t first_bits_mask = ((1 << n_first_bits) - 1);
55 uint32_t code_point = (byte_value & first_bits_mask);
56 for(
int i = 1; i < n_bytes; ++i )
60 const Byte continuation_byte = *it;
64 code_point = (code_point << 6) | (continuation_byte & 0x3F);
77 class =
Enable_if_<(magnitude_bits_per_<Item_for_iterator_<Out_iterator>> >= 21)>
81 const Out_iterator destination
86 Out_iterator current = destination;
87 const In_iterator beyond_bytes = bytes_range.
beyond();
88 for(
auto it = bytes_range.
first(); it != beyond_bytes; )
91 *current = static_cast<Out_value>( code_point );
100 class =
Enable_if_<(magnitude_bits_per_<Item_for_iterator_<Out_iterator>> >= 21)>
103 const In_iterator first,
104 const In_iterator beyond,
105 const Out_iterator destination
auto first() const -> Iterator
auto n_bad_groups() const noexcept -> Size
auto utf32_from_bytes(const Span_< In_iterator > bytes_range, const Out_iterator destination) -> Out_iterator
auto is_continuation_byte(const char ch) -> Truth
auto n_noncanonical_groups() const noexcept -> Size
CPPX_USE_STD(distance, invoke, ref, next)
auto is_lead_byte(const char ch) -> Truth
auto hopefully(const Truth condition) -> Truth
auto code_point_from_bytes(In_out_ref_< In_iterator > it_ref, const In_iterator beyond) -> uint32_t
auto utf32_from_bytes(const In_iterator first, const In_iterator beyond, const Out_iterator destination) -> Out_iterator
auto is_single_byte(const char ch) -> Truth
auto group_size_for_lead_byte(const char lead_byte) -> int
auto next(P_< const char > p) -> P_< const char >
unsigned char Byte
Default choice of byte type.
Signed_< size_t > Size
A Signed_ equivalent of size_t.
typename std::iterator_traits< Iterator >::value_type Item_for_iterator_
auto beyond() const -> Iterator
std::enable_if_t< condition, Result > Enable_if_
Just more readable than enable_if_t.
Macros for generating more concise and clear using statements, primarily $use_cppx and $use_std,...
auto is_valid_lead_byte(const char ch) -> Truth
Signed Size and Index, plus unsigned equivalents Unsigned_size and Unsigned_index.