Ad

Find Encoding Based On Input And Output

- 1 answer

I have a byte representation of a string, no idea what is the encoding, I know that b'\x04\x00\x00\x00\xf0\x9f\x90\x9f\x00' represents 🐟(fish character). Is it possible to find the encoding based on this information? I checked print(b'\x04\x00\x00\x00\xf0\x9f\x90\x9f\x00') prints 🐟, so terminal knows its encoding, not me.

Ad

Answer

\xf0\x9f\x90\x9f is the UTF-8 encoded character U+1F41F FISH.
The rest are useless NUL bytes and one 0x04EOT byte, which don't do a lot usually.

Ad
source: stackoverflow.com
Ad