往页面里写入html字符串,显示后出现乱码,在线等
请把以下代码执行一下,执行后hotitem.aspx里是乱码
string htmlcode;
htmlcode = "<table width='195' height='170' border='0' align='center' cellpadding='0' cellspacing='0'><tr><td width='195'> <img src='images/left_04.gif' width='195' height='27'></td></tr>";
htmlcode+="<tr><td height='27' background='images/left_05.gif'>";
htmlcode+=" <a href=searchitem.aspx?in=1 target=_blank>你好</a></td></tr>";
htmlcode+="</table>";
string path = Server.MapPath("hotitem.aspx");
using (System.IO.StreamWriter sw = new StreamWriter(path,true,System.Text.Encoding.GetEncoding("GB2312")))
{
//byte[] b = Encoding.UTF8.GetBytes(htmlcode);
sw.WriteLine(htmlcode);
}
问题点数:20、回复次数:4Top
1 楼net_lover(【孟子E章】)回复于 2005-12-19 12:25:40 得分 0
<globalization requestEncoding="gb2312" responseEncoding="gb2312"/>Top
2 楼truelove12(结贴者寥寥无几,心寒ing...)回复于 2005-12-19 12:36:13 得分 0
将页面的字符集设为utf-8
web.config如 孟老大所说.Top
3 楼yjgking()回复于 2005-12-19 14:13:57 得分 20
告诉我你的邮箱,我发个例子给你.Top
4 楼bigsuncc(to be MoreHappy)回复于 2005-12-19 14:35:56 得分 0
难道见到老大回答问题。Top




