PebbleOS
Loading...
Searching...
No Matches
Macros | Functions

UTF-8 decoder (Bjoern Hoehrmann's DFA). More...

Macros

#define PBL_UTF8_ACCEPT   0U
 Decoder state: a code point has been decoded, or decoding has not started.
 
#define PBL_UTF8_REJECT   12U
 Decoder state: the input is not valid UTF-8.
 

Functions

uint8_t pbl_utf8_decode (uint8_t *state, uint32_t *codepoint, uint8_t byte)
 Feed one byte to the UTF-8 decoder.
 

Detailed Description

UTF-8 decoder (Bjoern Hoehrmann's DFA).

Macro Definition Documentation

◆ PBL_UTF8_ACCEPT

#define PBL_UTF8_ACCEPT   0U

Decoder state: a code point has been decoded, or decoding has not started.

◆ PBL_UTF8_REJECT

#define PBL_UTF8_REJECT   12U

Decoder state: the input is not valid UTF-8.

Sticky until the state is reset.

Function Documentation

◆ pbl_utf8_decode()

uint8_t pbl_utf8_decode ( uint8_t *  state,
uint32_t *  codepoint,
uint8_t  byte 
)

Feed one byte to the UTF-8 decoder.

Start with state set to PBL_UTF8_ACCEPT. A code point is complete when the returned state is PBL_UTF8_ACCEPT. Overlong forms, surrogates and code points above U+10FFFF are rejected.

Parameters
[in,out]stateDecoder state.
[in,out]codepointCode point being decoded.
byteNext input byte.
Returns
New decoder state.