Avatar ·

Coding error in Python: Readline() when reading UTF-8 file throws: 'charmap' codec can't decode byte

📁 string, Advanced Python Topics, AI

Trying to read the port file from Iana. It is saved in UTF-8 encoding without BOM. But on one of the lines the readline() function throws this error:

'charmap' codec can't decode byte 0x98 in position 7938: character maps to <undefined>

The line in the file looks like this:

# Jim Harlan <"" Jimh & infowest.com">

What workaround can I come up with for this? Or is there a direct solution?

upd

A workaround in the form of removing this line would work (and for some reason it's only one), but only during debugging, because later the partners will tear my hair out. I will also post the code that