views:

218

answers:

2

I want to export csv file that contains hebrew character in my ASP.net MVC application

I have tried many encoding but not work. Actually hebrew characters and not displaying as they are.

Can anybody have idea?

 System.Text.UnicodeEncoding Enc = new UnicodeEncoding();

        HttpContext.Current.Response.AddHeader("Content-Length", Enc.GetByteCount(strExport).ToString());
        HttpContext.Current.Response.BinaryWrite(Enc.GetBytes(strExport));
        HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("windows-1255");
        //HttpContext.Current.Response.Charset = "iso-8859-8";
        HttpContext.Current.Response.ContentType = "text/csv";
        HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment;inline; filename={0}.csv", fileName));

        HttpContext.Current.Response.End();
A: 

Hey,

Check this out and see if setting the encoding helps: http://msdn.microsoft.com/en-us/library/system.text.encoding.aspx

Brian
A: 

Once upon a time we had multiple clients, including Hebrew, text files for import into MySQL, Sql Server, etc. The company had standardized on UTF8 as the encoding for everything. That was a few years ago, so ymmv.

Might be easier to debug if you show us a code sample.

qor72