I'm tring to setup a little chat program in python. Everything was working fine until I sent a string containing a non ascii character that caused the program to crash. The string are read from a wx.TestCtrl
How can I send a string with UTF-8 encoding over sockets?
Why does the program work without problems at the start? I have set the encoding to UTF-8 so wouldn't all character cause the program to crash?
Here is the error:
Traceback (most recent call last):
File "./client.py", line 180, in sendMess
outSock.sendto(s,self.serveraddr)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in position 26:
ordinal not in range(128)
Here is how I create the socket and try to send the message:
outSock = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
....
outSock.sendto(s,self.serveraddr)