当前位置:编程学习 > C#/ASP.NET >>

关于编码的一个问题。请教大家。

string filename = "昨日信息" + DateTime.Now.AddDays(-1).ToShortDateString()+".doc";
            Response.Charset = "GB2312";
            Response.ContentEncoding = System.Text.Encoder("GB2312");
            Response.AddHeader("Content-Disposition", "attachment;filename="+HttpUtility.UrlEncode(filename,System.Text.Encoding.Default));

怎么输出的是乱码啊?? 请教一下如何修改为中文。。。
--------------------编程问答-------------------- string filename = "昨日信息" + DateTime.Now.AddDays(-1).ToShortDateString()+".doc";
你这个文件原来是什么编码的就设置成什么编码,一般是默认UTF8的
Response.Charset = "UTF8";
  Response.ContentEncoding = System.Text.Encoder("UTF8");

具体的看文件

--------------------编程问答-------------------- --------------------编程问答-------------------- 应该是用HttpUtility.UrlEncode才对。。 --------------------编程问答-------------------- Response.ContentEncoding = System.Text.Encoding.UTF7;
  Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString());
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,