def encoding_exists(encoding, _aliases=_ENCODING_ALIASES):
 try:
  codecs.lookup(resolve_encoding(encoding, _aliases))
 except LookupError:
  return False
 return True

def encoding_exists ( encoding , _aliases = _ENCODING_ALIASES ) : try : codecs . lookup ( resolve_encoding ( encoding , _aliases ) ) except LookupError : return False return True
returns true if encoding is valid .