Skip to content

Instantly share code, notes, and snippets.

@pisceanfoot
Created May 20, 2014 01:21
Show Gist options
  • Save pisceanfoot/6416ea3ffdf1393c59d0 to your computer and use it in GitHub Desktop.
Save pisceanfoot/6416ea3ffdf1393c59d0 to your computer and use it in GitHub Desktop.
SSB Xml TextWriter
public class SSBXmlTextWriter : XmlTextWriter
{
private static Regex InvalidXMLCharacter = new Regex(@"[\u0000-\u0008\u000B\u000C\u000E-\u001F\uD800-\uDFFF\uFFFE\uFFFF]", RegexOptions.Compiled);
public SSBXmlTextWriter(TextWriter w)
: base(w)
{
}
public SSBXmlTextWriter(Stream w, Encoding encoding)
: base(w, encoding)
{
}
public override void WriteString(string text)
{
if (!string.IsNullOrEmpty(text))
{
text = InvalidXMLCharacter.Replace(text, " ");
}
base.WriteString(text);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment