Exemplo n.º 1
0
 public static int IndexOfInvalid(string s, bool allowSurrogate)
 {
     for (int i = 0; i < s.Length; i++)
     {
         if (XmlChar.IsInvalid((int)s[i]))
         {
             if (!allowSurrogate || i + 1 == s.Length || s[i] < '\ud800' || s[i] >= '\udc00' || s[i + 1] < '\udc00' || s[i + 1] >= '')
             {
                 return(i);
             }
             i++;
         }
     }
     return(-1);
 }
Exemplo n.º 2
0
        public static int IndexOfInvalid(char[] s, int start, int length, bool allowSurrogate)
        {
            int num = start + length;

            if (s.Length < num)
            {
                throw new ArgumentOutOfRangeException("length");
            }
            for (int i = start; i < num; i++)
            {
                if (XmlChar.IsInvalid((int)s[i]))
                {
                    if (!allowSurrogate || i + 1 == num || s[i] < '\ud800' || s[i] >= '\udc00' || s[i + 1] < '\udc00' || s[i + 1] >= '')
                    {
                        return(i);
                    }
                    i++;
                }
            }
            return(-1);
        }
Exemplo n.º 3
0
 public static bool IsValid(int ch)
 {
     return(!XmlChar.IsInvalid(ch));
 }