开发者

C# StringWriter encoding issues

开发者 https://www.devze.com 2023-03-21 14:22 出处:网络
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 fro

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?


£ 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消