|
例子是gb2312读取,utf-8写入,自己看着改吧
File = "D:\123.txt"
Code1 = "gb2312"
Code2 = "utf-8"
WriteToFile File, ReadFile(File, Code1), Code2
Function ReadFile(Filepath, CharSet)
Dim Str
Set stm = 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
ReadFile = Str
End Function
Function WriteToFile (Filepath, Str, CharSet)
Set stm = 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 Function |
|