Is there a Python library which can detect (and perhaps decode) encoding of the string?
I found chardet
but it gives me an error, using:
chardet.detect(self.ui.TextFrom.toPlainText())
got: = chardet.detect(self.ui.TextFrom.toPlainText())
File .... u.feed(aBuf) File ....
if self._highBitDetector.search(aBuf):
TypeError: buffer size mismatch
Also:
print type(self.ui.TextFrom.toPlainText())
# <class 'PyQt4.QtCore.QString'>
You need to convert your
QString
to a Python string before passing it tochardet
. Change this:to this:
I guess this is another option.
http://cthedot.de/encutils/