Does anybody know if there is a simple way to detect character set encoding in Java? It seems to me that some programs have the ability to detect which character set a given piece of data uses, or at least make an aproximation.
I suppose the underlying mechanism would have to decode the data in each character set and pick whichever one has the least undefined characters followed by which character set is more common to break a tie.
Any ideas?
Take a look at jchardet, a library ported from the Mozilla browser that specializes in "guessing" the charset of a document.
As an alternative, the cpdetector library, a bit newer, specializes in detecting the code page of a document.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With