0

See this code:

namespace TestHtmlDecode
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using System.Web;

    [TestClass]
    public class TestHtmlDecode
    {
        private string Convert(string input)
        {
            return HttpUtility.HtmlDecode(input);
        }

        [TestMethod]
        public void TestLeftBrace()
        {
            Assert.AreEqual("{", Convert("{"));
        }

        [TestMethod]
        public void TestGreaterThan()
        {
            Assert.AreEqual(">", Convert(">"));
        }
    }
}

TestGreaterThan passes, but TestLeftBrace fails (Convert returns {). Why is this?

Maria Ines Parnisari
  • 16,584
  • 9
  • 85
  • 130

1 Answers1

3

Looks like there are two things going on here.

  1. &lbrace is a { and not [ (http://jsfiddle.net/B7AAh/1/)

  2. It doesn't look like &lbrace is included in the list of of known items. Source code is here http://referencesource.microsoft.com/#System/net/System/Net/WebUtility.cs which refers to the list of entities found here http://www.w3.org/TR/REC-html40/sgml/entities.html

Joe
  • 5,389
  • 7
  • 41
  • 63
  • 1. Oops that was a mistake :) 2. Do you know what I can use to replace `HtmlDecode()`? – Maria Ines Parnisari Jul 27 '14 at 01:41
  • 1
    Sorry, I don't know of anything. Would probably be pretty straightforward to wrap a call to to it and then have a secondary list though? Want to start a new project :) ? – Joe Jul 27 '14 at 02:03