Banjo API 1.1.0-alpha
Low-level C99 game development API
Loading...
Searching...
No Matches
unicode.h
Go to the documentation of this file.
1
33#ifndef BJ_UNICODE_H
34#define BJ_UNICODE_H
35
36#include <banjo/api.h>
37#include <banjo/string.h>
38
50
65 size_t byte_offset;
66 size_t n_bytes;
67 const char* bytes;
68 uint32_t value;
70};
71
83 const struct bj_utf8_report* report,
84 void* user_data
85);
86
105 struct bj_str view,
106 size_t* cursor,
107 struct bj_utf8_report* report
108);
109
125 struct bj_str view,
126 bj_utf8_fn callback,
127 void* user_data
128);
129
147 struct bj_str view,
148 size_t* cursor,
149 uint32_t* value
150);
151
167 uint32_t value,
168 char bytes[4]
169);
170
185 struct bj_str view,
186 size_t* first_error
187);
188
189#endif /* BJ_UNICODE_H */
General-purpose definitions for Banjo API.
#define BANJO_EXPORT
Definition api.h:179
uint32_t bj_bool
Boolean type used throughout the Banjo API.
Definition api.h:264
A borrowed view of a sequence of bytes.
Definition string.h:57
uint32_t value
Decoded code point, or the partial value for an error.
Definition unicode.h:68
enum bj_utf8_state state
Result of the decoding attempt.
Definition unicode.h:69
const char * bytes
The bytes covered by the report, borrowed from the view.
Definition unicode.h:67
size_t n_bytes
Number of bytes covered by the report.
Definition unicode.h:66
size_t byte_offset
Offset of the first byte in the view.
Definition unicode.h:65
bj_utf8_state
Result of decoding the bytes in a UTF-8 report.
Definition unicode.h:43
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.
Definition unicode.h:82
@ BJ_UTF8_STATE_VALID
A valid UTF-8 character was decoded.
Definition unicode.h:44
@ BJ_UTF8_STATE_TRUNCATED
The view ended before the sequence was complete.
Definition unicode.h:48
@ BJ_UTF8_STATE_BAD_SLOT
A byte is not allowed at this position in the sequence.
Definition unicode.h:47
@ BJ_UTF8_STATE_BAD_LEAD
The first byte cannot start a UTF-8 character (C0, C1, F5..FF).
Definition unicode.h:45
@ BJ_UTF8_STATE_LONE_CONTINUATION
A continuation byte appeared where a character should start.
Definition unicode.h:46
Details about one UTF-8 decoding attempt.
Definition unicode.h:64
UTF-8 string views and owning strings.