I am pulling my hair out on this issue for several hours.
I have a message file that I want to generate using the django makemessages command, which works fine in a Linux environment that actually handles locale settings efficiently. However, when I try to do the same on Windows, every time python tries to open the file, it assumes that it is encoded in cp932(SHIFT-JIS), which causes all kinds of chaos.
Manually adding encoding='utf-8'to each call openworks, but this is hardly a good way to fix the problem. Is there a way to force the openuse of a specific standard encoding?
sys.getdefaultencoding() returns "utf-8", for some secret reason this setting is not respected.- PYTHONIOENCODING and PYTHONENCODING are both set to 'utf-8'
- My code page is set to
cp65001
This is my python version string:
Python 3.3.2 (v3.3.2:d047928ae3f6, May 16 2013, 00:06:53) [MSC v.1600 64 bit (AMD64)] on win32
EDIT: I noticed that it locale.getpreferredencoding()returns cp932, so I think that finding the Windows locale with utf-8the default will do the trick. Is there such a thing?
source
share