文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>HttpWebRequest以UTF-8编码写入内容时发生“Bytes to be written to the stream exceed the

HttpWebRequest以UTF-8编码写入内容时发生“Bytes to be written to the stream exceed the

时间:2010-12-13  来源:Gildor Wang

request.ContentLength = Encoding.UTF8.GetByteCount(content);
var writer = new StreamWriter(request.GetRequestStream(), Encoding.UTF8);
writer.Write(content);
writer.Flush();
writer.Close();

原因是直接使用Encoding.UTF8,在StreamWriter中使用这个Encoding会在流的开头写入byte order mark. 解决方法是改用new UTF8Encoding(false)来构造不写入byte order mark的Encoding.

排行榜 更多 +
mirrox模组(玩家自制)手机版下载

mirrox模组(玩家自制)手机版下载

休闲益智 下载
集装箱模拟器手机版下载安装

集装箱模拟器手机版下载安装

模拟经营 下载
哔咔漫画app下载免费2025

哔咔漫画app下载免费2025

浏览阅读 下载