0

Hello everyone I am trying to convert a byte string to utf-8 format. Currently the byte string is:

 b'\xf7\xc8\x9e\x81\xe0<\xeb\x8d*<2+\x85L\x9b\x86\xd1\xb7\xf2"\xc9\xaa\xf6ky\xb8\x07\x95\x91\x93\xf1\xa2\x13\xadj\x0b\xa2\xe9\\\xf8\xa9\x9b2wk\x1f\xd1\x18\x1e\x8e:?6h\xa9\x97\x1f\x0b\x90\xb8\xb7y\x03\xad'

Currently I do

my_byte_string.decode("utf-8")

However, this throws an error:

 'utf-8' codec can't decode byte 0xf7 in position 0: invalid start byte

But if I use utf-16 - it converts the string to another language other than english, how can I resolve this issue?

ashes999
  • 1,002
  • 1
  • 6
  • 19
  • 1
    Where did it come from? It may not be an encoded text string at all. Encrypted maybe? I ran `chardet.detect` on it and it couldn't guess. There is a list of encodings and you could run through them one by one to see what doesn't crash and looks okay https://stackoverflow.com/a/25584253/642070 – tdelaney Sep 14 '21 at 22:48

0 Answers0