/* Returns: the number of bytes forming the character returned.  */
int _cairo_utf8_get_char_validated(const char *p, uint32_t *unicode)
/* Returns: the number of bytes forming the character returned.  */
int _cairo_utf8_get_char_validated(const char *p, uint32_t *unicode)
{
    int i, mask = 0, len;
    uint32_t result;
    unsigned char c = (unsigned char) *p;
    UTF8_COMPUTE (c, mask, len);
    if (len == -1) {
	if (unicode)
	    *unicode = (uint32_t)-1;
	return 1;
    }
    UTF8_GET (result, p, i, mask, len);
    if (unicode)
	*unicode = result;
    return len;
}