错字的根源是 音频操做过程和前述代码不完全一致引致的
一般来说就三种情形 大列佩季哈区三种情形的递回情形
接纳utf8音频gbk2312
接纳gbk2312音频utf8
阿谁操做体例纷歧定是你他们优先选择的 而要你接纳的操做体例系统或辅助东西手动优先选择的
对ANSI文件格局的gbk2312(即在书签中留存为ANSI且关上无错字 原因在于谷歌接纳了gbk2312音频) 可接纳我写的JAVA来音频文件 全力撑持设置装备摆设文件文件格局递回 设置装备摆设文件文件格局过滤器 开辟名选定等 总之仅全力撑持此种情形 对早已错字的文件文件格局 并不是我显然无法查验是乱过数次的码 而要显然就没辅助东西能查验 恕一筹莫展 必要你他们处置(逆操做体例) 出格留意是间接将gbk转成utf8-nobom 我把bom头也杀掉了
附vbsJAVA:
|================================================================================| | VBScript代码切换辅助东西, 可拖曳、文件文件格局另留存为, 勿逆操做体例, 勿接纳notepad++中的GB2312| | ANSI(GBK)2UTF-8-nobom BY: saltyzero | |================================================================================| GBK = "GB2312" UTF = "UTF-8" Usage1 = "句法1:gbk2utf.vbs [磁盘][产物目次][文件文件格局名]" Dim path, exts, cmd, utf8, rex, filter Set fso = CreateObject("Scripting.FileSystemObject") Set rex = New Regexp utf8 = "[\xC0-\xDF]([^\x80-\xBF]|$)" utf8 = utf8 & "|[\xE0-\xEF].{0,1}([^\x80-\xBF]|$)" utf8 = utf8 & "|[\xF0-\xF7].{0,2}([^\x80-\xBF]|$)" utf8 = utf8 & "|[\xF8-\xFB].{0,3}([^\x80-\xBF]|$)" utf8 = utf8 & "|[\xFC-\xFD].{0,4}([^\x80-\xBF]|$)" utf8 = utf8 & "|[\xFE-\xFE].{0,5}([^\x80-\xBF]|$)" utf8 = utf8 & "|[\x00-\x7F][\x80-\xBF]" utf8 = utf8 & "|[\xC0-\xDF].[\x80-\xBF]" utf8 = utf8 & "|[\xE0-\xEF]..[\x80-\xBF]" utf8 = utf8 & "|[\xF0-\xF7]...[\x80-\xBF]" utf8 = utf8 & "|[\xF8-\xFB]....[\x80-\xBF]" utf8 = utf8 & "|[\xFC-\xFD].....[\x80-\xBF]" utf8 = utf8 & "|[\xFE-\xFE]......[\x80-\xBF]" utf8 = utf8 & "|^[\x80-\xBF]" rex.Pattern = utf8 exts = "txt h hh hpp hxx h++ c cc cpp cxx c++ ii ipp ixx inl tpp txx tpl cppm cxxm c++m" filter = ".vs .git" cmd = "|%{$file = [IO.File]::ReadAllText($_.FullName, [Text.Encoding]::UTF8);$Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False;[System.IO.File]::WriteAllText($_.FullName, $file, $Utf8NoBomEncoding);}" call main() Sub main() select case WScript.Arguments.Count case 0 path = Inputbox("请选定文件文件格局或设置装备摆设文件文件格局", "", "") if path = "" then MsgBox("error") Wscript.Quit end if arg = path case 1 arg = WScript.Arguments(0) end select if fso.FileExists(arg) then y = InputBox("找出文件文件格局: " & arg, "按Enter键证明", "") Dim fA fA = Array(fso.GetFile(arg)) MsgBox(fA(0).name) UpdateFiles(fA) elseif fso.FolderExists(arg) then y = InputBox("找出设置装备摆设文件文件格局: " & arg, "按Enter键证明", "") UpdateFiles(fso.GetFolder(arg).Files) UpdateFolders(fso.GetFolder(arg)) end if MsgBox("切换完成") End Sub Function ReadFile(file) 将Byte()数组转成String字符串 Dim ado, a(), i, n Set ado = CreateObject("ADODB.Stream") ado.Type = 1 : ado.Open ado.LoadFromFile file n = ado.Size - 1 ReDim a(n) For i = 0 To n a(i) = ChrW(AscB(ado.Read(1))) Next if rex.Test(Join(a, "")) = -1 then Dim Str Set stm = CreateObject("Adodb.Stream") stm.Type = 2 stm.mode = 3 stm.charset = GBK stm.Open stm.loadfromfile file Str = stm.readtext stm.Close Set stm = Nothing ReadFile = Str else ReadFile = "" end if MsgBox(ReadFile) End Function Function WriteToFile(file, Str) MsgBox(file) Set stm = CreateObject("Adodb.Stream") stm.Type = 2 stm.mode = 3 stm.charset = UTF stm.Open stm.WriteText Str stm.SaveToFile file,2 stm.flush stm.Close Set stm = Nothing WriteToFile=0 End Function Function UpdateFiles(files) Dim powsh For Each f in files MsgBox(f.Name) folder = f.ParentFolder.Path if InStr(f.Name, "gbk2utf.vbs") = 0 then if InStr(f.Name, ".") = 0 or (f.Attributes and 1) then call WScript.CreateObject("WScript.Shell").Run("cmd.exe /p /c echo " & f.Path & " >>"& Wscript.scriptfullname & "\..\gbk2utf_error.log", 0, true) else nA = Split(f.Name, ".") ext = nA(UBound(nA)) MsgBox(ext(UBound(ext))) if InStr(exts, ext) > 0 then MsgBox("find") read = ReadFile(f.Path) if not read = "" then call WriteToFile(f.Path, read) powsh = powsh & "dir . """ & f.Name & cmd & """ ; " end if end if end if end if Next MsgBox(folder) call WScript.CreateObject("WScript.Shell").Run("cmd.exe /p /c pushd " & folder & "\ && powershell -command " & powsh & " && exit && popd", 0, true) End Function Function UpdateFolders(folder) if InStr(filter, folder.Name) = 0 then For Each subFolder in folder.SubFolders MsgBox(subFolder.Path) if InStr(filter, subFolder.Name) = 0 then MsgBox(subFolder.name) UpdateFolders(fso.GetFolder(subFolder.Path)) UpdateFiles(fso.GetFolder(subFolder.Path).Files) end if Next end if End Function
0