diff options
author | Nicholas <nbnoll@eml.cc> | 2021-11-10 20:12:45 -0800 |
---|---|---|
committer | Nicholas <nbnoll@eml.cc> | 2021-11-10 20:12:45 -0800 |
commit | b5de2d7bd1e08d27f7780434e601d6d3a0750583 (patch) | |
tree | 1d12af8a2c5903f1eef3b967e52474a244e78257 /sys/libutf/len.c | |
parent | 0a1041044141ddbda0c67602e70fe8894e7430fd (diff) |
chore: libunicode -> libutf
Diffstat (limited to 'sys/libutf/len.c')
-rw-r--r-- | sys/libutf/len.c | 21 |
1 files changed, 21 insertions, 0 deletions
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++; + } +} |