Unsolved Reading file with an unknown charset
-
Hi,
I a have to read text files with Qt but I don't know a priori in which charset they are code. How can I found the charset of a text file with Qt?
Thanks,
jclaude
-
@jcga Theoretically it's impossible without a priori knowledge. Practically you can make a good guess if you know at least something, e.g. that the text is some natural language. Then you can test for some characteristics, e.g. how frequently some characters or combinations are used. It's not directly related to Qt, it's a more common problem. See https://stackoverflow.com/questions/436220/determine-the-encoding-of-text-in-python.
-
If you're on linux, you could use file.
-
libiconv
can guess the charset, but it no longer supports Windows. -
Thank you all for your answers.
jcga