这两段代码是两个不同聊天室的main框架主页的content部分的代码,为什么第一个没加content="text/html; charset=gb2312就不出现乱码呢?而另一个会出现乱吗呢
他们到底有什么不同?
第一段没出现乱码的代码
<html>
<head>
<meta http-equiv="refresh" content="10;url=content.asp">
<title>聊天内容</title>
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<base target="ltop">
</head>
<body bgcolor="rgb(254,252,237)">
<%
'response.write application("AllCanSee")
'application("AllCanSee")=application("AllCanSee")& "you are welcome!<br>"
if application("Private" & session("NUM"))<>"/\" then
%>
<% =application("Private" & session("NUM")) %>
<% else %>
<%
'将其踢出聊天室
if session("NUM")<>"" then
application("VisitorNum")=application("VisitorNum")-1
application("Private" & session("NUM"))=""
dim i,j,num
i=1
j=1
num=0
dim Name(10)
'删除使用者名字和代号
do while j<>0
j=instr(i,application("VisitorName"),";",1)
if j<>0 then
num=num+1
str=mid(application("VisitorName"),i,j-i)
temppos=instr(1,str,",",1)+1
UserNum=mid(str,temppos)
if UserNum=cstr(session("NUM")) then
i=i-1
j=j+1
application("VisitorName")=mid(application("VisitorName"),1,i) & mid(application("VisitorName"),j)
exit do
end if
end if
i=j+1
loop
session("NUM")=""
session.abandon
end if
%>
<p><font color="#FF0000"><strong><font face="隶书"><big><big>不好意思,鉴于你的表现,你不能继续留在这!</big></big></font></strong>
<% end if %></font></p>
</body>
</html>
第二段出现乱码的文件
<html>
<head>
<!--??ò3??????10???ó?¢D?ò?′?-->
<meta http-equiv="refresh" content="10;url=content.asp?user=<%=UserID%>">
<title>á?ìì?úèY</title>
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<base target="ltop">
</head>
<body bgcolor="rgb(254,252,237)">
<%
dim info
dim changed
set newconn=server.CreateObject("ADODB.Connection")
newconn.ConnectionString="DSN=ChatRoom"
newconn.Open
if Request.ServerVariables("REQUEST_METHOD")="GET" then
UserID=Request.QueryString("user")
myname=session("myname")'Request.QueryString("roomname")
end if
if Request.ServerVariables("REQUEST_METHOD")="POST" then
myname=Request.Form("userid")
UserID=myname
myroom=session("myroom")'Request.Form("roomname")
mynickname=Request.Form("mynickname")
newsql="update UserOnLine set TimeLastTalking='"&now&"'where UserID='"&UserID&"'"
newconn.Execute(newsql)
Application.Lock()
if left(Request.Form("T1"),1)="/"then
command=Request.Form("T1")
select case left(Request.Form("T1"),2)
case "/j"
newroom=trim(mid(Request.Form("T1"),4))
newsql="select RoomName,IfLocked,WhoCreate from RoomInfo where RoomName='"&newroom&"'"
set newrecord=newconn.Execute(newsql)
if newrecord.bof or newrecord.eof then
Application(UserID)="??óD?a??·???o?!<br><br>"&Application(UserID)
elseif newrecord("IfLocked")=true then
newsql="select UserID from UserOnLine where RoomName='"&newroom&"'and UserID='"&newrecord(2)&"'"
set myrecord=newconn.Execute(newsql)
if not myrecord.Bof then
Application(UserID)="?a??·???ò?é???,2??ü??è?£?<br><br>"&Application(UserID)
else
Create_Leaved=true
newsql="update RoomInfo set IfLocked=false where RoomName='"&newroom&"'"
newconn.execute(newsql)
end if
elseif Create_Leaved=false then
newsql1="select UserID from UserOnLine where RoomName='"&newroom&"'"
set newrecord1=server.CreateObject("ADODB.Recordset")
newrecord1.Open newsql1,"DSN=ChatRoom",1,3
do while not newrecord1.eof
tempname=cstr(newrecord1("UserID"))
if tempname<>UserID then
Application(tempname)="<br>"&mynickname&"′óò?′ó°úμ???à′á?£?£¨???¢D?)<font color=blue size=1>("&time()&")</font><br><br>"&Application(tempname)
end if
newrecord1.movenext
loop
newsql3="update RoomInfo set HowManyUsers=HowManyUsers+1 where RoomName='"&newroom&"'"
newconn.Execute(newsql3)
newsql4="update RoomInfo set HowManyUsers=HowManyUsers-1 where RoomName='"&myroom&"'"
newconn.Execute(newsql4)
newsql2="update UserOnLine set RoomName='"&newroom&"'where UserID='"&UserID&"'"
newconn.Execute(newsql2)
Application(UserID)="??ò??-??è?á?·???"&newroom&"<br>"&Application(UserID)
session("myroom")=newroom
changed=true
newrecord1.Close
set newrecord1=nothing
end if
case "/r"
newsql="select * from RoomInfo"
set newrecordset1=newconn.Execute(newsql)
do while not newrecordset1.eof
info=info & newrecordset1("RoomName")& "--" & newrecordset1("HowManyUsers") & "--" & newrecordset1("Topic") & "--" & newrecordset1("IfLocked") & "--" &newrecordset1("WhoCreate") & "<br>"
newrecordset1.movenext
loop
Application(UserID)=info &"<br>" &Application(UserID)
case "/w"
if len(trim(Request.Form("T1")))=2 then
newsql="select * from UserOnLine"
set newrecordset2=newconn.Execute(newsql)
do while not newrecordset2.eof
info=info&newrecordset2("UserId")&"--"&newrecordset2("RoomName")&"--"&newrecordset2("IpAdd")&"--"&newrecordset2("TimeLogin")&"<br>"
newrecordset2.movenext
loop
Application(UserID)=info&"<br>"&Application(UserID)
else
if right(left(Request.Form("T1"),3),1)<>":"then
info="?üá?DDê?è?′í?ó<br><br>"
Application(UserID)=info & Application(UserID)
else
temproom=mid(trim(Request.Form("T1")),4)
newsql="select RoomName from RoomInfo where RoomName='"&temproom&"'"
set newrecord3=newconn.Execute(newsql)
if not newrecord3.bof then
newsql="select * from UserOnLine where RoomName='"&temproom&"'"
set newrecordset2=newconn.Execute(newsql)
if newrecordset2.bof then
Application(UserID)="<br>??·????Yê±??óDè?!<br><br>"&Application(UserID)
else
do while not newrecordset2.eof
info=info&newrecordset2("UserID")&"--"& newrecordset2("RoomName")&"--"&newrecordset2("IpAdd")&"--"&newrecordset2("TimeLogin")&"<br>"
newrecordset2.movenext
loop
Application(UserID)="<br>"&info&"<br>"&Application(UserID)
end if
else
info="<br>??óD<font color=vbred><strong>"&temproom&"</strong></font>?a??·???£?<br><br>"
Application(UserID)=info&Application(UserID)
end if
end if
end if
case "/1"
newsql="select WhoCreate from RoomInfo where WhoCreate='"&UserID&"'and RoomName='"&session("myroom")&"'"
set newrecordset=newconn.Execute(newsql)
if newrecordset.bof then
Application(UserID)="2?o?òa??£????Tè¨??×??a??·???£?<br><br>"&Application(UserID)
else
newsql="update RoomInfo set IfLocked=true where RoomName='"&session("myroom")&"'"
newconn.Execute(newsql)
Application(UserID)="??ò??-??×?á??a??·???!<br><br>"&Application(UserID)
end if
case "/u"
newsql="select WhoCreate from RoomInfo where WhoCreate='"&UserID&"'and RoomName='"&session("myroom")&"'"
set newrecordset=newconn.Execute(newsql)
if newrecordset.bof then
Application(UserID)="2?o?òa??£????Tè¨?a?a?a??·????ò??2??ú????·???£?<br><br>"&Application(UserID)
else
newsql="update RoomInfo set IfLocked=false where RoomName='"&session("myroom")&"'"
newconn.Execute(newsql)
Application(UserID)="??ò??-?a?a?a??·???£?<br><br>"&Application(UserID)
end if
case "/c"
Application(session("myname"))=""
case "/b"
%>
<script language="javascript">
<!--
//è?ò3????è?byebye.asp
top.location.href="byebye.asp"
//-->
</script>
<%
session.Abandon
Response.End
case"/h"
info="/h---3???°??úìáê?<br>"
info=info&"/j:roomname---?óè?D?μ?·???<br>"
info=info&"/r--2é?′μ±?°·???D??¢<br>"
info=info&"/w:roomname---2é?′μ±?°ó??§?é??<br>"
info=info&"/l--??×?μ±?°·???£???óD′′?¨??2??ü??×?<br>"
info=info&"/b--í?3?á?ììêò<br>"
info=info&"/u--?a?a?3??·???<br>"
info=info&"/t:newtopic--DT???°ìa£???óD′′?¨??2??üDT??<br>"
info=info&"/c--??3yá?ìì?úèY<br>"
Application(UserID)="<br>"&info&"<br>"&Application(UserID)
case"/t"
if right(left(command,3),1)<>":"then
Application(UserID)="<br>?üá?ê?è?′í?ó£?<br><br>"&Application(UserID)
else
newsql="select WhoCreate from RoomInfo where WhoCreate='"&UserID&"'and RoomName='"&session("myroom")&"'"
set newrecordset=newconn.Execute(newsql)
if newrecordset.bof then
Application(UserID)="2?o?òa??£????Tè¨DT???a??·???μ??°ìa£?<br><br>"&Application(UserID)
else
newsql="update RoomInfo set Topic='"&mid(command,4)&"' where RoomName='"&session("myroom")&"'"
newconn.Execute(newsql)
newsql="select UserID from UserOnLine where RoomName='"&session("myroom")&"'"
set t_newrecordset=newconn.Execute(newsql)
do while not t_newrecordset.eof
Application(t_newrecordset(0))="·????°ìa±?DT???a<font color=vbpurplea>"&mid(command,4)&"</font>!<br><br>"&Application(t_newrecordset(0))
t_newrecordset.movenext
loop
t_newrecordset.close
set t_newrecordset=nothing
end if
end if
case else
Application(UserID)="<br>??óD?a???üá?,??ó?/h2é?′°??ú<br>"&Application(UserID)
end select
else
if request.Form("D1")<>"all" then
id_name=Request.Form("D1")
temppos=instr(1,id_name,",",1)
yourid=mid(id_name,1,temppos-1)
yournickname=mid(id_name,temppos+1)
end if
set myrecord=server.CreateObject("ADODB.Recordset")
mysql="select * from UserOnLine where RoomName='"&myroom&"'"
myrecord.Open mysql,"DSN=ChatRoom",1,3
if request.Form("D1")="all" or request.Form("C1")<>"ON" then
if request.Form("D1")="all" then
tempstr="<font color='"&request.Form("D2") & "'>"&mynickname&Request.Form("facing")&"?μ£o"&request.Form("T1")&"</font><font color=blue size=0.5>("&time()&")</font><br>"
else
tempstr="<font color='"&request.Form("D2")&"'>"&mynickname&"????"&yournickname&Request.Form("facing")&"?μ£o"& request.Form("T1")&"</font><font color=blue size=0.5>("&time()&")</font><br>"
end if
do while not myrecord.EOF
Application(myrecord("UserID"))=tempstr&Application(myrecord("UserID"))
myrecord.MoveNext
loop
Application(myroom)=tempstr&Application(myroom)
if len(Application(myroom))>1000 then
length2=len(Application(myroom))
temppos=instrrev(Application(myroom),"<br>",length2)-1
Application(myroom)=mid(Application(myroom),1,temppos)
end if
else
tempstr="<marquee border='0' behavior='alternate'><font color='"&request.Form("D2")&"'>"&mynickname&"??" &yournickname&Request.Form("facing")&"?μ:"&request.Form("T1")&"</font></marquee>"&"<font color=blue size=0.5>("&time()&")</font><br>"
Application(yourid)=tempstr&Application(yourid)
Application(myname)=tempstr&Application(myname)
end if
if len(Application(myname))>20000 then
length1=len(Application(myname))
temppos=instrrev(Application(myname),"<br>",length1-4)-1
Application(myname)=mid(Application(myname),1,temppos)
end if
Application.UnLock
end if
Response.Write Application(UserID)
else
Response.Write Application(UserID)
end if
newconn.Close
set newconn=nothing
'changed=true
if changed=true then
%>
<script language="javascript">
<!--
parent.frames[1].location.href="send.asp"
//-->
</script>
<%
end if
%>
</body>
</html>
[此贴子已经被作者于2006-2-10 18:16:41编辑过]