summaryrefslogtreecommitdiff
path: root/lib9p/core_utf8.h
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-05-11 19:45:40 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-05-11 19:45:40 -0600
commit6b45663cbb556e252fc6a2b04a1ccc221ad77ba9 (patch)
tree214eb605f42ea83a4e378914422b3b6ff0747c18 /lib9p/core_utf8.h
parentc474fa0ade3409efa9eb1e45743afb82fd377cbd (diff)
lib9p: Tidy core_utf8.h
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; }