---
lib/hivex-internal.h | 1 +
lib/utf16.c | 10 ++++++++++
2 files changed, 11 insertions(+)
diff --git a/lib/hivex-internal.h b/lib/hivex-internal.h
index 6bc8638..7f4cc3c 100644
--- a/lib/hivex-internal.h
+++ b/lib/hivex-internal.h
@@ -277,6 +277,7 @@ extern char * _hivex_recode (const char *input_encoding,
_hivex_recode ("LATIN1", _input, _len, "UTF-8", NULL)
extern char* _hivex_encode_string(const char *str, size_t *size, int *utf16);
extern size_t _hivex_utf16_string_len_in_bytes_max (const char *str, size_t len);
+extern size_t _hivex_utf8_strlen (const char* str, size_t len, int utf16);
/* util.c */
extern void _hivex_free_strings (char **argv);
diff --git a/lib/utf16.c b/lib/utf16.c
index 3641580..7dde9e5 100644
--- a/lib/utf16.c
+++ b/lib/utf16.c
@@ -123,3 +123,13 @@ _hivex_utf16_string_len_in_bytes_max (const char *str, size_t len)
return ret;
}
+
+size_t
+_hivex_utf8_strlen (const char* str, size_t len, int utf16)
+{
+ char* encoding = utf16 ? "UTF-16LE" : "LATIN1";
+ size_t ret;
+ char* buf = _hivex_recode(encoding, str, len, "UTF-8", &ret);
+ free(buf);
+ return ret;
+}
--
1.8.5.2