shared/utf8: add utf8_is_valid_n()

Sometimes we need to check strings without the terminating NUL. Add a variant
that does that.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2020-09-01 16:48:40 +02:00
parent e12b6e1951
commit 80ab31a435
3 changed files with 35 additions and 8 deletions
+4 -1
View File
@@ -14,7 +14,10 @@
bool unichar_is_valid(char32_t c);
char *utf8_is_valid(const char *s) _pure_;
char *utf8_is_valid_n(const char *str, size_t len_bytes) _pure_;
static inline char *utf8_is_valid(const char *s) {
return utf8_is_valid_n(s, (size_t) -1);
}
char *ascii_is_valid(const char *s) _pure_;
char *ascii_is_valid_n(const char *str, size_t len);