I like Unicode more than I used to...

Skip Montanaro skip at pobox.com
Mon Feb 24 22:17:01 EST 2003


    Terry> Actually, what I was surprised by is the idea that the Python
    Terry> interpreter cannot determine what codec the terminal application
    Terry> understands. I would've expected this to be one of the things you
    Terry> can figure out from the environment.  In particular, I would
    Terry> expect that if such a mechanism didn't exist for ASCII terminals,
    Terry> that being Unicode capable would include some sort of sensing
    Terry> API.

I'm not sure how you think it's supposed to figure that out.  Consider that
Terminal is just a terminal emulator which can be told to run a program and
then exits when that program exits (more-or-less like xterm).  That program
could be anything, though it's usually a shell.  The only obvious way to
announce the encoding would be by exporting an environment variable to the
child program.  I'm not aware of any standard for announcing the encoding in
this fashion.  Running "env" in a Terminal window I see an environment
variable called __CF_USER_TEXT_ENCODING which has a valud of 0x1F5:0:0, but
I have no idea how to interpret it.  In addition, I see it in an xterm as
well, so it's not likely to be related directly to something Terminal is
doing.

Even if terminal emulators could export an environment variable to
subprocesses it wouldn't allow you to modify the encoding on-the-fly and
sense the change automatically.

    Terry> Also, I wonder if this in some way a fundamental obstacle, or is
    Terry> it merely that the Python interpreter doesn't implement such
    Terry> sensing.  Which suggest the question of "why not?".

I think there is a fundamental obstacle.  There just is no defined mechanism
(API or otherwise) for sensing that sort of thing.

Skip





More information about the Python-list mailing list