Base definitions shared by every core module: error codes, memory, logging, locks.
size_t utf8_encode(uint32_t cp, char out[4])
void utf8_truncate(char *s, size_t max_bytes)
Truncate to at most max_bytes without splitting a code point.
size_t utf8_decode(const char *s, uint32_t *cp)
Decode one code point; returns bytes consumed (>=1) and stores cp (U+FFFD on error).
void text_trim(char *s)
trims ASCII whitespace in place
size_t text_to_utf8(const uint8_t *in, size_t len, text_encoding_t enc, char *out, size_t out_size)
Convert to UTF-8.
size_t utf8_strlen(const char *s)
code points
@ TEXT_ENC_AUTO_LEGACY
single-byte text of unknown code page: detect UTF-8 / CP1251 / Latin-1
Definition text.h:18
bool text_is_valid_utf8(const uint8_t *in, size_t len)
text_encoding_t text_detect_legacy(const uint8_t *in, size_t len)
Heuristic for 8-bit legacy text: valid UTF-8 -> UTF8; mostly bytes 0xC0..0xFF forming Russian words -...