diff options
Diffstat (limited to 'misc.c')
| -rw-r--r-- | misc.c | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -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. |
