Detects the byte order mark of a file and returns an appropriate encoding for the file.