static private IsCombiningCategory ( UnicodeCategory uc ) : bool | ||
uc | UnicodeCategory | |
Résultat | bool |
// Token: 0x06003054 RID: 12372 RVA: 0x000B935C File Offset: 0x000B755C internal static int GetCurrentTextElementLen(string str, int index, int len, ref UnicodeCategory ucCurrent, ref int currentCharCount) { if (index + currentCharCount == len) { return(currentCharCount); } int num; UnicodeCategory unicodeCategory = CharUnicodeInfo.InternalGetUnicodeCategory(str, index + currentCharCount, out num); if (CharUnicodeInfo.IsCombiningCategory(unicodeCategory) && !CharUnicodeInfo.IsCombiningCategory(ucCurrent) && ucCurrent != UnicodeCategory.Format && ucCurrent != UnicodeCategory.Control && ucCurrent != UnicodeCategory.OtherNotAssigned && ucCurrent != UnicodeCategory.Surrogate) { int num2 = index; for (index += currentCharCount + num; index < len; index += num) { unicodeCategory = CharUnicodeInfo.InternalGetUnicodeCategory(str, index, out num); if (!CharUnicodeInfo.IsCombiningCategory(unicodeCategory)) { ucCurrent = unicodeCategory; currentCharCount = num; break; } } return(index - num2); } int result = currentCharCount; ucCurrent = unicodeCategory; currentCharCount = num; return(result); }
internal static int GetCurrentTextElementLen(string str, int index, int len, ref UnicodeCategory ucCurrent, ref int currentCharCount) { int num; if ((index + currentCharCount) == len) { return(currentCharCount); } UnicodeCategory uc = CharUnicodeInfo.InternalGetUnicodeCategory(str, index + currentCharCount, out num); if (((!CharUnicodeInfo.IsCombiningCategory(uc) || CharUnicodeInfo.IsCombiningCategory(ucCurrent)) || ((ucCurrent == UnicodeCategory.Format) || (ucCurrent == UnicodeCategory.Control))) || ((ucCurrent == UnicodeCategory.OtherNotAssigned) || (ucCurrent == UnicodeCategory.Surrogate))) { int num3 = currentCharCount; ucCurrent = uc; currentCharCount = num; return(num3); } int num2 = index; index += currentCharCount + num; while (index < len) { uc = CharUnicodeInfo.InternalGetUnicodeCategory(str, index, out num); if (!CharUnicodeInfo.IsCombiningCategory(uc)) { ucCurrent = uc; currentCharCount = num; break; } index += num; } return(index - num2); }
internal static int GetCurrentTextElementLen(string str, int index, int len, ref UnicodeCategory ucCurrent, ref int currentCharCount) { if (index + currentCharCount == len) { return(currentCharCount); } int charLength; UnicodeCategory unicodeCategory1 = CharUnicodeInfo.InternalGetUnicodeCategory(str, index + currentCharCount, out charLength); if (CharUnicodeInfo.IsCombiningCategory(unicodeCategory1) && !CharUnicodeInfo.IsCombiningCategory(ucCurrent) && (ucCurrent != UnicodeCategory.Format && ucCurrent != UnicodeCategory.Control) && (ucCurrent != UnicodeCategory.OtherNotAssigned && ucCurrent != UnicodeCategory.Surrogate)) { int num = index; index += currentCharCount + charLength; while (index < len) { UnicodeCategory unicodeCategory2 = CharUnicodeInfo.InternalGetUnicodeCategory(str, index, out charLength); if (!CharUnicodeInfo.IsCombiningCategory(unicodeCategory2)) { ucCurrent = unicodeCategory2; currentCharCount = charLength; break; } index += charLength; } return(index - num); } int num1 = currentCharCount; ucCurrent = unicodeCategory1; currentCharCount = charLength; return(num1); }
//////////////////////////////////////////////////////////////////////// // // Get the code point count of the current text element. // // A combining class is defined as: // A character/surrogate that has the following Unicode category: // * NonSpacingMark (e.g. U+0300 COMBINING GRAVE ACCENT) // * SpacingCombiningMark (e.g. U+ 0903 DEVANGARI SIGN VISARGA) // * EnclosingMark (e.g. U+20DD COMBINING ENCLOSING CIRCLE) // // In the context of GetNextTextElement() and ParseCombiningCharacters(), a text element is defined as: // // 1. If a character/surrogate is in the following category, it is a text element. // It can NOT further combine with characters in the combinging class to form a text element. // * one of the Unicode category in the combinging class // * UnicodeCategory.Format // * UnicodeCateogry.Control // * UnicodeCategory.OtherNotAssigned // 2. Otherwise, the character/surrogate can be combined with characters in the combinging class to form a text element. // // Return: // The length of the current text element // // Parameters: // String str // index The starting index // len The total length of str (to define the upper boundary) // ucCurrent The Unicode category pointed by Index. It will be updated to the uc of next character if this is not the last text element. // currentCharCount The char count of an abstract char pointed by Index. It will be updated to the char count of next abstract character if this is not the last text element. // //////////////////////////////////////////////////////////////////////// internal static int GetCurrentTextElementLen(string str, int index, int len, ref UnicodeCategory ucCurrent, ref int currentCharCount) { Contract.Assert(index >= 0 && len >= 0, "StringInfo.GetCurrentTextElementLen() : index = " + index + ", len = " + len); Contract.Assert(index < len, "StringInfo.GetCurrentTextElementLen() : index = " + index + ", len = " + len); if (index + currentCharCount == len) { // This is the last character/surrogate in the string. return(currentCharCount); } // Call an internal GetUnicodeCategory, which will tell us both the unicode category, and also tell us if it is a surrogate pair or not. int nextCharCount; UnicodeCategory ucNext = CharUnicodeInfo.InternalGetUnicodeCategory(str, index + currentCharCount, out nextCharCount); if (CharUnicodeInfo.IsCombiningCategory(ucNext)) { // The next element is a combining class. // Check if the current text element to see if it is a valid base category (i.e. it should not be a combining category, // not a format character, and not a control character). if (CharUnicodeInfo.IsCombiningCategory(ucCurrent) || (ucCurrent == UnicodeCategory.Format) || (ucCurrent == UnicodeCategory.Control) || (ucCurrent == UnicodeCategory.OtherNotAssigned) || (ucCurrent == UnicodeCategory.Surrogate)) // An unpair high surrogate or low surrogate { // Will fall thru and return the currentCharCount } else { int startIndex = index; // Remember the current index. // We have a valid base characters, and we have a character (or surrogate) that is combining. // Check if there are more combining characters to follow. // Check if the next character is a nonspacing character. index += currentCharCount + nextCharCount; while (index < len) { ucNext = CharUnicodeInfo.InternalGetUnicodeCategory(str, index, out nextCharCount); if (!CharUnicodeInfo.IsCombiningCategory(ucNext)) { ucCurrent = ucNext; currentCharCount = nextCharCount; break; } index += nextCharCount; } return(index - startIndex); } } // The return value will be the currentCharCount. int ret = currentCharCount; ucCurrent = ucNext; // Update currentCharCount. currentCharCount = nextCharCount; return(ret); }