-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutf8.h
More file actions
25 lines (18 loc) · 1.03 KB
/
utf8.h
File metadata and controls
25 lines (18 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/* Copyright (c) 2008-2009 Bjoern Hoehrmann <[email protected]>
See http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for details.
Modifications are made by Richard James Howe <[email protected]> and
released under the same license. See <https://github.com/howerj/utf8>
for this projects repository.
UTF-8 Validation, Decoding and Encoding functions. */
#ifndef UTF8_H
#define UTF8_H
#include <stddef.h>
/* all functions return negative on failure */
int utf8_decode(unsigned long *state, unsigned long *codep, const unsigned char byte); /* returns: 0 = done, 1 = need more, -1 = error */
int utf8_code_points(const char *s, size_t slen, size_t *count); /* returns: 0 = done, 1 need more, -1 = error */
int utf8_next(char **s, size_t *slen, unsigned long *codep); /* returns: 0 = done, 1 need more, -1 = error */
int utf8_code_point_valid(unsigned long codep); /* -1 = invalid, 0 = valid */
int utf8_add(char **s, size_t *length, unsigned long codep); /* add 0 to NUL terminate */
int utf8_tests(void);
int utf8_version(unsigned long *version);
#endif