dovecot-2.0: Added uni_utf8_data_is_valid().

dovecot at dovecot.org dovecot at dovecot.org
Fri Feb 18 05:55:35 EET 2011


details:   http://hg.dovecot.org/dovecot-2.0/rev/35c6df7f6144
changeset: 12610:35c6df7f6144
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Feb 18 05:55:34 2011 +0200
description:
Added uni_utf8_data_is_valid().

diffstat:

 src/lib/unichar.c |  7 +++++++
 src/lib/unichar.h |  2 ++
 2 files changed, 9 insertions(+), 0 deletions(-)

diffs (25 lines):

diff -r 206cc9b37215 -r 35c6df7f6144 src/lib/unichar.c
--- a/src/lib/unichar.c	Thu Feb 17 15:30:46 2011 +0000
+++ b/src/lib/unichar.c	Fri Feb 18 05:55:34 2011 +0200
@@ -388,3 +388,10 @@
 	return uni_utf8_find_invalid_pos((const unsigned char *)str,
 					 strlen(str), &i) == 0;
 }
+
+bool uni_utf8_data_is_valid(const unsigned char *data, size_t size)
+{
+	size_t i;
+
+	return uni_utf8_find_invalid_pos(data, size, &i) == 0;
+}
diff -r 206cc9b37215 -r 35c6df7f6144 src/lib/unichar.h
--- a/src/lib/unichar.h	Thu Feb 17 15:30:46 2011 +0000
+++ b/src/lib/unichar.h	Fri Feb 18 05:55:34 2011 +0200
@@ -75,5 +75,7 @@
 			     buffer_t *buf);
 /* Returns TRUE if string is valid UTF-8 input. */
 bool uni_utf8_str_is_valid(const char *str);
+/* Returns TRUE if data contains only valid UTF-8 input. */
+bool uni_utf8_data_is_valid(const unsigned char *data, size_t size);
 
 #endif


More information about the dovecot-cvs mailing list