UTF-8 is a variable-length Unicode encoding: each code point occupies one to four bytes. In C, a UTF-8 literal can be written with the u8 prefix, as in u8"𝒜". section 14.4
A UTF-8 literal in C
u8"𝒜" has type char8_t[5] in the correspondence table: four bytes encode the character and one byte terminates the string. The u8 prefix is useful when the program must explicitly ensure UTF-8, such as in network communication. section 14.4
UTF-8 processing becomes stateful when input arrives in pieces. Repeated calls to mbrtoc8 use the same mbstate_t object to collect a complete multibyte sequence and write its UTF-8 bytes to an output buffer. section 14.5
A C scanner must account for these cases:
- Treat mbincomplete as a sequence that may continue in the next input buffer. section 14.5
- Treat mbinvalid as an input error rather than a completed code point. section 14.5










