From 189b9e23edfe60b7e82c4c7b6071a3f98799653a Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Tue, 26 Oct 2021 21:32:55 -0700 Subject: fix(unicode): renamed functions to be easier to understand their functions --- sys/libunicode/len.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 sys/libunicode/len.c (limited to 'sys/libunicode/len.c') diff --git a/sys/libunicode/len.c b/sys/libunicode/len.c new file mode 100644 index 0000000..c461bf3 --- /dev/null +++ b/sys/libunicode/len.c @@ -0,0 +1,21 @@ +#include "internal.h" + +int +utf8·len(char *s) +{ + int c; + long n; + rune r; + + n = 0; + for(;;){ + c = *(uchar*)s; + if(c < RuneSelf) { + if(c == 0) + return n; + s++; + } else + s += utf8·decode(s, &r); + n++; + } +} -- cgit v1.2.1