UnicodeDecodeError:' utf8'编解码器不能解码位置4中的字节0xc5:无效的连续字节

时间:2014-12-17 11:43:19

标签: python sockets utf-8 udp

我正在尝试转换从UDP连接收到的数据。这个原始数据看起来像这样,

  

♦无人机♥1}(┐û¼t=☻ô┐#─G┐╨){=♀█}┐4h)┐0Gu= {;f┐Drone2♥α∙Æûo♥╜α↑♦> r ╕╧> .a╝╥▐←>ûÑσ>û┼è╗all     1}(┐û¼t=☻ô┐#─G┐╨] {=♀█}┐4h)┐0Gu= {;f┐α∙Æûo♥╜α↑♦>r╕╧> .a╝╥▐←>ûÑσ>û┼è╗♥☺w83┐ö∟w╣ü┐ìù─;è6r?Uk►╗ï╣Ñ>♥1}(┐û¼t   =☻┐#─G┐╨] {=♀█}┐4h)┐0Gu= {;f┐☺☻♥ª─<ª¢─<ª¢─<½>↨9☺☺GÜ ♣╜ï◄-?EAI?i☻9= O   0,?├÷p╛Q; 3?♥α∙Æ☼6è╝╝E= $ 7.?☼♦= {:?♥ƒçç=!ù╥>ûo♥╜α↑♦>r╕╧ > .a╝╥▐←>ûÑσ>û┼è╗☺☻   ♥ª¢─<ª¢─<ª¢─ûo♥╜ª¢──<☻☻α↑♦>r╕╧> .a╝ª¢─<☻♥╥▐←>ûÑσ>û┼è╗ª¢─<☻╝╗▐A       wwwww╫; @

当我尝试解码时,

unpacked_data = stringdata = data.decode('utf-8')

它出错了,

Traceback (most recent call last):
File "read_udp_multicast.py", line 27, in <module>
unpacked_data = stringdata = data.decode('utf-8')
File "C:\Python27\lib\encodings\utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xd5 in position 4: invalid continuation byte.

我也尝试过像'latin-9'这样的人解码。它不起作用。数据以UDP数据包形式出现。所以不确定如何将其转换为人类可读的格式。

0 个答案:

没有答案
相关问题