Try to get a sane encoding.
On MaxOSX locale.setlocale(locale.LC_ALL, '') does not have the
desired effect, so that locale.getlocale()[1] still returns None. So in
that case try to fallback to locale.getpreferredencoding().
<sys.getdefaultencoding()>
-
what Python itself uses to convert string <-> unicode when no
other encoding was specified
-
ascii by default
-
can be set in site.py and sitecustomize.py
<locale.getlocale()[1]>
-
what the current locale is *actually* using as the encoding for text
conversion
<locale.getpreferredencoding()>
-
what the current locale would *recommend* using as the encoding for
text conversion
|