在服务器上生成文件的内容..给客户端直接下载.文件必需是unicode编码格式,代码.string fileName = "aaaa.csv";
StringWriter sw = new StringWriter();
sw.WriteLine("abs中文");
this.Response.Clear();
this.Response.Buffer = true;
this.Response.Filter.Close();
this.Response.ContentEncoding = System.Text.Encoding.Unicode;
this.Response.Charset = "Unicode";
this.Response.AddFileDependency(fileName);
this.Response.ContentType = "text/csv";
this.Response.AppendHeader("Content-Disposition", "attachment;filename=" + fileName);
this.Response.Write(sw);
this.Response.End();
sw.Close();
如果字符串里没有中文,下载下来的文件就是unicode编码的文件,如果有中文就不是,中文也变在乱码.请教这个要怎么解决?
StringWriter sw = new StringWriter();
sw.WriteLine("abs中文");
this.Response.Clear();
this.Response.Buffer = true;
this.Response.Filter.Close();
this.Response.ContentEncoding = System.Text.Encoding.Unicode;
this.Response.Charset = "Unicode";
this.Response.AddFileDependency(fileName);
this.Response.ContentType = "text/csv";
this.Response.AppendHeader("Content-Disposition", "attachment;filename=" + fileName);
this.Response.Write(sw);
this.Response.End();
sw.Close();
如果字符串里没有中文,下载下来的文件就是unicode编码的文件,如果有中文就不是,中文也变在乱码.请教这个要怎么解决?
解决方案 »
- 客户如果不满意,则弹出对话框,让他填写不满意的原因
- 急!怎样对一个快完成的asp.net(电子商务)网站进行测试找错
- 弹出对话框问题
- 安装SQL Server 2000时,到最后一步(连接服务器)时报错怎么办,又不想重装系统
- 不支持此服务器版本,仅支持Microsoft sql server 2005以下版本的服务器?请问这是怎么回事?
- 我在把项目添加到源代码管理器的时候
- csdn重新开张,问个问题,在asp.net怎末显示个对话框?
- 问一个触发器的问题
- asp.net 开发的网站,页面里使用jquery下的AJAX ,在VS2005下调试正常,部署到IIS6下就不行了 求解答
- 帮忙看看!
- 怎么将合并了表头的Grid数据,原样导出至Excel呀?大家帮忙呀!急急急----
- Asp.net2005 连接一个文件夹下面的多个access数据库100分长期在线
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />2,html页面(aspx页面),及cs文件保存时采用的编码为utf-8这样,一般不会有问题.
内容如下
system.web>
<globalization fileEncoding="gb2312" requestEncoding="gb2312" responseEncoding="gb2312" culture="zh-CN" uiCulture="zh-CN"/>
<!--
设置 compilation debug="true" 将调试符号插入
已编译的页面中。但由于这会
影响性能,因此只在开发过程中将此值
设置为 true。
-->
<compilation debug="true">
1
开始>>附件>>记事本>>随便敲几个字母,比如abcde.然后点保存,存为a.txt(默认为ansi)
2
开始>>附件>>记事本>>随便敲几个字母,比如abcde.然后点保存,不要急着保存,在保存对话框那里,编码那里选utf-8,再存为b.txt用记录本分别打开a.txt和b.txt你看到的内容是一样的.
用ultra eidt等其它工具,以二进制方式查看文件,你看到的内容是不一样的.做完我上面说的, 再回头看我在4楼的回贴,你就明白我的意思了.