| 关键词: nbsp stm FileUrl CharSet UTF-8 ReadFile objArgs Set CreateObject WriteToFile |
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") NextFunction 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 = StrEnd FunctionFunction 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 = NothingEnd FunctionCMD: @echo offfor /f "delims=" %%a in ('dir /s /b /a-d D:\test\*.txt') do hacknote.vbs "%%a"pause |
|
声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系
[邮箱地址] 删除
|