Let's avoid a few casts in the function. Also, let's drop the "const"
when returning the string, for similar reasons as strchr() and friends
drop it: so that we don't add a const if the user passes in a non-const
string.
return true;
}
-const char *utf8_is_valid(const char *str) {
- const uint8_t *p;
+char *utf8_is_valid(const char *str) {
+ const char *p;
assert(str);
- for (p = (const uint8_t*) str; *p; ) {
+ p = str;
+ while (*p) {
int len;
- len = utf8_encoded_valid_unichar((const char *)p);
+ len = utf8_encoded_valid_unichar(p);
if (len < 0)
return NULL;
p += len;
}
- return str;
+ return (char*) str;
}
char *utf8_escape_invalid(const char *str) {
bool unichar_is_valid(char32_t c);
-const char *utf8_is_valid(const char *s) _pure_;
+char *utf8_is_valid(const char *s) _pure_;
char *ascii_is_valid(const char *s) _pure_;
char *ascii_is_valid_n(const char *str, size_t len);