File name contains garbled or special characters when download.
ASP.NET
1
Posts
1
Posters
0
Views
1
Watching
-
filename1 = "のサンプル"; Response.Clear(); Response.ContentType = "text/comma-separated-values"; Response.ContentEncoding = System.Text.Encoding.GetEncoding( 932 ); Response.AppendHeader("Content-Disposition", "filename=\\"" + filename + "\\""); Response.WriteFile(filepath); Response.Flush(); System.IO.File.Delete(filepath);
Above code is used for downloading japanese file, when using as above i am getting file downloaded but the file when it shows in file save as dialog contains some machine mixed special characters(non ascii). expected file name is
のサンプル
.xls and not like "a1/4a...." How to over come this issue. Hi As i found in the forum link i used this function to convert file name but this too didnt helped me out.
public static string EncodeTwit(string txt)
{
UTF8Encoding utf8 = new UTF8Encoding();
byte[] bytes = utf8.GetBytes(txt);
char[] chars = new char[bytes.Length];
for (int index = 0; index < bytes.Length; index++)
{
chars[index] = Convert.ToChar(bytes[index]);
}string s = new string(chars); return s; }