+ -
当前位置:首页 → 问答吧 → 日中 韩文 中文 乱码 问题

日中 韩文 中文 乱码 问题

时间:2011-12-26

来源:互联网

C# code
            System.IO.StringWriter sw = new System.IO.StringWriter();
            sw.WriteLine(" 파이브커피숍・スター・ダイアモン中文");
            sw.Close();
          
            Response.Clear();
            Response.Buffer = true;      
            HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + DateTime.Now.ToShortDateString() +".xls");
            HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";

            HttpContext.Current.Response.Charset = "UTF-8";
            HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default;

            HttpContext.Current.Response.Write(sw.ToString());
            HttpContext.Current.Response.End();
            


以上 会乱码 求大牛们 支招 不胜感激!

作者: rolloxa   发布时间: 2011-12-26

改为:
HttpContext.Current.Response.Charset = "UTF-8";
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;

编码要一致。在简体中文操作系统中,Default一般默认为gb2312,所以不一致。。

作者: dalmeeme   发布时间: 2011-12-26

C# code
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;

这句我试过 改成这样的话 就彻底 都乱码了
引用 1 楼 dalmeeme 的回复:

改为:
HttpContext.Current.Response.Charset = "UTF-8";
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;

编码要一致。在简体中文操作系统中,Default一般默认为gb2312,所以不一致。。

作者: rolloxa   发布时间: 2011-12-26

热门下载

更多