diff options
author | pommicket <pommicket@gmail.com> | 2023-08-09 12:24:40 -0300 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2023-08-09 12:25:33 -0300 |
commit | 310faf5d70b8a65c83c013a31ab87d9d3f301767 (patch) | |
tree | 9e48b8afad2651de90e6b4e74ac9b96d94968fbd /unicode.h | |
parent | 17e65f8dd57762a2e79aeb79a5c0fb69849c07f9 (diff) |
new node/buffer system, needs more testing
Diffstat (limited to 'unicode.h')
-rw-r--r-- | unicode.h | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -211,4 +211,15 @@ static size_t unicode_utf16_to_utf8_offset(const char *str, size_t utf16_offset) return SIZE_MAX; } +static bool unicode_is_valid_utf8(const char *cstr) { + char32_t c = 0; + while (*cstr) { + size_t n = unicode_utf8_to_utf32(&c, cstr, 4); + if (n >= (size_t)-2) + return false; + cstr += n; + } + return true; +} + #endif // UNICODE_H_ |