changeset 18149:0e74934072e0

lib-charset: Added charset_utf8_to_utf8_begin() wrapper function. It's never supposed to fail, so it makes it nicer for the callers who need to use it.
author Timo Sirainen <tss@iki.fi>
date Thu, 15 Jan 2015 01:05:13 +0200
parents e645ee117fa9
children 3d9ec121dc81
files src/lib-charset/charset-utf8.c src/lib-charset/charset-utf8.h
diffstat 2 files changed, 13 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-charset/charset-utf8.c	Thu Jan 15 01:03:58 2015 +0200
+++ b/src/lib-charset/charset-utf8.c	Thu Jan 15 01:05:13 2015 +0200
@@ -32,6 +32,16 @@
 	return 0;
 }
 
+struct charset_translation *
+charset_utf8_to_utf8_begin(normalizer_func_t *normalizer)
+{
+	struct charset_translation *trans;
+
+	if (charset_to_utf8_begin("UTF-8", normalizer, &trans) < 0)
+		i_unreached();
+	return trans;
+}
+
 #ifndef HAVE_ICONV
 
 struct charset_translation {
--- a/src/lib-charset/charset-utf8.h	Thu Jan 15 01:03:58 2015 +0200
+++ b/src/lib-charset/charset-utf8.h	Thu Jan 15 01:05:13 2015 +0200
@@ -15,6 +15,9 @@
 int charset_to_utf8_begin(const char *charset, normalizer_func_t *normalizer,
 			  struct charset_translation **t_r)
 	ATTR_NULL(2);
+/* Translate UTF-8 to UTF-8 while validating the input. */
+struct charset_translation *
+charset_utf8_to_utf8_begin(normalizer_func_t *normalizer);
 void charset_to_utf8_end(struct charset_translation **t);
 void charset_to_utf8_reset(struct charset_translation *t);