{
int i, j, k, K, l, L;
intlen, c;
unsignedchar lows[6] = {0, 0x80, 0x81, 0xC1, 0xFF, 0xBF};
intvalue;
data[4] = 0;
for (i = 0xF0;i <= 0xFF;i++) {
for (j = 0;j <= 0xFF;j++) {
for (k = 0;k < 6;k++) {
for (l = 0;l < 6;l++) {
data[0] = i;
data[1] = j;
K = lows[k];
data[2] = (char) K;
L = lows[l];
data[3] = (char) L;
value = (L & 0x3F) + ((K & 0x3F) << 6) + ((j & 0x3F) << 12) +
((i & 0x7) << 18);
ctxt->charset = XML_CHAR_ENCODING_UTF8;
lastError = 0;
c = xmlCurrentChar(ctxt, &len);
/* * if fifth bit of first char is set, then the sequence would need * at least 5 bytes, but we give only 4 ! */if ((i & 0xF8) == 0xF8) {
if (lastError != XML_ERR_INVALID_CHAR)
fprintf(stderr,
"Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x%02X 0x%02X\n",
i, j, K, data[3]);
}
/* * The second, third and fourth bytes must start with 10 */elseif (((j & 0xC0) != 0x80) || ((K & 0xC0) != 0x80) ||
((L & 0xC0) != 0x80)) {
if (lastError != XML_ERR_INVALID_CHAR)
fprintf(stderr,
"Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x%02X 0x%02X\n",
i, j, K, L);
}
/* * if using a 3 byte encoding then the value must be greater * than 0x10000, i.e. one of bits 3 to 0 of i must be set or * the 6 or 5th byte of j must be set */elseif (((i & 0x7) == 0) && ((j & 0x30) == 0)) {
if (lastError != XML_ERR_INVALID_CHAR)
fprintf(stderr,
"Failed to detect invalid char for Bytes 0x%02X 0x%02X 0x%02X 0x%02X\n",
i, j, K, L);
}
/* * There are values in that range that are not allowed in XML-1.0 */elseif (((value > 0xD7FF) && (value <0xE000)) ||
((value > 0xFFFD) && (value <0x10000)) ||
(value > 0x10FFFF)) {
if (lastError != XML_ERR_INVALID_CHAR)
fprintf(stderr,
"Failed to detect invalid char 0x%04X for Bytes 0x%02X 0x%02X 0x%02X 0x%02X\n",
value, i, j, K, L);
}
/* * We should see no error in remaining cases */elseif ((lastError != 0) || (len != 4)) {
fprintf(stderr,
"Failed to parse char for Bytes 0x%02X 0x%02X 0x%02X\n",
i, j, K);
}
/* * Finally check the value is right */elseif (c != value) {
fprintf(stderr,
"Failed to parse char for Bytes 0x%02X 0x%02X 0x%02X: expect %d got %d\n",
i, j, data[2], value, c);
}
}
}
}
}
}
Generated on Sat May 26 2012 06:01:57 for ReactOS by
1.7.6.1
ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.