diff --git a/lib/util/charset/charset.h b/lib/util/charset/charset.h index f350e748c07..0f3c6750a4f 100644 --- a/lib/util/charset/charset.h +++ b/lib/util/charset/charset.h @@ -103,6 +103,11 @@ struct smb_iconv_handle; size_t ucs2_align(const void *base_ptr, const void *p, int flags); +/** +return the number of bytes occupied by a buffer in CH_UTF16 format +**/ +size_t utf16_len(const void *buf); + /** return the number of bytes occupied by a buffer in CH_UTF16 format the result includes the null termination diff --git a/lib/util/charset/util_unistr.c b/lib/util/charset/util_unistr.c index c94068819ce..d81a9c3b70f 100644 --- a/lib/util/charset/util_unistr.c +++ b/lib/util/charset/util_unistr.c @@ -193,15 +193,23 @@ size_t ucs2_align(const void *base_ptr, const void *p, int flags) /** return the number of bytes occupied by a buffer in CH_UTF16 format -the result includes the null termination **/ -size_t utf16_null_terminated_len(const void *buf) +size_t utf16_len(const void *buf) { size_t len; for (len = 0; SVAL(buf,len); len += 2) ; - return len + 2; + return len; +} + +/** +return the number of bytes occupied by a buffer in CH_UTF16 format +the result includes the null termination +**/ +size_t utf16_null_terminated_len(const void *buf) +{ + return utf16_len(buf) + 2; } /**