当前位置:编程学习 > 网站相关 >>

DOS下文本编码批量转换代码

黑客笔记

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
CMD:
@echo off
for /f "delims=" %%a in (dir /s /b /a-d D: est*.txt) do hacknote.vbs "%%a"
pause

 

补充:综合编程 , 安全编程 ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,