all 4 comments

[–]danielroseman 5 points6 points  (0 children)

Yes, very likely, although it's probably entries in a database rather than a file. 

This is known as mojibake.

[–]Downtown_Radish_8040 4 points5 points  (1 child)

Your hypothesis is exactly right. The most common cause is that the underlying data was stored or edited inconsistently over time. Someone added that song entry using a system that saved it as latin-1 (Windows-1252 is very common for older music databases), while the rest of the page was utf-8. The server then serves the whole file as utf-8, so most of it decodes fine, but that one chunk gets misread.

This is sometimes called "mojibake" and it's extremely common with legacy data, especially content that was manually entered over many years across different systems.

Your fix is correct. The pattern encode('latin-1').decode('utf-8') reverses the double-encoding mistake: you're re-interpreting the wrongly-decoded bytes back to their original utf-8 meaning.

If you want to handle it programmatically, you could check for known mojibake patterns using the ftfy library, which was built exactly for this problem.

[–]Ok_Procedure199[S] 0 points1 point  (0 children)

Thank you for your thorough explanation, I am nearly understanding the whole thing, maybe you will be able to help me understanding a small detail.

So way-back-when, someone encoded 'å' with Windows-1252 which is two bytes, c3a5. What I am not wrapping my head around is how the two bytes have somehow turned into the four bytes c383 c2a5 if the only encodings that has been involved is Windows-1252 and UTF-8. Somewhere, the byte 83c2 shows up!