/* Copyright (c) 2005-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "bsearch-insert-pos.h"
#include "unichar.h"
#include "unicodemap.c"
{ 0xef, 0xbf, 0xbd }; /* 0xfffd */
2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,1,1
};
{
unsigned int len = 0;
return len;
}
{
chr_r);
}
{
{ 0, 0, 0x80, 0x800, 0x10000, 0x200000, 0x4000000 };
unsigned int i, len;
int ret;
if (*input < 0x80) {
return 1;
}
/* first byte has len highest bits set, followed by zero bit.
the rest of the bits are used as the highest bits of the value. */
switch (len) {
case 2:
chr &= 0x1f;
break;
case 3:
chr &= 0x0f;
break;
case 4:
chr &= 0x07;
break;
case 5:
chr &= 0x03;
break;
case 6:
chr &= 0x01;
break;
default:
/* only 7bit chars should have len==1 */
return -1;
}
} else {
/* check first if the input is invalid before returning 0 */
lowest_valid_chr = 0;
ret = 0;
}
/* the following bytes must all be 10xxxxxx */
for (i = 1; i < len; i++) {
chr <<= 6;
}
/* these are specified as invalid encodings by standards
see RFC3629 */
if (!uni_is_valid_ucs4(chr))
return -1;
if (chr < lowest_valid_chr) {
/* overlong encoding */
return -1;
}
return ret;
}
{
while (*input != '\0') {
if (len <= 0) {
/* invalid input */
return -1;
}
}
return 0;
}
{
while (size > 0) {
if (len <= 0)
return -1; /* invalid input */
}
return 0;
}
{
}
{
unsigned char first;
int bitpos;
if (chr < 0x80) {
return;
}
/* 110xxxxx */
bitpos = 6;
/* 1110xxxx */
/* 11110xxx */
/* 111110xx */
} else {
/* 1111110x */
}
do {
bitpos -= 6;
} while (bitpos > 0);
}
{
}
{
}
{
size_t i;
for (i = 0; i < size; ) {
break;
i += count;
len++;
}
*partial_pos_r = i;
return len;
}
{
}
{
}
{
unsigned int idx;
if (chr <= 0xff)
return titlecase8_map[chr];
else if (chr <= 0xffff) {
return chr;
else
return titlecase16_values[idx];
} else {
return chr;
else
return titlecase32_values[idx];
}
}
{
unsigned int idx;
if (*chr <= 0xff) {
return FALSE;
} else if (*chr <= 0xffff) {
if (*chr < uni16_decomp_keys[0])
return FALSE;
if (!uint16_find(uni16_decomp_keys,
return FALSE;
} else {
if (!uint32_find(uni32_decomp_keys,
return FALSE;
}
return TRUE;
}
{
uni_ucs4_to_utf8_c(L, output);
uni_ucs4_to_utf8_c(V, output);
}
{
unsigned int idx;
return FALSE;
return FALSE;
return TRUE;
}
{
/* don't add the replacement char multiple times */
return;
}
}
{
int ret = 0;
while (size > 0) {
if (bytes <= 0) {
/* invalid input. try the next byte. */
ret = -1;
continue;
}
else if (uni_ucs4_decompose_uni(&chr) ||
}
return ret;
}
static inline unsigned int
{
}
{
/* find the first invalid utf8 sequence */
for (i = 0; i < size;) {
if (input[i] < 0x80)
i++;
else {
*pos_r = i;
return -1;
}
i += len;
}
}
return 0;
}
{
return TRUE;
/* broken utf-8 input - skip the broken characters */
while (i < size) {
if (input[i] < 0x80) {
continue;
}
if (len == 0) {
i++;
continue;
}
i += len;
}
return FALSE;
}
{
size_t i;
return uni_utf8_find_invalid_pos((const unsigned char *)str,
}
{
size_t i;
}