2017-09-07 23:10:17 +02:00
|
|
|
namespace System.Unicode
|
2014-11-01 02:26:07 +01:00
|
|
|
{
|
2014-12-15 01:57:09 +01:00
|
|
|
/// <summary>Contains extension methods applicable to the <see cref="string"/> type.</summary>
|
2014-11-01 02:26:07 +01:00
|
|
|
public static class StringExtensions
|
|
|
|
|
{
|
2014-12-15 01:57:09 +01:00
|
|
|
/// <summary>Encapsulates the string in an object which can be used to enumerate code points.</summary>
|
|
|
|
|
/// <remarks>
|
|
|
|
|
/// The enumerable returned by this method enumerates code points in a strict manner.
|
|
|
|
|
/// If the string contains lone surrogates, the enumeration will throw.
|
|
|
|
|
/// </remarks>
|
|
|
|
|
/// <param name="s">The string to encapsulate.</param>
|
|
|
|
|
/// <returns>An enumerable object, which can be used to enumerate code points in the string.</returns>
|
2014-11-01 02:26:07 +01:00
|
|
|
public static CodePointEnumerable AsCodePointEnumerable(this string s)
|
|
|
|
|
{
|
|
|
|
|
return new CodePointEnumerable(s);
|
|
|
|
|
}
|
2014-11-26 22:27:09 +01:00
|
|
|
|
2014-12-15 01:57:09 +01:00
|
|
|
/// <summary>Encapsulates the string in an object which can be used to enumerate code points in a permissive way.</summary>
|
|
|
|
|
/// <remarks>
|
|
|
|
|
/// The enumerable returned by this method is permissive, regarding the code points represented.
|
|
|
|
|
/// It allows invalid sequences, such as lone surrogates, the enumeration will handle those gracefully.
|
|
|
|
|
/// </remarks>
|
|
|
|
|
/// <param name="s">The string to encapsulate.</param>
|
|
|
|
|
/// <returns>An enumerable object, which can be used to enumerate code points in the string.</returns>
|
2014-11-26 22:27:09 +01:00
|
|
|
public static PermissiveCodePointEnumerable AsPermissiveCodePointEnumerable(this string s)
|
|
|
|
|
{
|
|
|
|
|
return new PermissiveCodePointEnumerable(s);
|
|
|
|
|
}
|
2014-11-01 02:26:07 +01:00
|
|
|
}
|
|
|
|
|
}
|