请问ASP自动生成HTML静态页面问题(如果设置保存为UTF-8)

来源:百度知道 编辑:UC知道 时间:2024/09/20 02:47:16
Function getHTTPPage(Path)
t = GetBody(Path)
getHTTPPage=BytesToBstr(t,"utf-8")
End function

Function GetBody(strUrl)
dim objXmlHttp
set objXmlHttp = Server.CreateObject("Microsoft.XMLHTTP")
objXmlHttp.open "GET",strUrl,false
objXmlHttp.send()
GetBody= objXmlHttp.responseBody
set objXmlHttp=nothing
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
'response.write BytesToBstr
objstream.Close
set objstream = nothing
End Function
Function Newstring(wstr,strng)
Newstring=Instr(lcase(wstr),lcase(strng))
if Newstring<=0 then Newstring=L

要处理编码的话,写入文件应该使用adodb.stream对象,用它的saveto保存文件。在保存之前先设置objstream.Charset = "UTF-8"

不要使用FSO对象。

Body = GetBody(URL)
Body = BytesToBstr(ListBody,"utf-8")
Set TxtFile = Fso.CreateTextFile(filename,true,true)
TxtFile.Write(Body)

结合上面的代码,用这4句就可以了!

<%@ page charset=UTF-8"%>

把你的ASP文件另存为UTF8的,数据库也是这个编码

模板中的<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />也得有

用记事本(或者其他编译器)把这段代码另存为编码为utf-8的文件就可以