Using more than 7 bit ASCII on windows.

Paul Moore paul.moore at uk.origin-it.com
Mon Oct 30 11:18:49 EST 2000


On Mon, 30 Oct 2000 14:54:24 +0100, "Alex Martelli"
<aleaxit at yahoo.com> wrote:
>print couldn't care less -- it delegates the transform-into-string
>to str.  str applied to a Unicode object, in turn, wants _ASCII_
>encoding, as the message on the UnicodeError is telling you.
>
>os.chdir is apparently also "calling str" (the C API equivalent
>thereof, no doubt, in both cases:-), with similar results.

That makes sense, and (sort of) clears up the confusion. I'm lost in a
mess of conflicting code pages, though (latin1, vs cp437 (OEM), ...)
But that's not a Python problem...

>It sure would be nice to have a way to control the default
>encoding -- not have ASCII hard-wired.  There is a function
>(not in the 2.0 docs -- doc error?), sys.getdefaultencoding(),
>that _tells_ you what the default encoding is (and guess
>which one...:-), but I do not know of a way to *change* it.

Put the following in sitecustomize.py. The problem is that site.py
deletes sys.setdefaultencoding at the end, presumably so that user
code can't change it...

import sys
sys.setdefaultencoding("latin1")

Hope this helps,
Paul. (Happy to be supplying an answer rather than a question!)




More information about the Python-list mailing list