Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Djhtml fails to complete due to old default encoding on windows #122

Open
jeriox opened this issue Jul 30, 2024 · 2 comments
Open

Djhtml fails to complete due to old default encoding on windows #122

jeriox opened this issue Jul 30, 2024 · 2 comments

Comments

@jeriox
Copy link

jeriox commented Jul 30, 2024

When running djhtml on Windows 11 for my project, it fails with Error: 'charmap' codec can't decode byte 0x8f in position 622: character maps to <undefined>. According to various sources (e.g. https://stackoverflow.com/a/68650013) this is due to Windows using an outdated encoding (windows-1252) by default if no encoding is specified when opening the file. This encoding fails to read utf-8 characters. Adding encoding="utf-8" to the open() call in https://github.com/rtts/djhtml/blob/main/djhtml/__main__.py#L53 solves the problem for me.

@JaapJoris
Copy link
Member

Yes, this is a known issue, which is why the README contains this paragraph:

Note that Windows still uses legacy code pages instead of UTF-8. It is highly advised to set the environment variable PYTHONUTF8 to 1 with the setx command:

C:\> setx /m PYTHONUTF8 1

If this can also be fixed by adding encoding="utf-8" to the open() call, that seems like a better solution and that paragraph can be removed. Can anyone concur? Or may some people still have valid reasons to not use UTF-8 in 2024?

@jeriox
Copy link
Author

jeriox commented Jul 30, 2024

Yes, this is a known issue, which is why the README contains this paragraph:

My bad, I missed that part 😅 sorry for the inconvenience

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants