ADODB.Stream指定CharSet读写文本文件的函数

Function  ReadTextFile (FilePath,CharSet)
dim  str,stm
set  stm = server.CreateObject( " adodb.stream " )
stm.Type
= 2   ' 以文本模式读取
stm.mode = 3  
stm.charset
= CharSet
stm.open
stm.loadfromfile FilePath
str
= stm.readtext
stm.Close
set  stm = nothing
ReadTextFile
= str
End function

Sub  WriteTextFile (FilePath,Str,CharSet)
dim  stm 
set  stm = server.CreateObject( " adodb.stream " )
stm.Type
= 2   ' 以文本模式读取
stm.mode = 3
stm.charset
= CharSet
stm.open
stm.WriteText str
stm.SaveToFile FilePath,
2  
stm.flush
stm.Close
set  stm = nothing
End Sub

你可能感兴趣的:(charset)