2017-09-07 23:10:17 +02:00
|
|
|
using System.Collections;
|
2014-11-26 22:27:09 +01:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
namespace System.Unicode
|
|
|
|
|
{
|
2014-12-15 01:57:09 +01:00
|
|
|
/// <summary>Allows enumeration of the code points contained in an encapsulated string, even when this one contains lone surrogates.</summary>
|
|
|
|
|
/// <remarks>
|
|
|
|
|
/// This enumerable will allow enumeration of UTF-16 strings containing lone surrogates.
|
|
|
|
|
/// For a more conformant enumeration of code points, please use <see cref="CodePointEnumerable"/> instead.
|
|
|
|
|
/// </remarks>
|
2014-11-26 22:27:09 +01:00
|
|
|
public struct PermissiveCodePointEnumerable : IEnumerable<int>
|
|
|
|
|
{
|
2014-12-15 01:57:09 +01:00
|
|
|
/// <summary>Initializes a new instance of the struct <see cref="PermissiveCodePointEnumerable"/>.</summary>
|
|
|
|
|
/// <param name="text">The string whose code points must be enumerated.</param>
|
2017-09-07 23:10:17 +02:00
|
|
|
public PermissiveCodePointEnumerable(string text) => Text = text ?? throw new ArgumentNullException(nameof(text));
|
2014-11-26 22:27:09 +01:00
|
|
|
|
2014-12-15 01:57:09 +01:00
|
|
|
/// <summary>Gets the text whose code points are being enumerated.</summary>
|
2017-09-07 23:10:17 +02:00
|
|
|
public string Text { get; }
|
2014-11-26 22:27:09 +01:00
|
|
|
|
2014-12-15 01:57:09 +01:00
|
|
|
/// <summary>Gets an enumerator which can be used to enumerate the code points in the text.</summary>
|
|
|
|
|
/// <returns></returns>
|
2017-09-07 23:10:17 +02:00
|
|
|
public PermissiveCodePointEnumerator GetEnumerator() => new PermissiveCodePointEnumerator(Text);
|
2014-11-26 22:27:09 +01:00
|
|
|
|
2017-09-07 23:10:17 +02:00
|
|
|
IEnumerator<int> IEnumerable<int>.GetEnumerator() => GetEnumerator();
|
2014-11-26 22:27:09 +01:00
|
|
|
|
2017-09-07 23:10:17 +02:00
|
|
|
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
2014-11-26 22:27:09 +01:00
|
|
|
}
|
|
|
|
|
}
|