Last active
January 10, 2025 04:58
-
-
Save muink/0ac786cb39a7fbd64a1e046fd0681237 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
::獲取當前代碼頁 | |
for /f "tokens=2 delims=:" %%l in ('chcp') do set "code_page=%%l" | |
set "code_page=%code_page: =%" | |
::先輸出一個Unicode檔案 | |
reg export HKCR\.txt U.bom | |
::取得 Unicode BOM | |
chcp 1252 | |
set /p BOM=<U.bom | |
set /p=%BOM:~0,2%<nul >U.bom | |
::或 | |
echo.//4=>U.bom.txt | |
certutil -decode -f U.bom.txt U.bom>nul | |
del /f/q U.bom.txt 2>nul | |
::ansi → Unicode | |
chcp %code_page% | |
copy U.bom Unicode.txt | |
cmd /u /c "type ansi.txt >>Unicode.txt" | |
::======================================= | |
chcp 65001 | |
::Unicode → 無BOM的UTF-8 | |
type Unicode.txt > UTF-8-0.txt | |
::Unicode → 有BOM的UTF-8 | |
copy /b U.bom + Unicode.txt Unicode-2B.txt | |
type Unicode-2B.txt > UTF-8-B.txt | |
::======================================= | |
::無BOM的UTF-8 → Unicode | |
copy U.bom Unicode-save-0.txt | |
cmd /u /c "type UTF-8-0.txt >> Unicode-save-0.txt" | |
::有BOM的UTF-8 → Unicode | |
cmd /u /c "type UTF-8-B.txt > Unicode-save-1.txt" | |
::======================================== | |
::Unicode → ansi | |
chcp %code_page% | |
type Unicode-save-0.txt > ansi-save-0.txt | |
type Unicode-save-1.txt > ansi-save-1.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
utf8bom:
echo '77u/' | base64 -d > utf8.bom