namespace Umbraco.Tests
{
static class StringNewLineExtensions
{
///
/// Ensures Lf only everywhere.
///
/// The text to filter.
/// The filtered text.
public static string Lf(this string text)
{
if (string.IsNullOrEmpty(text)) return text;
text = text.Replace("\r", ""); // remove CR
return text;
}
///
/// Ensures CrLf everywhere.
///
/// The text to filter.
/// The filtered text.
public static string CrLf(this string text)
{
if (string.IsNullOrEmpty(text)) return text;
text = text.Replace("\r", ""); // remove CR
text = text.Replace("\n", "\r\n"); // add CRLF everywhere
return text;
}
///
/// Replaces Cr/Lf by a single space.
///
/// The text to filter.
/// The filtered text.
public static string NoCrLf(this string text)
{
if (string.IsNullOrEmpty(text)) return text;
text = text.Replace("\r\n", " "); // remove CRLF
text = text.Replace("\r", " "); // remove CR
text = text.Replace("\n", " "); // remove LF
return text;
}
}
}