Is it possible to check in Python whether a given charset exists/is installed.
For example:
check('iso-8859-1') -> True
check('bla') -> False
From stackoverflow
-
You can use the
lookup()
function in thecodecs
module. It throws an exception if a codec does not exist:import codecs def exists_encoding(enc): try: codecs.lookup(enc) except LookupError: return False return True exists_encoding('latin1')
0 comments:
Post a Comment