'Removes file encoding from file_contents because the file was already
read into Unicode, and the AST parser complains.
Arguments:
file_contents: The Python file contents.
Returns:
The Python file contents with the encoding stripped.'

def _strip_file_encoding(self, file_contents):

    encoding_regex = re.compile('^[    \\t\\v]*#.*?coding[:=][    \\t]*([-_.a-zA-Z0-9]+)')
    encoding_match = encoding_regex.search(file_contents)
    if (encoding_match is None):
        lines = StringLines(file_contents)
        if (lines.line_count() >= 2):
            encoding_match = encoding_regex.search(lines.line_number_to_line(2))
    if (encoding_match is not None):
        file_contents = file_contents.replace(encoding_match.group(), '#', 1)
    return file_contents
