Вопрос

I have an invalid text as following "Suite Exécutive" while parsing using JSON.

Do you know any idea of how to decode this text in C# ? Thanks

Это было полезно?

Решение

In case if are using ASP.NET you can try

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();
}

}

And on .Net 4.0

System.Net.WebUtility.HtmlDecode(..)
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top