From 9b86df8ce86411e774515fdcb3f5c9826ecb91d2 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Sun, 31 Oct 2010 02:02:16 +0200 Subject: lib/util/charset/util_unistr: add strlen_m_ext_term() - variant of strlen_m_ext() counting terminator --- lib/util/charset/charset.h | 2 ++ lib/util/charset/util_unistr.c | 10 ++++++++++ 2 files changed, 12 insertions(+) (limited to 'lib/util') diff --git a/lib/util/charset/charset.h b/lib/util/charset/charset.h index 8222a0586e..92ea7304bf 100644 --- a/lib/util/charset/charset.h +++ b/lib/util/charset/charset.h @@ -121,6 +121,8 @@ struct smb_iconv_convenience; char *strchr_m(const char *s, char c); size_t strlen_m_ext(const char *s, charset_t src_charset, charset_t dst_charset); +size_t strlen_m_ext_term(const char *s, charset_t src_charset, + charset_t dst_charset); size_t strlen_m_term(const char *s); size_t strlen_m_term_null(const char *s); size_t strlen_m(const char *s); diff --git a/lib/util/charset/util_unistr.c b/lib/util/charset/util_unistr.c index 93fc24da15..74b453bf46 100644 --- a/lib/util/charset/util_unistr.c +++ b/lib/util/charset/util_unistr.c @@ -315,6 +315,16 @@ _PUBLIC_ size_t strlen_m_ext(const char *s, charset_t src_charset, charset_t dst return count; } +_PUBLIC_ size_t strlen_m_ext_term(const char *s, const charset_t src_charset, + const charset_t dst_charset) +{ + if (!s) { + return 0; + } + return strlen_m_ext(s, src_charset, dst_charset) + 1; +} + + /** Count the number of UCS2 characters in a string. Normally this will be the same as the number of bytes in a string for single byte strings, -- cgit