Character encoding detection and conversion (Python, Bash)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

12 lines
262 B

#!/usr/bin/python
import sys
import glob
from chardet.universaldetector import UniversalDetector
detector = UniversalDetector()
detector.reset()
contents=file(sys.argv[1], 'rb').read()
detector.feed(contents)
detector.close()
print detector.result['encoding']