asp生成静态页面编码utf-8问题
大家好,asp生成静态页面,生成的是unicode编码,但我需要生成的是utf-8,代码如下
Function createhtml(url,filename,path)
Set MyFileObject=Server.CreateObject("Scripting.FileSystemObject")
path1=server.mappath(path)&"\"&filename
Set MyTextFile=MyFileObject.CreateTextFile(path1,True,true)
strurl=url
strTmp = GetHTTPPage(trim(strurl))
MyTextFile.WriteLine(strTmp)
MytextFile.Close
Set MyFileObject=nothing
response.Write "<script language=javascript>alert('生成"&filename&"成功!');window.opener.location.reload();window.close();</script>"
End function
Function getHTTPPage(url)
On Error Resume Next
dim http
set http=Server.createobject("Microsoft.XMLHTTP")
Http.open "GET",url,false
Http.send()
if Http.readystate<>4 then
exit function
end if
getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")
set http=nothing
If Err.number<>0 then
Response.Write "<p align='center'><font color='red'><b>服务器获取文件内容出错</b></font></p>"
Err.Clear
End If
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 ="UTF-8"
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
Function timetohtml(str)
timetohtml=Replace(Replace(Replace(str,":",""),"-","")," ","")&".html"
End Function
Function finddir(filepath)
finddir=""
for i=1 to len(filepath)
if left(right(filepath,i),1)="/" or left(right(filepath,i),1)="\" then
abc=i
exit for
end if
next
if abc <> 1 then
finddir=left(filepath,len(filepath)-abc+1)
end if
end Function
url="http://" & Request.ServerVariables("http_host") & finddir(Request.ServerVariables("url"))
url0=""&url&"" '这个为页面地址
path="../html"
filename="index.html"
url=url0&"list.asp"
Call createhtml(url,filename,path)
注:好像是fso不能生成utf-8编码,只能生成unicode,需要改成adodb.stream,但不知道怎么改,呵呵,大家会的帮我下哈