views:

197

answers:

2

Hello, can you show me library for python which can detect (or decode - not nessecary) encoding of the string. I found chardet but it's not that what i need. Thanks.

+2  A: 

I guess this is another option.

http://cthedot.de/encutils/

A collection of helper functions to detect encodings of text files (like HTML, XHTML, XML, CSS, etc.) retrieved via HTTP, file or string.

muitocomplicado
Thanks. I'll try this.
Ockonal
How can i get encoding info of the string?encutils.getEncodingInfo(text=self.ui.TextFrom.toPlainText())Calls an error: AttributeError: find in _getTextType.
Ockonal
+7  A: 

You need to convert your QString to a Python string before passing it to chardet. Change this:

chardet.detect(self.ui.TextFrom.toPlainText())

to this:

chardet.detect(str(self.ui.TextFrom.toPlainText()))
RichieHindle
thanks, it works fine.
Ockonal