Opened 11 years ago
Closed 10 years ago
#422 closed defect (wontfix)
Add sitecustomize.py to set Python default encoding to UTF-8
Reported by: | akaginch | Owned by: | |
---|---|---|---|
Priority: | major | Component: | Package |
Version: | Keywords: | python27, i18n | |
Cc: |
Description
Since the default encoding of Python 2.x is ASCII, encoding / decoding strings that include non-ASCII characters without explicitly specified encoding causes UnicodeEncodeError / UnicodeDecodeError.
Some useful QGIS plugins (e.g. some algorithms of Processing, and mmqgis) can not be used with non-ASCII data because of this error.
We can avoid these errors by simply changing the default encoding to UTF-8.
There is no problem related to this change with users who use only ASCII characters.
In Python 3.x, the default encoding is UTF-8.
Python code authors still need to pay attention to encoding when writing a code which handles file path or non-UTF-8 data, but have no need to pay attention at any other time.
python27\lib\site-packages\sitecustomize.py:
import sys sys.setdefaultencoding("utf-8")
I'm closing this ticket because some modifications can be found in the plugins.