I'm using python3.3. I've been trying to decode a certain string that looks like this:
b'\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\x03\xed:\xf9w\xdaH\xd2?\xcf\xbc.... keeps going on. However whenever I try to decode this string using str.decode('utf-16') I get an error saying:
'utf16' codec can't decode bytes in position 54-55: illegal UTF-16 surrogate I'm not exactly sure how to decode this string.
utf16is correct.twisted/web/proxy.pyin thehandleResponsePart(self, buffer)function, I just injectedprint(buffer). So basically the encoded string you're looking at is supposed to be HTML, that I receive from Twisted proxies'UTF-16BE'and'UTF-16LE'— endianess might be the issue.