Franklin M. Siler

Lawyer and Technologist

  • Home
  • Contact
  • Setup
  • Blog

Detecting character encodings

Posted in Uncategorized
November 11, 2021

This is a quick and dirty script inspired by this post, but it can definitely be a useful tool:

#!/usr/bin/env python
from chardet import detect
from sys import argv

for fn in argv[1:]:
  with open(fn, "rb") as f:
    print(fn, detect(f.read())['encoding'])
← No fault go-arounds
Handy commit hook →
© Franklin M. Siler