用ASP生成UTF-8网页文件的两种方法
程序员文章站
2023-10-27 14:00:16
方法一:createtextfile生成文件方法 复制代码 代码如下:<%function writetofile(filename,...
方法一:createtextfile生成文件方法
<%function writetofile(filename,filecontent)
set fso=server.createobject("scripting.filesystemobject")
set fp=fso.createtextfile(server.mappath(filename),,true)
fp.write(filecontent)
end function%>
方法二:adodb.stream生成文件方法
<%function writetofile(filename,filecontent)
set ccobjstream = server.createobject("adodb.stream")
with ccobjstream
.type = 2
.mode = 3
.open
.charset = "utf-8"
.position = ccobjstream.size
.writetext filecontent
.savetofile filename,2
.close
end with
end function%>
复制代码 代码如下:
<%function writetofile(filename,filecontent)
set fso=server.createobject("scripting.filesystemobject")
set fp=fso.createtextfile(server.mappath(filename),,true)
fp.write(filecontent)
end function%>
方法二:adodb.stream生成文件方法
复制代码 代码如下:
<%function writetofile(filename,filecontent)
set ccobjstream = server.createobject("adodb.stream")
with ccobjstream
.type = 2
.mode = 3
.open
.charset = "utf-8"
.position = ccobjstream.size
.writetext filecontent
.savetofile filename,2
.close
end with
end function%>