(self, file_name)
Reads the first few bytes from file_name and tries to guess the text
    encoding. Returns None as a guess if it can't detect it.
Reads the first few bytes from file_name and tries to guess the text
    encoding. Returns None as a guess if it can't detect it.
Reads the first few bytes from file_name and tries to guess the text encoding . Returns None as a guess if it can t detect it .
def _DetectInputEncoding(self, file_name):
    """Reads the first few bytes from file_name and tries to guess the text
    encoding. Returns None as a guess if it can't detect it."""
    fp = open(file_name, 'rb')
    try:
      header = fp.read(3)
    except:
      fp.close()
      return None
    fp.close()
    if header.startswith("\xFE\xFF"):
      return "UTF-16"
    elif header.startswith("\xFF\xFE"):
      return "UTF-16"
    elif header.startswith("\xEF\xBB\xBF"):
      return "UTF-8"
    else:
      return None
def _DetectInputEncoding ( self , file_name ) : fp = open ( file_name , 'rb' ) try : header = fp . read ( 3 ) except : fp . close ( ) return None fp . close ( ) if header . startswith ( "\xFE\xFF" ) : return "UTF-16" elif header . startswith ( "\xFF\xFE" ) : return "UTF-16" elif header . startswith ( "\xEF\xBB\xBF" ) : return "UTF-8" else : return None