Iros
 
Loading...
Searching...
No Matches
utf8_stream_decoder.h
Go to the documentation of this file.
1#pragma once
2
4#include "di/types/prelude.h"
6
7namespace ttx {
9public:
10 constexpr static auto replacement_character = U'\uFFFD';
11
12 // Decode the incoming byte stream as UTF-8. This may buffer code
13 // units if the input doesn't end on a code point boundary.
14 //
15 // Invalid UTF-8 sequences are replaced with replacement characters.
17
18 // Flush any pending data. If there is any pending data, a single
19 // replacement character will be output.
20 auto flush() -> di::String;
21
22private:
23 constexpr static auto default_lower_bound = u8(0x80);
24 constexpr static auto default_upper_bound = u8(0xBF);
25
26 void decode_byte(di::String& output, byte input);
27 void decode_first_byte(di::String& output, byte input);
28 void output_code_point(di::String& output, c32 code_point);
29
30 u8 m_pending_code_units { 0 };
31 u32 m_pending_code_point { 0 };
32 u8 m_lower_bound { default_lower_bound };
33 u8 m_upper_bound { default_upper_bound };
34};
35}
Definition span_forward_declaration.h:10
Definition utf8_stream_decoder.h:8
static constexpr auto replacement_character
Definition utf8_stream_decoder.h:10
auto decode(di::Span< byte const > input) -> di::String
Definition utf8_stream_decoder.cpp:9
auto flush() -> di::String
Definition utf8_stream_decoder.cpp:17
string::StringImpl< string::Utf8Encoding > String
Definition string.h:11
__UINT8_TYPE__ u8
Definition integers.h:9
char32_t c32
Definition char.h:6
__UINT32_TYPE__ u32
Definition integers.h:11
Definition escape_sequence_parser.cpp:18
@ U
Definition key.h:30