TXT编码批量转换代码
VBS: 红色处替换成编码格式 gb2312 UTF-8 Unicode
Set objArgs = WScript.Arguments
For I = 0 To objArgs.Count - 1
FileUrl = objArgs(I)
Call WriteToFile(FileUrl, ReadFile(FileUrl, "UTF-8"), "Unicode")
Next
Function ReadFile(FileUrl, CharSet)
Dim Str
Set stm = CreateObject("Adodb.Stream")
stm.Type = 2
stm.mode = 3
stm.charset = CharSet
stm.Open
stm.loadfromfile FileUrl
Str = stm.readtext
stm.Close
Set stm = Nothing
ReadFile = Str
End Function
Function WriteToFile (FileUrl, Str, CharSet)
Set stm = CreateObject("Adodb.Stream")
stm.Type = 2
stm.mode = 3
stm.charset = CharSet
stm.Open
stm.WriteText Str
stm.SaveToFile FileUrl, 2
stm.flush
stm.Close
Set stm = Nothing
End Function