20 lines
583 B
C
20 lines
583 B
C
|
#ifndef UTF8_HACK
|
||
|
#define UTF8_HACK
|
||
|
// hacky implementation of UTF-8 parsing. Doesn't do much validation.
|
||
|
// Primary purpose is to separate bytes into unicode codepoints.
|
||
|
#include <stdbool.h>
|
||
|
#include <stddef.h>
|
||
|
|
||
|
typedef struct utf8_char {
|
||
|
char *bytes;
|
||
|
size_t length;
|
||
|
} utf8_char;
|
||
|
|
||
|
bool utf8_char_eq(utf8_char *a, utf8_char *b);
|
||
|
int parse_to_utf8(char *input, utf8_char **output_string, size_t *output_length);
|
||
|
void print_utf8_str(utf8_char *str, size_t length);
|
||
|
void free_utf8_str(utf8_char *str, int length);
|
||
|
utf8_char copy_utf8_char(utf8_char *from);
|
||
|
|
||
|
#endif // UTF8_HACK
|