3

I have difficulties converting those bytes to string:

 x = b'<strong>\xc5\xb7\xc3\xc0\xd0\xd4\xb8\xd0\xd0\xb1\xc1\xec\xb5\xa5\xbc\xe7\xb3\xa4\xd0\xe4\xb2\xbb\xb9\xe6\xd4\xf2\xc1\xac\xd2\xc2\xc8\xb9\xa3\xac\xb4\xf2\xd4\xec\xd1\xe7\xbb\xe1\xa1\xa2\xca\xb1\xc9\xd0\xb8\xd0\xca\xae\xd7\xe3\xa3\xac\xd5\xc3\xcf\xd4\xc5\xae\xd0\xd4\xf7\xc8\xc1\xa6\xa3\xac\xb4\xf3\xc1\xbf\xcf\xd6\xbb\xf5\xa3\xac\xbb\xb6\xd3\xad\xd0\xc2\xc0\xcf\xbf\xcd\xbb\xa7\xc4\xc3\xd1\xf9\xb2\xc9\xb9\xba\xa3\xa1</strong>'

if i decode via unicode-escape i got weird characters like:

'<strong>Å·ÃÀÐÔ¸ÐбÁìµ¥¼ç³¤Ðä²»¹æÔòÁ¬ÒÂȹ£¬´òÔìÑç»á¡¢Ê±ÉиÐÊ®×㣬ÕÃÏÔÅ®ÐÔ÷ÈÁ¦£¬´óÁ¿ÏÖ»õ£¬»¶Ó\xadÐÂÀϿͻ§ÄÃÑù²É¹º£¡</strong>'

instead of chinese charaters like 欧美性感斜领单肩长袖不规则连衣裙

Mike Will
  • 189
  • 15
  • 1
    Where did you get this string. I have tried all mannor of encodings on your Chinese string and none of them look like what you have. `print("欧美性感斜领单肩长袖不规则连衣裙".encode())` gives `b'\xe6\xac\xa7\xe7\xbe\x8e\xe6\x80\xa7\xe6\x84\x9f\xe6\x96\x9c\xe9\xa2\x86\xe5\x8d\x95\xe8\x82\xa9\xe9\x95\xbf\xe8\xa2\x96\xe4\xb8\x8d\xe8\xa7\x84\xe5\x88\x99\xe8\xbf\x9e\xe8\xa1\xa3\xe8\xa3\x99'`. How was this string encoded into these bytes – Chris Doyle Mar 27 '20 at 15:20
  • your bytes aren't utf-8 decodable. if you run x.decode('utf8') it throws error invalid continuation byte. Read further about this error on https://stackoverflow.com/questions/5552555/unicodedecodeerror-invalid-continuation-byte – Numan Ijaz Mar 27 '20 at 15:21

1 Answers1

6

You seem to be using the wrong encoding. The right encoding seem to be 'GB2312'.

>>> x.decode('GB2312')
'<strong>欧美性感斜领单肩长袖不规则连衣裙... more symbols</strong>'
  • 1
    I can't post this website in the answer, but I found the answer here: http://xahlee.info/w/what_encoding_do_chinese_websites_use.html – Viktor Astakhov Mar 27 '20 at 15:29