I'm Using python 3.5
I have a couple of byte strings representing text that is encoded in various codecs so: b'mybytesstring' , now some are Utf8 encoded other are latin1 and so on. What I want to in the following order is:
- transform the bytes string into an ascii like string.
- transform the ascii like string back to a bytes string.
- decode the bytes string with correct codec.
The problem is that I have to move the bytes string into something that does not accept bytes objects so I'm looking for a solution that lets me do bytes -> ascii -> bytes safely.
bytesobjects, each encoded differently? I don't understand what you want to dobytes --ascii--> str --???--> bytes?bytesobjects all have different encodings. I need to put all of them into a container that does not acceptbytesobjects onlystringobjects. Then I get them out of the container and I can decode them properly with the correct encoding.