-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutf8.h
33 lines (26 loc) · 849 Bytes
/
utf8.h
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
26
27
28
29
30
31
32
33
#include <unistd.h>
#include <stdbool.h>
#include <stdint.h>
/* Checks if code warrents a line break.
There should be some way of specifying if it needs to eat another byte
such as with \n\r but I can not be bothered at the moment. */
bool
islinebreak(int32_t code);
/* Checks if code is a word break. */
bool
iswordbreak(int32_t code);
/* Checks if code is whitespace. */
bool
iswhitespace(int32_t code);
size_t
utf8iterate(const uint8_t *s, size_t len, int32_t *code);
/* Deiterate is now officially a word.
Calculates the codepoint imediatly before off. */
size_t
utf8deiterate(const uint8_t *s, size_t slen, size_t off,
int32_t *code);
size_t
utf8codepoints(const uint8_t *s, size_t len);
/* Encodes code into s if it can fit, returns the encoded length. */
size_t
utf8encode(uint8_t *s, size_t len, int32_t code);