Is there a way to change the default encoding for all run configurations within Pydev?

徘徊边缘 提交于 2019-12-13 13:55:04

问题


There has been some discussion of the merits or demerits/evilness of using sys.setdefaultencoding(...) in python 2.x I'm using PyDev and I want to have the default 'out of the box' python behaviour (US-ASCII as default (non-)encoding), as I feel this is safer (I don't like the site_customize.py approach), even if more laborious.

When I'm using PyDev (particularly for running unittests) it be defaults calls sys.setdefaultencoding('UTF-8'). Other answers have recommended changing the encoding setting to 'US-ASCII' in each 'run configurations' Common tab.

I would like to change the default for all run configurations to 'US-ASCII' across pydev (per workspace) or at least globally for one Python interpreter. Is there a way to do this?

Having looked into the implementation: Pydev uses a PYDEV_CONSOLE_ENCODING environment variable to get the encoding (this is within the site_customize.py file in the org.python.pydev plugin). However this seems to be set from the setting of the run-dialog in the Run configurations drop down. The default says "inherited - UTF-8" but I haven't found anywhere to change this in pydev's settings. I've tried setting the environment variable PYDEV_CONSOLE_ENCODING in various places, but this hasn't got through to site_customize.py (instead it reads the value from the Encoding setting on the dialog tab).


回答1:


You can change the default encoding at window > preferences > general > workspace > text file encoding (set it to other > us-ascii).



来源:https://stackoverflow.com/questions/9394277/is-there-a-way-to-change-the-default-encoding-for-all-run-configurations-within

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!