I'm trying to export a report to csv using this code:
byte[] csvBytes = AttachmentFileAgent.GetAttachmentFilesCSVBytes(context.Request["appCode"], performingPerson);
context.Response.AddHeader("content-disposition", "attachment; filename=ApplicationReport_" + context.Request["appCode"] + ".csv");
context.Response.ContentType = "text/csv;charset=utf-8";
context.Response.Charset = "utf-8";
context.Response.ContentEncoding = Encoding.UTF8;
context.Response.OutputStream.Write(csvBytes, 0, csvBytes.Length);
But the Hebrew content goes out in gibberish (׳›׳¢׳›׳’׳¢׳›׳’׳›׳¢). I tryied ising all kinds on encoding (UTF8, Unicode, ASCII) but nothing works...
Your changes to context.Response.ContentEncoding sets the encoding on the TextWriter used by context.Response.Output
When using context.Response.OutputStream you need to set the UTF-8 encoding used in your GetAttachmentFilesCSVBytesfunction.
Also see ASP.NET: Will Saving an XmlDocument to the Response.OutputStream honor the encoding?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With