internal static unsafe void VerifyCharData(char[] data, int offset, int len, ExceptionType exceptionType)
{
if (data == null || len == 0)
{
return;
}
int i = offset;
int endPos = offset + len;
for (;;)
{
while (i < endPos && s_xmlCharType.IsCharData(data[i]))
{
i++;
}
if (i == endPos)
{
return;
}
char ch = data[i];
if (XmlCharType.IsHighSurrogate(ch))
{
if (i + 1 == endPos)
{
throw CreateException(SR.Xml_InvalidSurrogateMissingLowChar, exceptionType, 0, offset - i + 1);
}
ch = data[i + 1];
if (XmlCharType.IsLowSurrogate(ch))
{
i += 2;
continue;
}
else
{
throw CreateInvalidSurrogatePairException(data[i + 1], data[i], exceptionType, 0, offset - i + 1);
}
}
throw CreateInvalidCharException(data, len, i, exceptionType);
}
}