dev/python/chardet/convert_tree_of_files.py

15 lines
351 B
Python
Raw Normal View History

2012-03-02 12:16:22 +04:00
import sys
import glob
from chardet.universaldetector import UniversalDetector
detector = UniversalDetector()
for filename in sys.argv[1:]:
#print filename.ljust(60),
detector.reset()
for line in file(filename, 'rb'):
detector.feed(line)
if detector.done: break
detector.close()
print detector.result['encoding']