def unicode_is_ascii(u_string):
 assert isinstance(u_string, str)
 try:
  u_string.encode('ascii')
  return True
 except UnicodeEncodeError:
  return False

def unicode_is_ascii ( u_string ) : assert isinstance ( u_string , str ) try : u_string . encode ( 'ascii' ) return True except UnicodeEncodeError : return False
determine if unicode string only contains ascii characters .