using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace System.Unicode { /// Allows enumeration of the code points contained in an encapsulated string. /// /// This enumerable will only allow enumeration of valid UTF-16 strings. /// For incomplete or invalid UTF-16 strings, please use instead. /// public struct CodePointEnumerable : IEnumerable { private readonly string text; /// Initializes a new instance of the struct . /// The string whose code points must be enumerated. public CodePointEnumerable(string text) { if (text == null) throw new ArgumentNullException(nameof(text)); this.text = text; } /// Gets the text whose code points are being enumerated. public string Text { get { return text; } } /// Gets an enumerator which can be used to enumerate the code points in the text. public CodePointEnumerator GetEnumerator() { return new CodePointEnumerator(text); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } } }