From 98279a2d333e8ed14d036a9d5bd38200aa215b5a Mon Sep 17 00:00:00 2001 From: dam Date: Tue, 20 Sep 2022 17:20:54 +0000 Subject: Let's say this is the first working prototype. --- misc.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'misc.c') diff --git a/misc.c b/misc.c index 2c734bd..151e26f 100644 --- a/misc.c +++ b/misc.c @@ -1,3 +1,17 @@ +// Returns the number of characters in a string using UTF8 encoding. +size_t length_utf8(char *string) { + size_t size = 0; + char *ptr = string; + while(*ptr != '\0') { + if ((*ptr & 0xC0) != 0x80) { + size++; + } + ptr++; + } + return size; +} + + // Adds task to database. If necessary, expands database capacity. // Returns success. -- cgit v1.2.3