using System.Collections; using System.Collections.Generic; namespace System.Unicode { /// Allows enumeration of the code points contained in an encapsulated string, even when this one contains lone surrogates. /// /// This enumerable will allow enumeration of UTF-16 strings containing lone surrogates. /// For a more conformant enumeration of code points, please use instead. /// public struct PermissiveCodePointEnumerable : IEnumerable { /// Initializes a new instance of the struct . /// The string whose code points must be enumerated. public PermissiveCodePointEnumerable(string text) => Text = text ?? throw new ArgumentNullException(nameof(text)); /// Gets the text whose code points are being enumerated. public string Text { get; } /// Gets an enumerator which can be used to enumerate the code points in the text. /// public PermissiveCodePointEnumerator GetEnumerator() => new PermissiveCodePointEnumerator(Text); IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } }