Mercurial > dovecot > original-hg > dovecot-1.2
comparison src/lib/unichar.h @ 9602:cc7aa7a4dd6d HEAD
UTF-8 string validity was still checked incorrectly.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Thu, 19 Aug 2010 18:06:22 +0100 |
parents | bf2fb1679cb4 |
children | 5efba9f9f0a7 |
comparison
equal
deleted
inserted
replaced
9601:70fa6178380e | 9602:cc7aa7a4dd6d |
---|---|
41 int uni_utf8_get_char(const char *input, unichar_t *chr_r); | 41 int uni_utf8_get_char(const char *input, unichar_t *chr_r); |
42 int uni_utf8_get_char_n(const void *input, size_t max_len, unichar_t *chr_r); | 42 int uni_utf8_get_char_n(const void *input, size_t max_len, unichar_t *chr_r); |
43 /* Returns UTF-8 string length with maximum input size. */ | 43 /* Returns UTF-8 string length with maximum input size. */ |
44 unsigned int uni_utf8_strlen_n(const void *input, size_t size) ATTR_PURE; | 44 unsigned int uni_utf8_strlen_n(const void *input, size_t size) ATTR_PURE; |
45 | 45 |
46 /* Returns the number of bytes belonging to this partial UTF-8 character. | 46 /* Returns the number of bytes belonging to this UTF-8 character. The given |
47 Invalid input is returned with length 1. */ | 47 parameter is the first byte of the UTF-8 sequence. Invalid input is |
48 returned with length 1. */ | |
48 static inline unsigned int ATTR_CONST | 49 static inline unsigned int ATTR_CONST |
49 uni_utf8_char_bytes(char chr) | 50 uni_utf8_char_bytes(char chr) |
50 { | 51 { |
51 /* 0x00 .. 0x7f are ASCII. 0x80 .. 0xC1 are invalid. */ | 52 /* 0x00 .. 0x7f are ASCII. 0x80 .. 0xC1 are invalid. */ |
52 if ((uint8_t)chr < (192 + 2)) | 53 if ((uint8_t)chr < (192 + 2)) |