General-purpose definitions for Banjo API.
uint32_t bj_bool
Boolean type used throughout the Banjo API.
A borrowed view of a sequence of bytes.
uint32_t value
Decoded code point, or the partial value for an error.
enum bj_utf8_state state
Result of the decoding attempt.
const char * bytes
The bytes covered by the report, borrowed from the view.
size_t n_bytes
Number of bytes covered by the report.
size_t byte_offset
Offset of the first byte in the view.
bj_utf8_state
Result of decoding the bytes in a UTF-8 report.
size_t bj_utf8_scan(struct bj_str view, bj_utf8_fn callback, void *user_data)
Process every UTF-8 character or decoding error in a view.
bj_bool bj_utf8_validate(struct bj_str view, size_t *first_error)
Check whether a view contains only valid UTF-8.
size_t bj_utf8_encode(uint32_t value, char bytes[4])
Encode a Unicode code point as UTF-8.
bj_bool bj_utf8_next(struct bj_str view, size_t *cursor, struct bj_utf8_report *report)
Read one UTF-8 character or decoding error from a view.
bj_bool bj_utf8_prev(struct bj_str view, size_t *cursor, uint32_t *value)
Read the UTF-8 character immediately before a byte offset.
bj_bool(* bj_utf8_fn)(const struct bj_utf8_report *report, void *user_data)
Callback used by bj_utf8_scan.
@ BJ_UTF8_STATE_VALID
A valid UTF-8 character was decoded.
@ BJ_UTF8_STATE_TRUNCATED
The view ended before the sequence was complete.
@ BJ_UTF8_STATE_BAD_SLOT
A byte is not allowed at this position in the sequence.
@ BJ_UTF8_STATE_BAD_LEAD
The first byte cannot start a UTF-8 character (C0, C1, F5..FF).
@ BJ_UTF8_STATE_LONE_CONTINUATION
A continuation byte appeared where a character should start.
Details about one UTF-8 decoding attempt.
UTF-8 string views and owning strings.