예제 #1
0
파일: Char.cs 프로젝트: buyaa-n/runtime
        public static bool IsNumber(string s, int index)
        {
            if (s == null)
            {
                ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s);
            }
            if (((uint)index) >= ((uint)s.Length))
            {
                ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.index);
            }

            char c = s[index];

            if (IsLatin1(c))
            {
                if (IsAscii(c))
                {
                    return(IsInRange(c, '0', '9'));
                }

                return(CheckNumber(GetLatin1UnicodeCategory(c)));
            }

            return(CheckNumber(CharUnicodeInfo.GetUnicodeCategoryInternal(s, index)));
        }
예제 #2
0
 public static UnicodeCategory GetUnicodeCategory(string s, int index)
 {
     if (s == null)
     {
         throw new ArgumentNullException(nameof(s));
     }
     if (((uint)index) >= ((uint)s.Length))
     {
         throw new ArgumentOutOfRangeException(nameof(index));
     }
     if (IsLatin1(s[index]))
     {
         return(GetLatin1UnicodeCategory(s[index]));
     }
     return(CharUnicodeInfo.GetUnicodeCategoryInternal(s, index));
 }
예제 #3
0
        public static bool IsSeparator(string s, int index)
        {
            if (s == null)
            {
                throw new ArgumentNullException(nameof(s));
            }
            if (((uint)index) >= ((uint)s.Length))
            {
                throw new ArgumentOutOfRangeException(nameof(index));
            }
            char c = s[index];

            if (IsLatin1(c))
            {
                return(IsSeparatorLatin1(c));
            }
            return(CheckSeparator(CharUnicodeInfo.GetUnicodeCategoryInternal(s, index)));
        }
예제 #4
0
        public static bool IsDigit(string s, int index)
        {
            if (s == null)
            {
                throw new ArgumentNullException(nameof(s));
            }
            if (((uint)index) >= ((uint)s.Length))
            {
                throw new ArgumentOutOfRangeException(nameof(index));
            }
            char c = s[index];

            if (IsLatin1(c))
            {
                return(IsInRange(c, '0', '9'));
            }
            return(CharUnicodeInfo.GetUnicodeCategoryInternal(s, index) == UnicodeCategory.DecimalDigitNumber);
        }
예제 #5
0
        public static bool IsUpper(string s, int index)
        {
            if (s == null)
            {
                throw new ArgumentNullException(nameof(s));
            }
            if (((uint)index) >= ((uint)s.Length))
            {
                throw new ArgumentOutOfRangeException(nameof(index));
            }
            char c = s[index];

            if (IsLatin1(c))
            {
                return((Latin1CharInfo[c] & IsUpperCaseLetterFlag) != 0);
            }

            return(CharUnicodeInfo.GetUnicodeCategoryInternal(s, index) == UnicodeCategory.UppercaseLetter);
        }
예제 #6
0
        public static bool IsLetter(string s, int index)
        {
            if (s == null)
            {
                throw new ArgumentNullException(nameof(s));
            }
            if (((uint)index) >= ((uint)s.Length))
            {
                throw new ArgumentOutOfRangeException(nameof(index));
            }
            char c = s[index];

            if (IsAscii(c))
            {
                // The ASCII range doesn't include letters in categories other than "upper" and "lower"
                return((Latin1CharInfo[c] & (IsUpperCaseLetterFlag | IsLowerCaseLetterFlag)) != 0);
            }
            return(CheckLetter(CharUnicodeInfo.GetUnicodeCategoryInternal(s, index)));
        }