asp用fso生成utf-8编码页面乱码?应该怎么解决?帮忙看一下.谢谢
<%'FunctionAbc(temp)'Fori=1Tolen(temp)'Ifmid(temp,i,1)<>"?"Then'pk=asc(mid(temp,i,1))...
<%
'Function Abc(temp)
'For i =1 To len(temp)
'If mid(temp,i,1)<>"?" Then
'pk=asc(mid(temp,i,1))-99
'If pk>126 Then
'pk=pk-95
'ElseIf pk<32 Then
'pk=pk+95
'End If
'a=a&chr(pk)
'Else
'a=a&vbcrlf
'End If
'Next
'Abc=a
'End Function
function getHTTPPage(url)
dim Http
set Http=server.createobject("MSXML2.XMLHTTP")
Http.open "GET",url,false
Http.send()
if Http.readystate<>4 then
exit function
end if
getHTTPPage=bytesToBSTR(Http.responseBody,"UTF-8")
set http=nothing
if err.number<>0 then err.Clear
end function
Function BytesToBstr(body,Cset)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode = 3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
%>
以上这是function.asp
这里以下是生成页面..
<!--#include file="function.asp"-->
<%
set rs=server.createobject("adodb.recordset")
dim urlurl
urlurl=Request.ServerVariables("HTTP_HOST")
action=request("action")
select case action
case "index"
call toindex()
end select
sub toindex()
response.Write "a"
set fso=server.createobject("scripting.filesystemobject")
files=server.mappath("/index.txt")
htmlfile="/index.htm"
checkfiles=server.mappath(htmlfile)
if (fso.fileexists(checkfiles)) then
set delfile=fso.getfile(checkfiles)
delfile.delete
end if
url="http://"&urlurl&"/index.asp"
html=gethttppage(url)
set ts = fso.createtextfile(files,true)
ts.write(html)
ts.close
set ts=nothing
set editfile=fso.getfile(files)
editfile.name=left(EditFile.name,len(EditFile.name)-4)&".htm"
%>
<link href="../images/css.css" rel="stylesheet" type="text/css">
<table class="tableBorder" width="90%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td align="center" background="../images/admin_bg_1.gif" height="25"><b><font color="#ffffff">静态页面生成信息</font></b></td>
</tr>
<tr>
<td align="center" valign="top">
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td align="center" bgcolor="fbf4f4">
<% response.write "<a href=/index.htm target=_blank>"&editfile.name&" 生成</a><br>" %>
</td>
</tr>
</table>
</td>
</tr>
</table>
<%
set editfile=nothing
set fso=nothing
response.write("<script>alert(""首页转换成功!"");</script>")
end sub
%>
生成页面结束
<a href="gethttp.asp?action=index" target="mainFrame" >生成首页</a>
这是生成首页连接.
上传的图片是我生成之后乱码现像.大家帮我看一下.是哪里出了问题.我应该怎么解决.谢谢了...
我的所有页面的编码都是utf-8的编码.
谢谢 展开
'Function Abc(temp)
'For i =1 To len(temp)
'If mid(temp,i,1)<>"?" Then
'pk=asc(mid(temp,i,1))-99
'If pk>126 Then
'pk=pk-95
'ElseIf pk<32 Then
'pk=pk+95
'End If
'a=a&chr(pk)
'Else
'a=a&vbcrlf
'End If
'Next
'Abc=a
'End Function
function getHTTPPage(url)
dim Http
set Http=server.createobject("MSXML2.XMLHTTP")
Http.open "GET",url,false
Http.send()
if Http.readystate<>4 then
exit function
end if
getHTTPPage=bytesToBSTR(Http.responseBody,"UTF-8")
set http=nothing
if err.number<>0 then err.Clear
end function
Function BytesToBstr(body,Cset)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode = 3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
%>
以上这是function.asp
这里以下是生成页面..
<!--#include file="function.asp"-->
<%
set rs=server.createobject("adodb.recordset")
dim urlurl
urlurl=Request.ServerVariables("HTTP_HOST")
action=request("action")
select case action
case "index"
call toindex()
end select
sub toindex()
response.Write "a"
set fso=server.createobject("scripting.filesystemobject")
files=server.mappath("/index.txt")
htmlfile="/index.htm"
checkfiles=server.mappath(htmlfile)
if (fso.fileexists(checkfiles)) then
set delfile=fso.getfile(checkfiles)
delfile.delete
end if
url="http://"&urlurl&"/index.asp"
html=gethttppage(url)
set ts = fso.createtextfile(files,true)
ts.write(html)
ts.close
set ts=nothing
set editfile=fso.getfile(files)
editfile.name=left(EditFile.name,len(EditFile.name)-4)&".htm"
%>
<link href="../images/css.css" rel="stylesheet" type="text/css">
<table class="tableBorder" width="90%" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td align="center" background="../images/admin_bg_1.gif" height="25"><b><font color="#ffffff">静态页面生成信息</font></b></td>
</tr>
<tr>
<td align="center" valign="top">
<table width="100%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<td align="center" bgcolor="fbf4f4">
<% response.write "<a href=/index.htm target=_blank>"&editfile.name&" 生成</a><br>" %>
</td>
</tr>
</table>
</td>
</tr>
</table>
<%
set editfile=nothing
set fso=nothing
response.write("<script>alert(""首页转换成功!"");</script>")
end sub
%>
生成页面结束
<a href="gethttp.asp?action=index" target="mainFrame" >生成首页</a>
这是生成首页连接.
上传的图片是我生成之后乱码现像.大家帮我看一下.是哪里出了问题.我应该怎么解决.谢谢了...
我的所有页面的编码都是utf-8的编码.
谢谢 展开
4个回答
展开全部
恕我愚笨,我以前也这样,后来把网页全改成Gb2312了。。。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
getHTTPPage=bytesToBSTR(Http.responseBody,"UTF-8")
换成
getHTTPPage=bytesToBSTR(Http.responseBody,"gb2312") 试试
换成
getHTTPPage=bytesToBSTR(Http.responseBody,"gb2312") 试试
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
getHTTPPage=bytesToBSTR(Http.responseBody,"gb2312")
参考资料: http://bbs.openty.com
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询