16 if (m_pending_code_units > 0) {
17 return Unexpected(BasicError::InvalidArgument);
23 constexpr static auto default_lower_bound =
u8(0x80);
24 constexpr static auto default_upper_bound =
u8(0xBF);
27 if (m_pending_code_units == 0) {
28 return decode_first_byte(input);
31 auto input_u8 = di::to_integer<u8>(input);
33 return Unexpected(BasicError::InvalidArgument);
36 m_lower_bound = default_lower_bound;
37 m_upper_bound = default_upper_bound;
38 m_pending_code_point <<= 6;
39 m_pending_code_point |= di::to_integer<u32>(input &
byte(0b0011'1111));
40 if (--m_pending_code_units == 0) {
41 return output_code_point(m_pending_code_point);
49 auto input_u8 = di::to_integer<u8>(input);
51 return output_code_point(di::to_integer<u32>(input));
54 m_pending_code_units = 1;
55 m_pending_code_point = di::to_integer<u32>(input &
byte(0x1F));
59 m_pending_code_units = 2;
60 if (input ==
byte(0xE0)) {
62 }
else if (input ==
byte(0xED)) {
65 m_pending_code_point = di::to_integer<u32>(input &
byte(0x0F));
69 m_pending_code_units = 3;
70 if (input ==
byte(0xF0)) {
72 }
else if (input ==
byte(0xF4)) {
75 m_pending_code_point = di::to_integer<u32>(input &
byte(0x07));
78 return Unexpected(BasicError::InvalidArgument);
81 constexpr auto output_code_point(
c32 code_point) ->
c32 {
88 u8 m_pending_code_units { 0 };
89 u32 m_pending_code_point { 0 };
90 u8 m_lower_bound { default_lower_bound };
91 u8 m_upper_bound { default_upper_bound };