public void Scalability()
        {
            const int count = 1 << 16;

            Assert.AreEqual(
                "&amp;".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 &quot; 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("&lt;foo /&gt;", XmlTextEncoder.Encode("<foo />"));
     Assert.AreEqual(
         "&lt;foo bar=&quot;baz&quot;&gt;&lt;/foo&gt;",
         XmlTextEncoder.Encode("<foo bar=\"baz\"></foo>"));
     Assert.AreEqual("&apos;&amp;&apos;", XmlTextEncoder.Encode("'&'"));
 }
        public void SimpleStrings()
        {
            Assert.AreEqual(String.Empty, XmlTextEncoder.Encode(String.Empty));

            var s = "foo\nbar";

            Assert.AreEqual(s, XmlTextEncoder.Encode(s));
        }
Exemple #6
0
        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());
        }
Exemple #7
0
 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));
        }