【问题标题】:C# string unescape '&#xxx;' [duplicate]C# 字符串 unescape '&#xxx;' [复制]
【发布时间】:2015-03-30 15:32:50
【问题描述】:

如何取消转义包含 xx; 的字符串?

例子:

“Quelque petite scratch sur lécran

“Quelque petite scratch sur lécran

è | è

é | é

【问题讨论】:

  • 不使用变音符号
  • 编码字符中的'来自哪里?它应该是 è和 é没有'
  • 我把它放在那里是因为浏览器正在将它替换为它们的实际字符 XD
  • @Cedric,我从你的帖子中删除了 '

标签: c# string


【解决方案1】:

WebUtility.HtmlDecode 应该可以解决问题,例如

using System;
using System.Net;

public class Program
{
    public static void Main()
    {
        string b = WebUtility.HtmlDecode("Quelque petite scratch sur lécran");

        Console.WriteLine("After HtmlDecode: " + b);

    }
}

https://dotnetfiddle.net/148gYR

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-04-15
    • 1970-01-01
    • 2019-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多