Hi there,
I'm using a technique from another stackoverflow question here, to write a CSV file to the Response output for a User to Open/Save. This is working fine and the file looks good in Notepad, but when I open it in Excel the accented characters are garbage. I assumed this was something to do with the character encoding, so tried manually to set it to utf-8 (the StreamWriter is utf-8 by default anyhow). Here is the code:
context.Response.Clear();
context.Response.AddHeader("content-disposition", "attachment; filename=registros.csv");
context.Response.ContentType = "text/csv";
context.Response.Charset = "utf-8";
using (StreamWriter writer = new StreamWriter(context.Response.OutputStream))
{
// .... write the output file
}
context.Response.End();
Any ideas as to what else I would need to do, to correctly encode the file so as Excel can view the accented characters?