1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
::UTF-8 to ANSI ::UTF-8 → Unicode CHCP 65001 ::如果输入的 UTF-8 没有 BOM,%~dpn1_unicode-without-BOM.txt 打开乱码 CMD /D /U /C TYPE %~1 > %~dpn1_unicode-without-BOM.txt ::取得 Unicode BOM ECHO.//4=>U.bom certutil -decode -f U.bom U.bom >NUL ::Unicode → Unicode BOM CHCP 936 MOVE /y U.bom %~dpn1_Unicode-BOM.txt >NUL TYPE %~dpn1_unicode-without-BOM.txt >> %~dpn1_Unicode-BOM.txt ::Unicode BOM → ANSI TYPE %~dpn1_Unicode-BOM.txt > %~dpn1_ANSI.txt DEL /Q /F %~dpn1_unicode-without-BOM.txt %~dpn1_Unicode-BOM.txt |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
:: ANSI To UTF-8 @ECHO OFF SETLOCAL EnableDelayedExpansion :: Get BOM(Byte order mark): ZERO WIDTH NO-BREAK SPACE :: "绿图" in unicode: \u7eff\u56fe SET GBK=绿图 CHCP 1252 >NUL FOR /F %%a IN ('CMD/D/U/C ECHO !GBK!') DO SET b=%%a :: Use UTF-16 Little-Endian SET HEAD=!b:~0,1!!b:~2,1! SET /P=!HEAD!<nul>U.BOM ::ANSI → Unicode BOM CHCP 936 MOVE /y U.BOM %~dpn1_Unicode-BOM.txt CMD /D /U /C TYPE %~1 >> %~dpn1_Unicode-BOM.txt ::Unicode BOM → UTF-8 CHCP 65001 TYPE %~dpn1_Unicode-BOM.txt > %~dpn1_UTF-8.txt DEL %~dpn1_Unicode-BOM.txt CHCP 936 |
原文链接https://www.52pojie.cn/thread-902239-1-1.html
发表回复