summaryrefslogtreecommitdiffstats
path: root/src/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils.c')
-rw-r--r--src/utils.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/utils.c b/src/utils.c
index 0168a23..24da427 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -28,3 +28,13 @@ const char* level(int channel, int peak)
return text[index][channel];
}
+size_t strlen_utf8(const char *s) {
+ size_t result = 0;
+
+ // ignore continuation bytes - only count single/leading bytes
+ while (*s)
+ if ((*s++ & 0xC0) != 0x80)
+ result++;
+
+ return result;
+}