I am accessing data from an SQL Server database to my ASP.Net C# based website. This data is received from affiliate companies and contains
&#163; for the £ sign. But when I display this data inside a label, instead of
£ it shows
& is converted to
I know it's a character encoding problem and I've tried to provide the character encoding as 'utf-8' and also 'ISO-8859-1' in the header.
Which character encoding should I use to solve the problem?Answer1:
It's not a problem with finding the correct character encoding to turn the bytes into text, it's how the text has been encoded (or rather escaped).
The problem is that the text has been HTML encoded twice. The first time it turns the
£, the second time into
So, to correct this you have to use the
HtmlDecode method to reverse the second step.
&#163 <strong>should</strong> render as £. By using the & you've escaped the HTML escape code.Answer3:
It appears to be encoded twice and decoded only once. What was the step it goes through ?