def guess_file_encoding(fh, default=DEFAULT_ENCODING):
start = fh.tell()<EOL>detector = chardet.UniversalDetector()<EOL>while True:<EOL><INDENT>data = fh.read(<NUM_LIT> * <NUM_LIT:10>)<EOL>if not data:<EOL><INDENT>detector.close()<EOL>break<EOL><DEDENT>detector.feed(data)<EOL>if detector.done:<EOL><INDENT>break<EOL><DEDENT><DEDENT>fh.seek(start)<EOL>return normalize_result(detector.result, default=default)<EOL>
Guess encoding from a file handle.