日期:2014-05-16  浏览次数:20452 次

asp---CreateObject("adodb.stream")文件写入utf-8格式

用CreateObject("Scripting.FileSystemObject")写入utf-8的文件会出现乱码问题

可以使用CreateObject("adodb.stream")写入,设置编码为utf-8即可

function writeToFile(charset,content,filepath)

			set stm=server.CreateObject("adodb.stream")
			stm.Type=2'以本模式读取
			stm.mode=3
			stm.charset=charset
			stm.open
			stm.WriteText content
			stm.SaveToFile server.MapPath(filepath),2 
			stm.flush
			stm.Close
			set stm=nothing
		end function

charset:编码

content:写入内容

filepath:文件路径