我有来自xml模板的字符,例如:
& >
Run Code Online (Sandbox Code Playgroud)
框架中是否存在通用函数以用它们的正常等价替换它们?
And*_*are 54
将已经过HTML编码的HTTP传输字符串转换为已解码的字符串.
有时文本的某些部分经过双重编码。
例如:"Lorem Ipsum
    - Blah"
这可能会有所帮助:
public static string RecursiveHtmlDecode(string str) {
if (string.IsNullOrWhiteSpace(str)) return str;
var tmp = HttpUtility.HtmlDecode(str);
while (tmp != str)
{
str = tmp;
tmp = HttpUtility.HtmlDecode(str);
}
return str; //completely decoded string
}
Run Code Online (Sandbox Code Playgroud)