views:

34

answers:

0

Hey. I'm converting a 2.6.5 application to python 3.1. I'm trying to convert a byte order received through socket.recv() into a string, by doing the following:

str(temp, 'UTF-8', 'ignore')

The problem is unknown characters are removed ("ignored"), such as \x00 and \xff (WebSockets characters), I do want to convert the byte order to a string before removing \x00 and \xff. I've checked the documentation and there is no correct error handling option (like a 'leave', f.e.) - is there some other way to accomplish this without removing the \x00 and \xff characters at byte level?