public static EnsureValidXMLValue ( string text ) : string | ||
text | string | The text to clean |
return | string |
public static string EnsureValidXMLValue(string text)
{
byte[] validsmallchars = new byte[] { 10, 13 };
var sb = new StringBuilder();
foreach (char c in text)
{
//Only CR,LF are valid for chars less than space (32)
if (c < ' ')
{
if (validsmallchars.Contains((byte)c))
sb.Append(c);
}
else
{
sb.Append(c);
}
}
return sb.ToString();
}