System.Globalization.CharUnicodeInfo.InternalGetCategoryValue C# (CSharp) Method

InternalGetCategoryValue() static private method

static private InternalGetCategoryValue ( int ch, int offset ) : byte
ch int
offset int
return byte
        internal unsafe static byte InternalGetCategoryValue(int ch, int offset) {
            BCLDebug.Assert(ch >= 0 && ch <= 0x10ffff, "ch is not in valid Unicode range.");
            // Get the level 2 item from the highest 12 bit (8 - 19) of ch.
            ushort index = m_pCategoryLevel1Index[ch >> 8];
            // Get the level 2 WORD offset from the 4 - 7 bit of ch.  This provides the base offset of the level 3 table.
            // Note that & has the lower precedence than addition, so don't forget the parathesis.
            index = m_pCategoryLevel1Index[index + ((ch >> 4) & 0x000f)];
            byte* pBytePtr = (byte*)&(m_pCategoryLevel1Index[index]);
            // Get the result from the 0 -3 bit of ch.
            byte valueIndex = pBytePtr[(ch & 0x000f)];
            byte uc = m_pCategoriesValue[valueIndex * 2 + offset];
            //
            // Make sure that OtherNotAssigned is the last category in UnicodeCategory.
            // If that changes, change the following assertion as well.
            //
            //BCLDebug.Assert(uc >= 0 && uc <= UnicodeCategory.OtherNotAssigned, "Table returns incorrect Unicode category");
            return (uc);
        }

Usage Example

コード例 #1
0
 internal static BidiCategory GetBidiCategory(string s, int index)
 {
     if (s == null)
     {
         throw new ArgumentNullException("s");
     }
     if ((uint)index >= (uint)s.Length)
     {
         throw new ArgumentOutOfRangeException("index");
     }
     return((BidiCategory)CharUnicodeInfo.InternalGetCategoryValue(CharUnicodeInfo.InternalConvertToUtf32(s, index), 1));
 }
All Usage Examples Of System.Globalization.CharUnicodeInfo::InternalGetCategoryValue