How do I convert from a possibly Windows 1252 'ANSI' encoded uploaded file to UTF8 in .NET?
Posted
by qqq123
on Stack Overflow
See other posts from Stack Overflow
or by qqq123
Published on 2009-01-22T16:34:15Z
Indexed on
2010/05/09
5:18 UTC
Read the original article
Hit count: 231
I've got a FileUpload
control in an ASP.NET web page which is used to upload a file, the contents of which (in a stream) are processed in the C# code behind and output on the page later, using HtmlEncode
.
But, some of this output is becoming mangled, specifically the symbol '£' is output as the Unicode FFFD REPLACEMENT CHARACTER. I've tracked this down to the input file, which is Windows 1252 ('ANSI') encoded.
The question is,
How do I determine whether the file is encoded as 1252 or UTF8? It could be either, and
How do I convert it to UTF8 if it is in Windows 1252, preserving the symbol £ etc?
I've looked online but cannot find a satisfactory answer.
© Stack Overflow or respective owner