Drunken Daddy
Drunken Daddy

Reputation: 8001

C# how to decode html character squared ($sup2)

I am getting a string "lb/in&sup2" (which I want to show as lb/in²) from server. I want to decode this and show it in my Xamarin.iOS app.

I tried:

System.Net.WebUtility.HtmlDecode("lb/in&sup2")

but its not working, still shows as "lb/in&sup2".

Upvotes: 1

Views: 622

Answers (1)

Evk
Evk

Reputation: 101583

Html entity should end with ";" character. This should work fine:

System.Net.WebUtility.HtmlDecode("lb/in²");

If you are getting string exactly as you posted - you should fix the side which you are getting this string from, because "&sup2" is not html entity, it's just a "&sup2" string.

Upvotes: 1

Related Questions