Il y a une lib pour la détection de codage: https://pypi.python.org/pypi/chardet (Codage de caractère automatique dans Python. Aussi intelligent que votre navigateur. Open source)
Détecte ...
- ASCII, UTF-8, UTF-16 (2 variantes), UTF-32 (4 variantes)
- BIG5, GB2312, EUC-TW, HZ-GB-2312, ISO-2022-CN (chinois traditionnel et simplifié)
- EUC-JP, Shift_Jis, ISO-2022-JP (Japonais)
- EUC-KR, ISO-2022-KR (coréen)
- KOI8-R, MACCYRILLIC, IBM855, IBM866, ISO-8859-5, Windows-1251 (Cyrillic)
- ISO-8859-2, Windows-1250 (hongrois)
- ISO-8859-5, Windows-1251 (bulgare)
- Windows-1252 (anglais)
- ISO-8859-7, Windows-1253 (grec)
- ISO-8859-8, Windows-1255 (Hébreu visuel et logique)
- TIS-620 (thaï)
Exemple de Docs:
>>> import urllib
>>> rawdata = urllib.urlopen('http://yahoo.co.jp/').read()
>>> import chardet
>>> chardet.detect(rawdata)
{'encoding': 'EUC-JP', 'confidence': 0.99}