*** ANSI2UTF8. BAT ***
echo off
rem *** ANSI to UTF-8 ***
ANSI2UTF8.vbs "TMBAR01_bak.txt"
exit
*** ANSI2UTF8. VBS ***
- Set objArgs = WScript.Arguments
- For I = 0 To objArgs.Count - 1
- FileUrl = objArgs(I)
- Call WriteToFile(FileUrl, ReadFile(FileUrl, "GB2312"), "UTF-8")
- 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