private string ParseUnexpectedToken(int startPos)
{
if (_xmlCharType.IsNCNameSingleChar(_chars[startPos])
#if XML10_FIFTH_EDITION
|| xmlCharType.IsNCNameHighSurrogateChar( chars[startPos] )
#endif
)
{ // postpone the proper surrogate checking to the loop below
int endPos = startPos;
for (;;)
{
if (_xmlCharType.IsNCNameSingleChar(_chars[endPos]))
{
endPos++;
}
#if XML10_FIFTH_EDITION
else if ( chars[endPos] != 0 && // check for end of the buffer
xmlCharType.IsNCNameSurrogateChar( chars[endPos], chars[endPos + 1] ) ) {
endPos += 2;
}
#endif
else
{
break;
}
}
int len = endPos - startPos;
return new string(_chars, startPos, len > 0 ? len : 1);
}
else
{
Debug.Assert(startPos < _charsUsed);
return new string(_chars, startPos, 1);
}
}