[I18n-sig] New Unicode default encoding scheme

Guido van Rossum guido@beopen.com
Mon, 10 Jul 2000 09:53:04 -0500


> Yes, ascii is exactly what I want for Zope. The site.py in the current
> CVS permanently sets the default-encoding based on locale, and I wanted
> Zope's __main__ to change it back to ascii !

For now, you can edit site.py as follows (I just did this to my own
copy).  If you prefer not to edit site.py, you can provide a
sitecustomize.py module that calls sys.setdefaultencoding('ascii').

Index: site.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/site.py,v
retrieving revision 1.12
diff -c -r1.12 site.py
*** site.py	2000/06/28 14:48:01	1.12
--- site.py	2000/07/10 13:51:13
***************
*** 134,147 ****
      except LookupError:
          sys.setdefaultencoding('ascii')
  
! if 1:
      # Enable to support locale aware default string encodings.
      locale_aware_defaultencoding()
  elif 0:
      # Enable to switch off string to Unicode coercion and implicit
      # Unicode to string conversion.
      sys.setdefaultencoding('undefined')
! elif 0:
      # Enable to hard-code a site specific default string encoding.
      sys.setdefaultencoding('ascii')
  
--- 134,147 ----
      except LookupError:
          sys.setdefaultencoding('ascii')
  
! if 0:
      # Enable to support locale aware default string encodings.
      locale_aware_defaultencoding()
  elif 0:
      # Enable to switch off string to Unicode coercion and implicit
      # Unicode to string conversion.
      sys.setdefaultencoding('undefined')
! elif 1:
      # Enable to hard-code a site specific default string encoding.
      sys.setdefaultencoding('ascii')
  

--Guido van Rossum (home page: http://dinsdale.python.org/~guido/)