diff options
| author | dam <dam@gudinoff> | 2022-09-20 17:20:54 +0000 |
|---|---|---|
| committer | dam <dam@gudinoff> | 2022-09-20 17:20:54 +0000 |
| commit | 98279a2d333e8ed14d036a9d5bd38200aa215b5a (patch) | |
| tree | eef8a5c9f396148956cdf2dca79c81c68309c715 /misc.c | |
| parent | 9bbb7ce1b56814e6fa1668bf0ef21aaf602584a1 (diff) | |
| download | task-time-tracker-98279a2d333e8ed14d036a9d5bd38200aa215b5a.tar.zst task-time-tracker-98279a2d333e8ed14d036a9d5bd38200aa215b5a.zip | |
Let's say this is the first working prototype.
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. |
