我用网页从数据库查询了一些数据,用UTF-8格式在网页中显示中文(简体字)正常,但保存下来后就显示乱码了。这是下载的时候指定的编码://Page.Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
//Page.Response.ContentEncoding = System.Text.Encoding.GetEncoding("BIG5");
Page.Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");
Page.Response.AppendHeader("Content-Disposition", "attachment;filename=" + fileName);
Page.Response.ContentType = "application/ms-excel";//设置输出文件类型为excel文件。
我的系统是繁体的不过我在语言里面设置的是China(PRC),可以看简繁体的
我的数据是从Excel中导入到数据库的,然后再保存下来原始的Excel打开是可以正常看到中文字体的。
//Page.Response.ContentEncoding = System.Text.Encoding.GetEncoding("BIG5");
Page.Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");
Page.Response.AppendHeader("Content-Disposition", "attachment;filename=" + fileName);
Page.Response.ContentType = "application/ms-excel";//设置输出文件类型为excel文件。
我的系统是繁体的不过我在语言里面设置的是China(PRC),可以看简繁体的
我的数据是从Excel中导入到数据库的,然后再保存下来原始的Excel打开是可以正常看到中文字体的。
编码问题吧!默认工程编码是Unicode编码,你可以在新建的工程的时候不要选择UNICODE编码!
或者选用MultiByteToWideChar()和WideCharToMultiByte()进行编码转换!
js中可以用escape()解决
我用Firefox去下载的时候,中文的文件名可以正常显示,但用IE就不行。
里面的内容还是一大堆的乱码。