是否有可以檢測(也許是解碼)字符串編碼的Python庫?使用QString編碼
我發現chardet
但它給了我一個錯誤,使用:
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
另外:
print type(self.ui.TextFrom.toPlainText())
# <class 'PyQt4.QtCore.QString'>
你需要解釋爲什麼chardet的是不是你想要的 - 這是你問什麼了。 – RichieHindle 2009-05-04 08:54:11
對不起,也許它不正確,chardet不是我所需要的。我這個LIB過程中有錯誤,可以使用: chardet.detect(self.ui.TextFrom.toPlainText()) 了: = chardet.detect(self.ui.TextFrom.toPlainText()) 文件.... u.feed(aBuf) 文件.... if self._highBitDetector.search(aBuf): TypeError:緩衝區大小不匹配 – Ockonal 2009-05-04 08:56:47
您在發佈的所有代碼中遇到錯誤,包括self.ui.TextFrom .toPlainText() - 你確定沒有給你一個Unicode字符串嗎?或者根本不是字符串的東西?什麼是打印類型(self.ui.TextFrom.toPlainText())給? – RichieHindle 2009-05-04 09:59:25