public void Scalability() { const int count = 1 << 16; Assert.AreEqual( "&".Length * count, XmlTextEncoder.Encode(String.Empty.PadRight(count, '&')).Length); }
private void ProcessXText(XText xtext, StringBuilder sb, bool performReplacements) { //.NET likes to just drop out some of the formatting, specially the " which becomes normal old double quotes. var correctedText = XmlTextEncoder.Encode(xtext.Value); var newvalue = performReplacements ? Replace(correctedText) : correctedText; sb.Append(newvalue); }
public void IllegalChars() { var s = "foo"; Assert.AreEqual( s, XmlTextEncoder.Encode(String.Format("\u0000\u0001\u000b{0}\u000e\u007f\u0086\uFFFE", s))); }
public void EntityStrings() { Assert.AreEqual("<foo />", XmlTextEncoder.Encode("<foo />")); Assert.AreEqual( "<foo bar="baz"></foo>", XmlTextEncoder.Encode("<foo bar=\"baz\"></foo>")); Assert.AreEqual("'&'", XmlTextEncoder.Encode("'&'")); }
public void SimpleStrings() { Assert.AreEqual(String.Empty, XmlTextEncoder.Encode(String.Empty)); var s = "foo\nbar"; Assert.AreEqual(s, XmlTextEncoder.Encode(s)); }
public string Parse(string input) { string trimmedInput = TrimBlankLines(input); trimmedInput = TrimUnessecaryIndents(trimmedInput); //TODO: remove all the leading whitespace. var encoded = XmlTextEncoder.Encode(trimmedInput); var sb = new StringBuilder(); sb.AppendLine("<div class=\"csharpcode\">"); sb.AppendLine(encoded); sb.Append("</div>"); return(sb.ToString()); }
private static string Escape(char ch) { return(XmlTextEncoder.Encode(new string(ch, 1))); }
public void IllegalSurrogates() { Assert.AreEqual(String.Empty, XmlTextEncoder.Encode("\xD834")); Assert.AreEqual(String.Empty, XmlTextEncoder.Encode("\xDD1E")); Assert.AreEqual("foobar", XmlTextEncoder.Encode("foo\xDD1E\xD834bar")); }
public void LegalSurrogates() { var s = "foo\xD834\xDD1Ebar"; Assert.AreEqual(s, XmlTextEncoder.Encode(s)); }