internal static unsafe int ParseNCName(string s, int offset)
{
Debug.Assert(s != null && offset <= s.Length);
// Quit if the first character is not a valid NCName starting character
int i = offset;
if (i < s.Length)
{
if (s_xmlCharType.IsStartNCNameSingleChar(s[i]))
{
i++;
}
#if XML10_FIFTH_EDITION
else if (s_xmlCharType.IsNCNameSurrogateChar(s, i)) {
i += 2;
}
#endif
else
{
return 0; // no valid StartNCName char
}
// Keep parsing until the end of string or an invalid NCName character is reached
while (i < s.Length)
{
if (s_xmlCharType.IsNCNameSingleChar(s[i]))
{
i++;
}
#if XML10_FIFTH_EDITION
else if (s_xmlCharType.IsNCNameSurrogateChar(s, i)) {
i += 2;
}
#endif
else
{
break;
}
}
}
return i - offset;
}