public bool SkipEol()
{
if (pos < end)
{
char ch = str[pos];
if (ch == '\r')
{
pos++;
if (pos < end && str[pos] == '\n')
pos++;
return true;
}
else if (ch == '\n')
{
pos++;
if (pos < end && str[pos] == '\r')
pos++;
return true;
}
}
return false;
}
public static string NormalizeLineEnds(string str) { if (str.IndexOfAny(Lineends) < 0) { return(str); } var sb = new StringBuilder(); var sp = new StringScanner(str); while (!sp.Eof) { if (sp.Eol) { sb.Append('\n'); sp.SkipEol(); } else { sb.Append(sp.Current); sp.SkipForward(1); } } return(sb.ToString()); }