summaryrefslogtreecommitdiff
path: root/lib9p/core_utf8.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib9p/core_utf8.h')
-rw-r--r--lib9p/core_utf8.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib9p/core_utf8.h b/lib9p/core_utf8.h
index 636d4eb..2c451e0 100644
--- a/lib9p/core_utf8.h
+++ b/lib9p/core_utf8.h
@@ -7,10 +7,12 @@
#ifndef _LIB9P_CORE_UTF8_H_
#define _LIB9P_CORE_UTF8_H_
+#include <stddef.h> /* for size_t */
+#include <stdint.h> /* for uint{n}_t */
+
static inline bool _is_valid_utf8(uint8_t *str, size_t len, bool forbid_nul) {
uint32_t ch;
uint8_t chlen;
- assert(str);
for (size_t pos = 0; pos < len;) {
if ((str[pos] & 0b10000000) == 0b00000000) { ch = str[pos] & 0b01111111; chlen = 1; }
else if ((str[pos] & 0b11100000) == 0b11000000) { ch = str[pos] & 0b00011111; chlen = 2; }