我有一个辅助方法:
public static string StripHtml(this string text)
{
text = HttpUtility.HtmlDecode(text);
text = Regex.Replace(text, @"<(.|\n)*?>", "");
return text;
}
还有一个单元测试:
[Test]
public void StripHtmlConvertsNbspEntityIntoSpace()
{
string result = "A B".StripHtml();
Assert.AreEqual("A B", result);
}
当我运行单元测试时,它失败并出现以下错误:
String lengths are both 3. Strings differ at index 1.
Expected: "A B"
But was: "A B"
------------^
所以我的问题是,为什么
没有解码成空格字符?