Skip to content

Instantly share code, notes, and snippets.

@LouiS0616
Created February 8, 2020 05:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LouiS0616/53238a867218919bdec843ce6aea8662 to your computer and use it in GitHub Desktop.
Save LouiS0616/53238a867218919bdec843ce6aea8662 to your computer and use it in GitHub Desktop.
simple decoding tool
@echo off
python %~dp0\enc.py %*
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