From 7ea1cdb7d31f00024f5a1d124b42cd19a03b959a Mon Sep 17 00:00:00 2001 From: Nicholas Date: Wed, 10 Nov 2021 20:12:45 -0800 Subject: chore: libunicode -> libutf --- sys/libutf/len.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 sys/libutf/len.c (limited to 'sys/libutf/len.c') diff --git a/sys/libutf/len.c b/sys/libutf/len.c new file mode 100644 index 0000000..8fbd679 --- /dev/null +++ b/sys/libutf/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 < Tx){ + if(c == 0) + return n; + s++; + }else + s += utf8·decode(s, &r); + n++; + } +} -- cgit v1.2.1