utf-8是否带签名 乱码问题。

 Encoding utf8 = new UTF8Encoding(true);

参数表示是否带签名,

但此是否带签名在WriteAllBytes 无效,生成的永远是无签名的。

但在WriteAllText中有效。

 Encoding utf8 = new UTF8Encoding(true);
        ////utf8.s = "65001";

        //var utf8 = System.Text.Encoding.GetEncoding(65001);
        var bys = utf8.GetBytes("测试生成页面" + DateTime.Now.ToString());
        System.IO.File.WriteAllBytes(Server.MapPath("~/") + "b.html", bys);

        File.WriteAllText(Server.MapPath("~/") + "a.html", Encoding.UTF8.GetString(bys) + ",最新", new UTF8Encoding(true));

 

posted @ 2014-01-24 15:56  Shikyoh  阅读(825)  评论(0编辑  收藏  举报