Exemple #1
0
        public static int ConvertToUtf32(string s, int index)
        {
            CheckParameter(s, index);

            if (!Char.IsSurrogate(s [index]))
            {
                return(s [index]);
            }
            if (!Char.IsHighSurrogate(s [index]) ||
                index == s.Length - 1 ||
                !Char.IsLowSurrogate(s [index + 1]))
            {
                throw new ArgumentException(String.Format("The string contains invalid surrogate pair character at {0}", index));
            }
            return(ConvertToUtf32(s [index], s [index + 1]));
        }
Exemple #2
0
 public static int ConvertToUtf32(string s, int index)
 {
     if (s == null)
     {
         throw new ArgumentNullException("s");
     }
     if (index < 0 || index >= s.Length)
     {
         throw new ArgumentOutOfRangeException("index");
     }
     if (!Char.IsSurrogate(s [index]))
     {
         return(s [index]);
     }
     if (!Char.IsHighSurrogate(s [index]) ||
         index == s.Length - 1 ||
         !Char.IsLowSurrogate(s [index + 1]))
     {
         throw new ArgumentException(String.Format("The string contains invalid surrogate pair character at {0}", index));
     }
     return(ConvertToUtf32(s [index], s [index + 1]));
 }
Exemple #3
0
 /// <summary>
 /// Indicates whether the specified Char object is a low surrogate.
 /// </summary>
 /// <param name="Char">The character to evaluate.</param>
 /// <returns>true if the numeric value of the <paramref name="Char"/> parameter ranges from U+DC00 through U+DFFF; otherwise, false.</returns>
 public static Boolean IsLowSurrogate(this Char Char) => Char.IsLowSurrogate(Char);
 public static Boolean IsLowSurrogate(this Char c)
 {
     return(Char.IsLowSurrogate(c));
 }