将FileSystemObject保存为UTF

时间:2010-05-25 18:38:37

标签: asp-classic utf-8 fso

如何在utf-8中保存文件?

Dim FSO, File   
Set FSO = Server.CreateObject("Scripting.FileSystemObject")   
Set File = FSO.OpenTextFile(Path,2,true,-1)   
File.Write(xml1)   
File.Close   
Set File = Nothing  
Set FSO = Nothing  

1 个答案:

答案 0 :(得分:5)

我会尝试ADODB Stream对象。

Dim objStream 
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Type = adTypeText
objStream.Mode = adModeReadWrite
objStream.Open
objStream.Position = 0
objStream.Charset = "UTF-8"
objStream.WriteText strContent
objStream.SaveToFile strABSPath,adSaveCreateOverWrite
objStream.Close
Set objStream=nothing