I know this question have been asked before but I still can't get any answers I find to work.

For example i have this string:

string myString = "Betrakta nedanstående figur";

And i want to decode it to:

string myString = "Betrakta nedanstående figur";

What is the best approach?

有帮助吗?

解决方案

The string you have shown has strictly nothing to do with the ISO-8859-1 encoding. It's just a string containing HTML encoded entities. To decode it you could use the HttpUtility.HtmlDecode function:

string myString = "Betrakta nedanstående figur";
string myDecodedString = HttpUtility.HtmlDecode(myString);

Note that you will need to reference the System.Web assembly in order to use that method.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top