24#ifndef ASTERISK_UTF8_H
25#define ASTERISK_UTF8_H
121 size_t *dst_size,
const char *src,
size_t src_len);
enum ast_utf8_validation_result ast_utf8_validator_state(struct ast_utf8_validator *validator)
Get the current UTF-8 validator state.
int ast_utf8_init(void)
Register UTF-8 tests.
ast_utf8_validation_result
@ AST_UTF8_INVALID
The consumed sequence is invalid UTF-8.
@ AST_UTF8_UNKNOWN
The validator is in an intermediate state.
@ AST_UTF8_VALID
The consumed sequence is valid UTF-8.
int ast_utf8_validator_new(struct ast_utf8_validator **validator)
Create a new UTF-8 validator.
int ast_utf8_is_valid(const char *str)
Check if a zero-terminated string is valid UTF-8.
enum ast_utf8_validation_result ast_utf8_validator_feed(struct ast_utf8_validator *validator, const char *data)
Feed a zero-terminated string into the UTF-8 validator.
@ AST_UTF8_REPLACE_INVALID
Source contained at least 1 invalid UTF-8 sequence.
@ AST_UTF8_REPLACE_VALID
Source contained fully valid UTF-8.
@ AST_UTF8_REPLACE_OVERRUN
Not enough space to copy entire source.
int ast_utf8_is_validn(const char *str, size_t size)
Check if the first size bytes of a string are valid UTF-8.
void ast_utf8_validator_reset(struct ast_utf8_validator *validator)
Reset the state of a UTF-8 validator.
void ast_utf8_validator_destroy(struct ast_utf8_validator *validator)
Destroy a UTF-8 validator.
void ast_utf8_copy_string(char *dst, const char *src, size_t size)
Copy a string safely ensuring valid UTF-8.
enum ast_utf8_replace_result ast_utf8_replace_invalid_chars(char *dst, size_t *dst_size, const char *src, size_t src_len)
Copy a string safely replacing any invalid UTF-8 sequences.
enum ast_utf8_validation_result ast_utf8_validator_feedn(struct ast_utf8_validator *validator, const char *data, size_t size)
Feed a string into the UTF-8 validator.