6 * utf8 - Simple routines to encode/decode valid UTF-8.
8 * This code contains routines to encode and decode UTF-8 characters.
9 * Table and test code stolen entirely from:
10 * Copyright (c) 2017 Christian Hansen <chansen@cpan.org>
11 * <https://github.com/chansen/c-utf8-valid>
14 * int main(int argc, char *argv[])
17 * struct utf8_state utf8_state = UTF8_STATE_INIT;
18 * bool decoded = true;
20 * for (i = 0; i < strlen(argv[1]); i++) {
21 * decoded = utf8_decode(&utf8_state, argv[1][i]);
24 * err(1, "Invalid UTF8 char %zu-%zu",
25 * i - utf8_state.used_len, i);
26 * printf("Character %u\n", utf8_state.c);
31 * errx(1, "Incomplete UTF8");
37 int main(int argc, char *argv[])
39 /* Expect exactly one argument */
43 if (strcmp(argv[1], "depends") == 0) {