diff options
Diffstat (limited to 'utf8.h')
| -rw-r--r-- | utf8.h | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -15,6 +15,7 @@ u32 utf8_encode_len(const u32 *src, u32 cp_count); void utf8_decode(u32 *dst, const char *src, u32 cp_count); void utf8_encode(char *dst, const u32 *src, u32 cp_count); u32 utf8_decode_at(const char *s, u32 i, u32 n); +int utf8_validate(const char *src, u32 n); #ifdef UTF8_IMPL @@ -85,5 +86,15 @@ u32 utf8_decode_at(const char *s, u32 i, u32 n) { return cp; } +int utf8_validate(const char *src, u32 n) { + /* TODO: rewrite this to be faster */ + for (u32 i = 0; i < n; i++) { + if (utf8_decode_at(src, i, n) == 0) { + return 0; + } + } + return 1; +} + #endif #endif |
