import chardet chardet.detect(b"Hello, world!") # {'encoding': 'ascii', 'confidence': 1.0, 'language': 'en'} # UTF-8 with typographic punctuation chardet.detect("It\u2019s a lovely day \u2014 let\u2019s grab coffee.".encode("utf-8")) # {'encoding': 'utf-8', 'confidence': 0.99, 'language': 'es'} # Japanese EUC-JP chardet.detect("これは日本語のテストです。文字コードの検出を行います。".encode("euc-jp")) # {'encoding': 'EUC-JP'

