| 94 | } |
| 95 | |
| 96 | int cm_utf8_is_valid(char const* s) |
| 97 | { |
| 98 | if (!s) { |
| 99 | return 0; |
| 100 | } |
| 101 | |
| 102 | char const* last = s + strlen(s); |
| 103 | char const* pos = s; |
| 104 | unsigned int pc; |
| 105 | |
| 106 | while (pos != last && (pos = cm_utf8_decode_character(pos, last, &pc))) { |
| 107 | /* Nothing to do. */ |
| 108 | } |
| 109 | |
| 110 | return pos == last; |
| 111 | } |
searching dependent graphs…