def normalize_encoding(encoding, default=DEFAULT_ENCODING):
if encoding is None:<EOL><INDENT>return default<EOL><DEDENT>encoding = encoding.lower().strip()<EOL>if encoding in ['<STR_LIT>', '<STR_LIT:ascii>']:<EOL><INDENT>return default<EOL><DEDENT>try:<EOL><INDENT>codecs.lookup(encoding)<EOL>return encoding<EOL><DEDENT>except LookupError:<EOL><INDENT>return default<EOL><DEDENT>
Normalize the encoding name, replace ASCII w/ UTF-8.