Skip to content

Instantly share code, notes, and snippets.

@Rahmanism
Created April 16, 2023 09:24
Show Gist options
  • Save Rahmanism/b8791833170237019158434dbc0168a5 to your computer and use it in GitHub Desktop.
Save Rahmanism/b8791833170237019158434dbc0168a5 to your computer and use it in GitHub Desktop.
Find the encoding of a file
import sys, chardet
with open(sys.argv[1], 'rb') as f:
result = chardet.detect(f.read())
print(result['encoding'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment