#ifndef UTILS_H
#define UTILS_H

#include <stddef.h>

typedef struct {
    unsigned char state;
    unsigned char remaining;
} utf8_decoder_t;

utf8_decoder_t *utf8_decoder_create(void);
void utf8_decoder_destroy(utf8_decoder_t *decoder);
int utf8_decode_byte(utf8_decoder_t *decoder, unsigned char byte, unsigned int *codepoint);

void string_trim(char *str);
int string_split(const char *str, char delimiter, char **parts, int max_parts);
char *string_replace(const char *str, const char *old, const char *new);

int strncasecmp(const char *s1, const char *s2, size_t n);

#endif