Created
February 8, 2020 05:46
-
-
Save LouiS0616/53238a867218919bdec843ce6aea8662 to your computer and use it in GitHub Desktop.
simple decoding tool
This file contains 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
@echo off | |
python %~dp0\enc.py %* |
This file contains 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
import sys | |
if len(sys.argv) != 2: | |
print('USAGE: python .py file', file=sys.stderr) | |
sys.exit(1) | |
# | |
filename = sys.argv[1] | |
with open(filename, mode='rb') as fin: | |
raw_data = fin.read() | |
code = 'utf-8' | |
if raw_data[:3] == b'\xef\xbb\xbf': # BOM | |
code = 'utf-8-sig' | |
print(raw_data.decode(code)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment