3 ms·
isn't the correct practice to use errors="surrogateescape" for precisely this purpose with any encoding? So in this case, you would use .decode("ascii", errors=
by make3 8y ago
isn't the correct practice to use errors="surrogateescape" for precisely this purpose with any encoding?
So in this case, you would use .decode("ascii", errors="surrogateescape") as the first bytes are the only ones you are sure of, and then .encode("ascii", errors="surrogateescape") to save again