23 lines
912 B
C
23 lines
912 B
C
#ifndef _PIUMA_LIB_TEXT_H_
|
|
#define _PIUMA_LIB_TEXT_H_
|
|
|
|
#include "types.h"
|
|
|
|
typedef u32 utf8_codepoint;
|
|
|
|
u64 utf8_codepoint_count(const char *s);
|
|
bool utf8_is_codepoint_start(const char *s);
|
|
u32 utf8_codepoint_bytes(const char *s);
|
|
/* If bytes_read returns 0, we either reached the end of the string or there was a decoding error */
|
|
utf8_codepoint utf8_extract_codepoint(const char *s, u64 current_index, u32 *bytes_read);
|
|
u32 utf8_bytes_to_next_valid_codepoint(const char *s, u64 current_index);
|
|
u32 utf8_bytes_to_prev_valid_codepoint(const char *s, u64 current_index);
|
|
|
|
|
|
/* Returns the number of codepoints read. If bytes_read returns 0, there was a decoding error */
|
|
u64 utf8_from_string(const char *s, u64 *bytes_read, utf8_codepoint *result, u64 result_size);
|
|
/* Returns the number of codepoints written. */
|
|
u64 utf8_to_string(utf8_codepoint *codepoints, u64 count, char *result, u64 result_size);
|
|
|
|
#endif
|