*** 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
本文介绍了一个简单的批处理脚本和VBScript脚本组合,用于将ANSI编码的文件转换为UTF-8编码。该解决方案包括两个部分:一个批处理文件用于启动转换过程,一个VBScript文件用于执行实际的编码转换。
1582

被折叠的 条评论
为什么被折叠?



