1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
#!/usr/bin/env python
# FIXME: This script doesn't work in python3
import sys
import os.path
for file in sys.argv:
if os.path.isfile(file):
#print "File:", file
content = open(file, 'rb').read()
ok = True
try:
unicode(content, 'utf-8')
except UnicodeDecodeError:
print "File '", file, "' is not UTF-8"
ok = False
if not ok:
lineNum = 1
for line in content.split('\n'):
try:
unicode(line, 'utf-8')
except UnicodeDecodeError:
print "\tNon UTF-8 line ", lineNum,":\t", line
ok = False
lineNum = lineNum + 1
|