Chris
Chris

Reputation: 7611

C# StringWriter encoding issues

I'm using a StringWriter to construct a CSV from a GridView to email/output to the user, and I'm having some issues outputting the '£' (GBP) sign - currently when it reads it from the GridView, it reads it as £, and this doesn't get encoded to the correct sign in the CSV. If I do a string replace of the ASCII code with the actual symbol, I get a little closer - the symbol appears but it also has an accented 'A' before the symbol.

Any ideas?

Upvotes: 1

Views: 1299

Answers (1)

Oded
Oded

Reputation: 498972

£ is the HTML Character entity for £, so I don't know why a StringWriter would know about it.

You need to convert from HTML to text first, for example with HttpUtility.HtmlDecode.

Upvotes: 2

Related Questions