= even more encoding=


Some (at least me :) are working with a different default-encoding than "ASCII". I am using Latin-1, which solves 98% of encoding problems when dealing with Windows-Applications on a German Windows.

so in site.py I changed from ASCII to LATIN-1


When an application is py2exed, site.py is not available and not parsed. (and that is good)

So the behaviour of the py2exed and the python filename.py use of the application is quite different.


Top of the application I start with

   1 import sys
   2 # sys.setdefaultencoding may be deleted by site.py, 
   3 # so bring it back:
   4 reload(sys) 
   5 if hasattr(sys,"setdefaultencoding"):
   6     sys.setdefaultencoding("latin-1")

Another solution

To take a guess at the users preferred encoding, do like the disabled code in site.py does:

   1 import sys
   2 if hasattr(sys, 'setdefaultencoding'):
   3     import locale
   4     loc = locale.getdefaultlocale()
   5     if loc[1]:
   6         encoding = loc[1]
   7         sys.setdefaultencoding(encoding)


if site.py is run, it kills the "setdefaultencoding" attribute.

HAM20040806 - we need a ternary decorator

EvenMoreEncodings (last edited 2008-07-08 11:27:43 by localhost)