From: Aki Tuomi Date: Thu, 20 Aug 2020 05:57:35 +0000 (+0300) Subject: lib: unichar - Change uni_utf8_char_bytes to accept unsigned char X-Git-Tag: 2.3.13~85 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=309b3ceba0ebbf08765f598be8d2de34f3ccf89b;p=thirdparty%2Fdovecot%2Fcore.git lib: unichar - Change uni_utf8_char_bytes to accept unsigned char --- diff --git a/src/lib-imap/imap-utf7.c b/src/lib-imap/imap-utf7.c index f46eca1c26..6fe603bf5f 100644 --- a/src/lib-imap/imap-utf7.c +++ b/src/lib-imap/imap-utf7.c @@ -111,7 +111,7 @@ int imap_utf8_to_utf7(const char *src, string_t *dest) *u++ = u16 >> 8; *u++ = u16 & 0xff; } - p += uni_utf8_char_bytes(*p); + p += uni_utf8_char_bytes((unsigned char)*p); } mbase64_encode(dest, utf16, u-utf16); } diff --git a/src/lib/unichar.h b/src/lib/unichar.h index a7578cea8d..88defcd43f 100644 --- a/src/lib/unichar.h +++ b/src/lib/unichar.h @@ -91,12 +91,12 @@ unsigned int uni_utf8_partial_strlen_n(const void *input, size_t size, parameter is the first byte of the UTF-8 sequence. Invalid input is returned with length 1. */ static inline unsigned int ATTR_CONST -uni_utf8_char_bytes(char chr) +uni_utf8_char_bytes(unsigned char chr) { /* 0x00 .. 0x7f are ASCII. 0x80 .. 0xC1 are invalid. */ - if ((uint8_t)chr < (192 + 2)) + if (chr < (192 + 2)) return 1; - return uni_utf8_non1_bytes[(uint8_t)chr - (192 + 2)]; + return uni_utf8_non1_bytes[chr - (192 + 2)]; } /* Return given character in titlecase. */