bat 批处理 ,那位大神提供一下的代码,我有好多UTF8编码的txt文档,我想通过代码的形式转换成ANSI编码的
1个回答
展开全部
@echo off
(echo aCode = "UTF-8"
echo bCode = "GB2312"
echo Set objArgs = WScript.Arguments
echo.
echo FileUrlSrc = objArgs^(0^)
echo FileUrlDst = objArgs^(1^)
echo Call WriteToFile^(FileUrlDst, ReadFile^(FileUrlSrc, aCode^), bCode^)
echo.
echo Function ReadFile^(FileUrlSrc, CharSet^)
echo Dim Str
echo Set stm = CreateObject^("Adodb.Stream"^)
echo stm.Type = 2
echo stm.mode = 3
echo stm.charset = CharSet
echo stm.Open
echo stm.loadfromfile FileUrlSrc
echo Str = stm.readtext
echo stm.Close
echo Set stm = Nothing
echo ReadFile = Str
echo End Function
echo.
echo Function WriteToFile ^(FileUrlDst, Str, CharSet^)
echo Set stm = CreateObject^("Adodb.Stream"^)
echo stm.Type = 2
echo stm.mode = 3
echo stm.charset = CharSet
echo stm.Open
echo stm.WriteText Str
echo stm.SaveToFile FileUrlDst, 2
echo stm.flush
echo stm.Close
echo Set stm = Nothing
echo End Function)>U82ANI.vbs
for /r %%a in (*.txt) do (
U82ANI.vbs "%%~a" "%%~a.ansi"
move /y "%%~a.ansi" "%%~a">nul
)
del U82ANI.vbs
pause
放到UTF8编码的txt文件一起后运行
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询