在C#中解码字符串

时间:2014-04-09 15:38:51

标签: c# decode

使用 JSON 进行解析时,我的"Suite Exécutive"文字无效。

您是否知道如何在 C#解码此文字?感谢

1 个答案:

答案 0 :(得分:2)

如果使用ASP.NET,您可以尝试

HttpUtility.HtmlDecode Method (String)

using System;
using System.Web;
using System.IO;

class MyNewClass
{
public static void Main()
{
    String myString;
    Console.WriteLine("Enter a string having '&' or '\"'  in it: ");
    myString = Console.ReadLine();
    // String myEncodedString;
    // Encode the string.

    // myEncodedString = HttpUtility.HtmlEncode(myString);
    // Console.WriteLine("HTML Encoded string is " + myEncodedString);
       StringWriter myWriter = new StringWriter();
    // Decode the encoded string.
    // HttpUtility.HtmlDecode(myEncodedString, myWriter);
    HttpUtility.HtmlDecode(myString, myWriter);
    Console.Write("Decoded string of the above encoded string is " +
                   myWriter.ToString());

    Console.Read();
}

}

.Net 4.0

System.Net.WebUtility.HtmlDecode(..)