asp用fso生成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的编码.
谢谢

网页第一行加这句:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>

----------------------------------------------------------------------

head之间加这句:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
温馨提示:答案为网友推荐,仅供参考
第1个回答  2009-05-18
恕我愚笨,我以前也这样,后来把网页全改成Gb2312了。。。
第2个回答  2009-05-18
getHTTPPage=bytesToBSTR(Http.responseBody,"UTF-8")
换成
getHTTPPage=bytesToBSTR(Http.responseBody,"gb2312") 试试
第3个回答  2009-05-18
getHTTPPage=bytesToBSTR(Http.responseBody,"gb2312")

参考资料:

相关了解……

你可能感兴趣的内容

大家正在搜

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网