Learn Python & Ethical Hacking From Scratch - Serialization issue with encoding

Hi,

I’m currently at the serialization topic and running into some trouble with it. Actually the trouble already started, when we began to send data via connection.send function, as I’m using Python3 and as far as I understood, it’s just accepting bytes according to the documentation. So to make the code working, I used .encode and .decode functions in the first place.
That works basically well, with the shortcoming, that I don’t know which codepage is used by my target system. So I ended up using .encode('utf-8', 'replace') to be at least able to transfer the data that can be encoded.
I tried to search for better solutions, but without knowing the exact encoding of the target system, i’m stuck with this halfway solution, which get’s even worse, when using serialization.
Sorry if i’m missing some obvious solution for that, but I’m really stuck with this at the moment :confused:. Would be great if some of you can help me out with this issue.