summaryrefslogtreecommitdiff
path: root/source4/lib/charset/util_unistr.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/lib/charset/util_unistr.c')
-rw-r--r--source4/lib/charset/util_unistr.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/source4/lib/charset/util_unistr.c b/source4/lib/charset/util_unistr.c
index faa1398eac..f55e390856 100644
--- a/source4/lib/charset/util_unistr.c
+++ b/source4/lib/charset/util_unistr.c
@@ -613,3 +613,22 @@ _PUBLIC_ void strupper_m(char *s)
*d = 0;
}
+
+/**
+ Find the number of 'c' chars in a string
+**/
+_PUBLIC_ size_t count_chars_w(const char *s, char c)
+{
+ size_t count = 0;
+
+ while (*s) {
+ size_t size;
+ codepoint_t c2 = next_codepoint(s, &size);
+ if (c2 == c) count++;
+ s += size;
+ }
+
+ return count;
+}
+
+