def try_coerce_ascii(string_utf8):
 try:
  string_utf8.decode('ascii')
 except UnicodeDecodeError:
  return
 return string_utf8

def try_coerce_ascii ( string_utf8 ) : try : string_utf8 . decode ( 'ascii' ) except UnicodeDecodeError : return return string_utf8
attempts to decode the given utf8-encoded string as ascii after coercing it to utf-8 .