Mercurial > dovecot > original-hg > dovecot-1.2
diff src/lib/unichar.h @ 7185:6f014a866f38 HEAD
Replace invalid UTF8 input with a replacement character.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 22 Jan 2008 09:31:59 +0200 |
parents | dcbf6afdf931 |
children | 81806d402514 |
line wrap: on
line diff
--- a/src/lib/unichar.h Tue Jan 22 08:49:24 2008 +0200 +++ b/src/lib/unichar.h Tue Jan 22 09:31:59 2008 +0200 @@ -1,6 +1,9 @@ #ifndef UNICHAR_H #define UNICHAR_H +/* Character used to replace invalid input. */ +#define UNICODE_REPLACEMENT_CHAR 0xfffd + typedef uint32_t unichar_t; ARRAY_DEFINE_TYPE(unichars, unichar_t); @@ -37,13 +40,14 @@ /* Convert UTF-8 input to titlecase and decompose the titlecase characters to output buffer. Returns 0 if ok, -1 if input was invalid. This generates - output that's compatible with i;unicode-casemap comparator. */ + output that's compatible with i;unicode-casemap comparator. Invalid input + is replaced with unicode replacement character (0xfffd). */ int uni_utf8_to_decomposed_titlecase(const void *input, size_t max_len, buffer_t *output); -/* If input contains only valid UTF-8 characters, return TRUE. If input - contains invalid UTF-8 characters, write only the valid ones to buf and - return FALSE. */ +/* If input contains only valid UTF-8 characters, return TRUE without updating + buf. If input contains invalid UTF-8 characters, replace them with unicode + replacement character (0xfffd), write the output to buf and return FALSE. */ bool uni_utf8_get_valid_data(const unsigned char *input, size_t size, buffer_t *buf);