summaryrefslogtreecommitdiff
path: root/unicode.h
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2023-08-09 12:24:40 -0300
committerpommicket <pommicket@gmail.com>2023-08-09 12:25:33 -0300
commit310faf5d70b8a65c83c013a31ab87d9d3f301767 (patch)
tree9e48b8afad2651de90e6b4e74ac9b96d94968fbd /unicode.h
parent17e65f8dd57762a2e79aeb79a5c0fb69849c07f9 (diff)
new node/buffer system, needs more testing
Diffstat (limited to 'unicode.h')
-rw-r--r--unicode.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/unicode.h b/unicode.h
index 4e8c020..8765164 100644
--- a/unicode.h
+++ b/unicode.h
@@ -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_