dovecot-2.2: lib: Added UTF8_IS_START_SEQ() helper macro

dovecot at dovecot.org dovecot at dovecot.org
Tue Jun 2 22:07:22 UTC 2015


details:   http://hg.dovecot.org/dovecot-2.2/rev/b95be677f483
changeset: 18816:b95be677f483
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Jun 03 01:03:52 2015 +0300
description:
lib: Added UTF8_IS_START_SEQ() helper macro

diffstat:

 src/lib/unichar.h |  5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diffs (15 lines):

diff -r 11c181d51b54 -r b95be677f483 src/lib/unichar.h
--- a/src/lib/unichar.h	Wed Jun 03 00:46:23 2015 +0300
+++ b/src/lib/unichar.h	Wed Jun 03 01:03:52 2015 +0300
@@ -23,6 +23,11 @@
 	(UTF16_SURROGATE_LOW_FIRST + \
 	 (((chr) - UTF16_SURROGATE_BASE) & UTF16_SURROGATE_MASK))
 
+/* Returns TRUE if given byte is ASCII character or the beginning of a
+   multibyte UTF-8 sequence */
+#define UTF8_IS_START_SEQ(b) \
+	(((b) & 0x80) == 0 || ((b) & 0xC0) == 0xC0)
+
 #define UTF8_REPLACEMENT_CHAR_LEN 3
 
 typedef uint32_t unichar_t;


More information about the dovecot-cvs mailing list