summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/charset.h12
-rw-r--r--lib/charset.c5
2 files changed, 17 insertions, 0 deletions
diff --git a/include/charset.h b/include/charset.h
index fde6bddbc2..c118cbeb9a 100644
--- a/include/charset.h
+++ b/include/charset.h
@@ -196,6 +196,18 @@ int u16_strncmp(const u16 *s1, const u16 *s2, size_t n);
size_t u16_strlen(const void *in);
/**
+ * u16_strsize() - count size of u16 string in bytes including the null
+ * character
+ *
+ * Counts the number of bytes occupied by a u16 string
+ *
+ * @in: null terminated u16 string
+ * Return: bytes in a u16 string
+ *
+ */
+size_t u16_strsize(const void *in);
+
+/**
* u16_strlen - count non-zero words
*
* This function matches wscnlen_s() if the -fshort-wchar compiler flag is set.
diff --git a/lib/charset.c b/lib/charset.c
index 1c6a7f693d..a28034ee1f 100644
--- a/lib/charset.c
+++ b/lib/charset.c
@@ -379,6 +379,11 @@ size_t u16_strnlen(const u16 *in, size_t count)
return i;
}
+size_t u16_strsize(const void *in)
+{
+ return (u16_strlen(in) + 1) * sizeof(u16);
+}
+
u16 *u16_strcpy(u16 *dest, const u16 *src)
{
u16 *tmp = dest;