Reputation: 10193
My script raises a UnicodeDecodeError when run in the Windows 8 console, but not when run in Eclipse/PyDev as a launch configuration. Where is the difference between the PyDev environment and running python.exe from the console in regards to unicode?
Upvotes: 0
Views: 632
Reputation: 10193
The difference is the default encoding. You can retrieve this via sys.getdefaultencoding()
. You will notice that the default encoding in a Windows 8 shell is ascii
, while PyDev defaults a launch configuration's default encoding to the project's default encoding, which itself defaults to Cp1252
.
There are a few (problematic) tricks to change in the default encoding in code, primarily reload(sys); sys.setdefaultencoding('myencoding')
. Ian Bicking documented this in his blog post The Illusive setdefaultencoding.
If you just want to align the PyDev behavior to what you see in the console (or on your production servers), you can change the default encoding on the 'Common' tab of the launch configuration properties:
Upvotes: 5