using System; using System.Collections; using System.Runtime.InteropServices; namespace System.Globalization { /// Provides functionality to split a string into text elements and to iterate through those text elements. // Token: 0x02000196 RID: 406 [ComVisible(true)] [Serializable] public class StringInfo { /// Initializes a new instance of the class. // Token: 0x0600149C RID: 5276 RVA: 0x0004F66C File Offset: 0x0004D86C public StringInfo() { } /// Initializes a new instance of the class to a specified string. /// A string to initialize this object. /// /// is null. // Token: 0x0600149D RID: 5277 RVA: 0x0004F674 File Offset: 0x0004D874 public StringInfo(string value) { this.String = value; } /// Indicates whether the current object is equal to a specified object. /// true if the parameter is a object and its property equals the property of this object; otherwise, false. /// An object. // Token: 0x0600149E RID: 5278 RVA: 0x0004F684 File Offset: 0x0004D884 [ComVisible(false)] public override bool Equals(object value) { StringInfo stringInfo = value as StringInfo; return stringInfo != null && this.s == stringInfo.s; } /// Calculates a hash code for the value of the current object. /// A 32-bit signed integer hash code based on the string value of this object. // Token: 0x0600149F RID: 5279 RVA: 0x0004F6B4 File Offset: 0x0004D8B4 [ComVisible(false)] public override int GetHashCode() { return this.s.GetHashCode(); } /// Gets the number of text elements in the current object. /// The number of base characters, surrogate pairs, and combining character sequences in this object. // Token: 0x170003A6 RID: 934 // (get) Token: 0x060014A0 RID: 5280 RVA: 0x0004F6C4 File Offset: 0x0004D8C4 public int LengthInTextElements { get { if (this.length < 0) { this.length = 0; int i = 0; while (i < this.s.Length) { i += StringInfo.GetNextTextElementLength(this.s, i); this.length++; } } return this.length; } } /// Gets or sets the value of the current object. /// The string that is the value of the current object. /// The value in a set operation is null. // Token: 0x170003A7 RID: 935 // (get) Token: 0x060014A1 RID: 5281 RVA: 0x0004F720 File Offset: 0x0004D920 // (set) Token: 0x060014A2 RID: 5282 RVA: 0x0004F728 File Offset: 0x0004D928 public string String { get { return this.s; } set { if (value == null) { throw new ArgumentNullException("value"); } this.length = -1; this.s = value; } } /// Retrieves a substring of text elements from the current object starting from a specified text element and continuing through the last text element. /// A substring of text elements in this object, starting from the text element index specified by the parameter and continuing through the last text element in this object. /// The zero-based index of a text element in this object. /// /// is less than zero.-or-The string that is the value of the current object is the empty string (""). // Token: 0x060014A3 RID: 5283 RVA: 0x0004F74C File Offset: 0x0004D94C public string SubstringByTextElements(int startingTextElement) { if (startingTextElement < 0 || this.s.Length == 0) { throw new ArgumentOutOfRangeException("startingTextElement"); } int num = 0; for (int i = 0; i < startingTextElement; i++) { if (num >= this.s.Length) { throw new ArgumentOutOfRangeException("startingTextElement"); } num += StringInfo.GetNextTextElementLength(this.s, num); } return this.s.Substring(num); } /// Retrieves a substring of text elements from the current object starting from a specified text element and continuing through the specified number of text elements. /// A substring of text elements in this object. The substring consists of the number of text elements specified by the parameter and starts from the text element index specified by the parameter. /// The zero-based index of a text element in this object. /// The number of text elements to retrieve. /// /// is less than zero.-or- is greater than or equal to the length of the string that is the value of the current object.-or- is less than zero.-or-The string that is the value of the current object is the empty string ("").-or- + specify an index that is greater than the number of text elements in this object. // Token: 0x060014A4 RID: 5284 RVA: 0x0004F7C8 File Offset: 0x0004D9C8 public string SubstringByTextElements(int startingTextElement, int lengthInTextElements) { if (startingTextElement < 0 || this.s.Length == 0) { throw new ArgumentOutOfRangeException("startingTextElement"); } if (lengthInTextElements < 0) { throw new ArgumentOutOfRangeException("lengthInTextElements"); } int num = 0; for (int i = 0; i < startingTextElement; i++) { if (num >= this.s.Length) { throw new ArgumentOutOfRangeException("startingTextElement"); } num += StringInfo.GetNextTextElementLength(this.s, num); } int num2 = num; for (int j = 0; j < lengthInTextElements; j++) { if (num >= this.s.Length) { throw new ArgumentOutOfRangeException("lengthInTextElements"); } num += StringInfo.GetNextTextElementLength(this.s, num); } return this.s.Substring(num2, num - num2); } /// Gets the first text element in a specified string. /// A string containing the first text element in the specified string. /// The string from which to get the text element. /// /// is null. // Token: 0x060014A5 RID: 5285 RVA: 0x0004F898 File Offset: 0x0004DA98 public static string GetNextTextElement(string str) { if (str == null || str.Length == 0) { throw new ArgumentNullException("string is null"); } return StringInfo.GetNextTextElement(str, 0); } /// Gets the text element at the specified index of the specified string. /// A string containing the text element at the specified index of the specified string. /// The string from which to get the text element. /// The zero-based index at which the text element starts. /// /// is null. /// /// is outside the range of valid indexes for . // Token: 0x060014A6 RID: 5286 RVA: 0x0004F8C0 File Offset: 0x0004DAC0 public static string GetNextTextElement(string str, int index) { int nextTextElementLength = StringInfo.GetNextTextElementLength(str, index); return (nextTextElementLength == 1) ? new string(str[index], 1) : str.Substring(index, nextTextElementLength); } // Token: 0x060014A7 RID: 5287 RVA: 0x0004F8F8 File Offset: 0x0004DAF8 private static int GetNextTextElementLength(string str, int index) { if (str == null) { throw new ArgumentNullException("string is null"); } if (index >= str.Length) { return 0; } if (index < 0) { throw new ArgumentOutOfRangeException("Index is not valid"); } char c = str[index]; UnicodeCategory unicodeCategory = char.GetUnicodeCategory(c); if (unicodeCategory == UnicodeCategory.Surrogate) { if (c < '\ud800' || c > '\udbff') { return 1; } if (index + 1 < str.Length && str[index + 1] >= '\udc00' && str[index + 1] <= '\udfff') { return 2; } return 1; } else { if (unicodeCategory == UnicodeCategory.NonSpacingMark || unicodeCategory == UnicodeCategory.SpacingCombiningMark || unicodeCategory == UnicodeCategory.EnclosingMark) { return 1; } int num = 1; while (index + num < str.Length) { unicodeCategory = char.GetUnicodeCategory(str[index + num]); if (unicodeCategory != UnicodeCategory.NonSpacingMark && unicodeCategory != UnicodeCategory.SpacingCombiningMark && unicodeCategory != UnicodeCategory.EnclosingMark) { break; } num++; } return num; } } /// Returns an enumerator that iterates through the text elements of the entire string. /// A for the entire string. /// The string to iterate through. /// /// is null. // Token: 0x060014A8 RID: 5288 RVA: 0x0004F9F8 File Offset: 0x0004DBF8 public static TextElementEnumerator GetTextElementEnumerator(string str) { if (str == null || str.Length == 0) { throw new ArgumentNullException("string is null"); } return new TextElementEnumerator(str, 0); } /// Returns an enumerator that iterates through the text elements of the string, starting at the specified index. /// A for the string starting at . /// The string to iterate through. /// The zero-based index at which to start iterating. /// /// is null. /// /// is outside the range of valid indexes for . // Token: 0x060014A9 RID: 5289 RVA: 0x0004FA20 File Offset: 0x0004DC20 public static TextElementEnumerator GetTextElementEnumerator(string str, int index) { if (str == null) { throw new ArgumentNullException("string is null"); } if (index < 0 || index >= str.Length) { throw new ArgumentOutOfRangeException("Index is not valid"); } return new TextElementEnumerator(str, index); } /// Returns the indexes of each base character, high surrogate, or control character within the specified string. /// An array of integers that contains the zero-based indexes of each base character, high surrogate, or control character within the specified string. /// The string to search. /// /// is null. // Token: 0x060014AA RID: 5290 RVA: 0x0004FA64 File Offset: 0x0004DC64 public static int[] ParseCombiningCharacters(string str) { if (str == null) { throw new ArgumentNullException("string is null"); } ArrayList arrayList = new ArrayList(str.Length); TextElementEnumerator textElementEnumerator = StringInfo.GetTextElementEnumerator(str); textElementEnumerator.Reset(); while (textElementEnumerator.MoveNext()) { arrayList.Add(textElementEnumerator.ElementIndex); } return (int[])arrayList.ToArray(typeof(int)); } // Token: 0x040005D8 RID: 1496 private string s; // Token: 0x040005D9 RID: 1497 private int length; } }