| 5 | #include <assert.h> |
| 6 | |
| 7 | static bool utf8_check(const char *src, size_t len) |
| 8 | { |
| 9 | bool decoded = false; |
| 10 | struct utf8_state utf8_state = UTF8_STATE_INIT; |
| 11 | size_t i; |
| 12 | |
| 13 | for (i = 0; i < len; i++) { |
| 14 | decoded = utf8_decode(&utf8_state, src[i]); |
| 15 | if (decoded) { |
| 16 | if (errno != 0) |
| 17 | return false; |
| 18 | } |
| 19 | } |
| 20 | if (!decoded) |
| 21 | return false; |
| 22 | return true; |
| 23 | } |
| 24 | |
| 25 | int main(int argc, char **argv) |
| 26 | { |