Created
May 20, 2014 01:21
-
-
Save pisceanfoot/6416ea3ffdf1393c59d0 to your computer and use it in GitHub Desktop.
SSB Xml TextWriter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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