Your file can be valid UTF-8 and still display Café . That happens when the original UTF-8 bytes for Café were decoded as Windows-1252, then the resulting wrong characters were saved as UTF-8. The browser is now reading the saved bytes correctly; the text itself is already wrong.
Problem
The key detail is that this failure leaves a recognizable trace. The original UTF-8 bytes for é are C3 A9 . Read as Windows-1252, those bytes become the characters é . Saving that text as UTF-8 writes new bytes for those two characters. A <meta charset="UTF-8"> declaration can correctly describe the new file, but it cannot infer that é used to be é .
# Text in the damaged file: Café
# The inverse of the mistaken decode: "Café".encode("cp1252").decode("utf-8") # 'Café'
Enter fullscreen mode
Exit fullscreen mode
This is not a general rule that every occurrence of à is corrupt. The same characters can appear legitimately, and not every mojibake sequence has this exact history.…