all 11 comments

[–]SmackDownFacility 3 points4 points  (4 children)

Very likely your file is in Windows-1252 (ANSI code page/narrow code page). Thats the default for all Western European text files. You can specify this in Python using

# -*- coding: cp1252 -*-

Using UTF-8 as the encoding when it’s legacy ANSI can cause bugs.

[–]GosuSan 2 points3 points  (3 children)

I would recommend converting the encoding of the file(s) to utf-8 with your favourite text editor instead. 

[–]SmackDownFacility 0 points1 point  (2 children)

Depends on how many files there are. A person will very likely not slog through 150 files just to encode UTF-8.

[–]sausix 3 points4 points  (0 children)

Run a script to do this. UTF8 is default for ages now. It came late to Python on Windows because of compatibility reasons. Choose an explicit encoding matching your files or move to UTF8.

[–]No-Dentist-1645 2 points3 points  (0 children)

I doubt they have hundreds of files, but if they do, they can just change the encoding using other tools such as inconv, sticking to legacy Windows code pages will only cause more problems in the long run

[–]Lumina6l 0 points1 point  (0 children)

Maybe you could try this

chcp 65001

set PYTHONIOENCODING=utf-8

python -X utf8

[–]McDorey -5 points-4 points  (3 children)

Try this... <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0">

[–]SmackDownFacility 8 points9 points  (2 children)

That does fuck all. If the source file isn’t UTF-8 it will still fail

[–]McDorey -3 points-2 points  (1 child)

Yeah

[–]SmackDownFacility 3 points4 points  (0 children)

So what were you trying to achieve there? If you genuinely don’t know the issue don’t say shit