xsltGetUTF8Char: : a sequence of UTF-8 encoded bytes : a pointer to len
Read one UTF8 Char from Function copied from libxml2 xmlGetUTF8Char() ... to discard ultimately and use the original API
Returns the char value or -1 in case of error and update with the number of bytes used
Definition at line 246 of file xsltutils.c.
Referenced by xsltFormatNumberConversion(), and xsltNumberComp().
{
unsigned int c;
if (utf == NULL)
goto error;
if (len == NULL)
goto error;
if (*len < 1)
goto error;
c = utf[0];
if (c & 0x80) {
if (*len < 2)
goto error;
if ((utf[1] & 0xc0) != 0x80)
goto error;
if ((c & 0xe0) == 0xe0) {
if (*len < 3)
goto error;
if ((utf[2] & 0xc0) != 0x80)
goto error;
if ((c & 0xf0) == 0xf0) {
if (*len < 4)
goto error;
if ((c & 0xf8) != 0xf0 || (utf[3] & 0xc0) != 0x80)
goto error;
*len = 4;
c = (utf[0] & 0x7) << 18;
c |= (utf[1] & 0x3f) << 12;
c |= (utf[2] & 0x3f) << 6;
c |= utf[3] & 0x3f;
} else {
*len = 3;
c = (utf[0] & 0xf) << 12;
c |= (utf[1] & 0x3f) << 6;
c |= utf[2] & 0x3f;
}
} else {
*len = 2;
c = (utf[0] & 0x1f) << 6;
c |= utf[1] & 0x3f;
}
} else {
*len = 1;
}
return(c);
error:
if (len != NULL)
*len = 0;
return(-1);
}