aboutsummaryrefslogtreecommitdiff
path: root/misc.c
diff options
context:
space:
mode:
authordam <dam@gudinoff>2022-09-20 17:20:54 +0000
committerdam <dam@gudinoff>2022-09-20 17:20:54 +0000
commit98279a2d333e8ed14d036a9d5bd38200aa215b5a (patch)
treeeef8a5c9f396148956cdf2dca79c81c68309c715 /misc.c
parent9bbb7ce1b56814e6fa1668bf0ef21aaf602584a1 (diff)
downloadtask-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.c14
1 files changed, 14 insertions, 0 deletions
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.