/* utf8.h */

#define UTF8_END   -1
#define UTF8_ERROR -2

typedef struct UTF8 {
	int  the_index;
	int  the_length;
	int  the_char;
	int  the_byte;
	char* the_input;
} Utf8;

extern int  utf8_decode_at_byte(Utf8 *u);
extern int  utf8_decode_at_character(Utf8 *u);
extern void utf8_decode_init(Utf8 *u, char p[], int length);
extern int  utf8_decode_next(Utf8 *u);

int utf8_output_char(int c, char *out);

char *utf8_to_codepoint(char *in, char *out, int bfsz);
char *codepoint_to_utf8(char *in, char *out, int bfsz);
char *utf8_validate(char *in, char *out, int bfsz);
int utf8_valid2(char *in);

int utf8_strcmpnc(char *src1, char *src2);
int utf8_strncmpnc(char *src1, char *src2, int n);
char *utf8_strstrnc(char *s1, char *s2);
void utf8_search_init(int use_utf8);
