Home Python charset detection
Post
Cancel

Python charset detection

We can use the chardet module to detect the charset (or character encoding) of a file.
This can come handy when we need to analyze a text file.
To install chardet:

1
$ sudo pip3 install chardet

Now we have a command line tool called chardetect to find files charset:

1
2
chardetect file.txt
file.txt: ascii with confidence 1.0

Enjoy! ;)

This post is licensed under CC BY 4.0 by the author.