]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Added UTF8_IS_START_SEQ() helper macro
authorTimo Sirainen <tss@iki.fi>
Tue, 2 Jun 2015 22:03:52 +0000 (01:03 +0300)
committerTimo Sirainen <tss@iki.fi>
Tue, 2 Jun 2015 22:03:52 +0000 (01:03 +0300)
src/lib/unichar.h

index 1841689fbb78e8cf8dc39dc19aa64369e081db08..546c8e101a1991eed5e9388f33a4dc557c00d836 100644 (file)
        (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;