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

Encoding error when running makemessages #46

Open
frayel opened this issue Apr 14, 2020 · 5 comments
Open

Encoding error when running makemessages #46

frayel opened this issue Apr 14, 2020 · 5 comments

Comments

@frayel
Copy link

frayel commented Apr 14, 2020

Special chars in my .po file are causing error when i run makemessages:

File "H:\OneDrive\Documents\Workspace\workspace.python\executorbpm\venv\lib\site-packages\vinaigrette\management\commands\makemessages.py", line 171, in handle
for line in po_file:
File "C:\Dev\Python3.7\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 3547: character maps to

It was solved changing
vinaigrette\management\commands\makemessages.py

line 168 to:
with open(po_path, encoding='utf-8') as po_file:

line 194 to:
with open(po_path, 'w', encoding='utf-8') as po_file:

@jordiecometrica
Copy link
Contributor

I don't understand the proposed fix. How did you come to this conclusion?

@jordiecometrica
Copy link
Contributor

Oh, I see, the default encoding is platform-dependent. It's probably UTF-16 or something on Windows.

@frayel
Copy link
Author

frayel commented Apr 14, 2020

Yes, i am using it at windows. Probably cp1252...
I don't know if this is the best solution. But worked here.. :)

Thank you, django-vinaigrette is being very useful here

@EParisot
Copy link

EParisot commented Jun 1, 2021

is it gonna be an official patch for this issue ?

@Ultraspider
Copy link

Hi.
I've been bitten by this more than once on windows as well.
Looking at Django's own makemessage.py command file, every call to open() has encoding='utf-8' specified.
So I guess it would make sense to apply the same behavior when handling the .po file made by those calls.

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

4 participants