+ -
当前位置:首页 → 问答吧 → asp生成HTML编码问题求助

asp生成HTML编码问题求助

时间:2011-11-23

来源:互联网

C# code


<%@ codepage=65001%> 
<% Response.Charset="UTF-8" %>
<%
function getHTTPPage(url)
   dim Http
 set http=Server.createobject("MSXML2.ServerXMLHTTP") 
 Http.setTimeouts 10000,10000,10000,30000
 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

Dim Url,Html
Url="http://www.url.com/"
Html = getHTTPPage(Url)

dim filename,fso,fout
filename="index.htm"
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set fout = fso.CreateTextFile(server.mappath(""&filename&""), True, True)
'Set fout = fso.CreateTextFile(server.mappath(""&filename&""))
fout.Write Html
fout.close
set fout=nothing
set fso=nothing
if err then
response.Write("生成页面失败")
else
response.Write("<a href='/index.htm' target='_blank'>生成页面成功</a>")
end if
%>




以上代码生成静态HTML文件之后 该文件用编辑器打开 显示Unicode编码 请问有什么方法解决?详解 谢谢

作者: cckakaok   发布时间: 2011-11-23

自己顶下

作者: cckakaok   发布时间: 2011-11-24