Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (47.6k points)

I have a socket server that is supposed to receive UTF-8 valid characters from clients.

The problem is some clients (mainly hackers) are sending all the wrong kind of data over it.

I can easily distinguish the genuine client, but I am logging to files all the data sent so I can analyze it later.

Sometimes I get characters like this œ that cause the UnicodeDecodeError error.

I need to be able to make the string UTF-8 with or without those characters.

1 Answer

0 votes
by (106k points)

You can use the below mentioned piece of code to get rid of this error:-

str = unicode(str, errors='replace')

or

str = unicode(str, errors='ignore')

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...