Encoding difficulties: £ displaying instead of £
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 £
for the £ sign. But when I display this data inside a label, instead of £
it shows £
.
Note: The &
is converted to &
.
I know it's a character encoding pr开发者_C百科oblem 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?
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 £
into £
, the second time into £
.
So, to correct this you have to use the HtmlDecode
method to reverse the second step.
&#163 should render as £. By using the & you've escaped the HTML escape code.
It appears to be encoded twice and decoded only once. What was the step it goes through ?
精彩评论