Python's 8-bit cleanness deprecated?

Roman Suzi rnd at onego.ru
Sun Feb 9 14:08:34 EST 2003


On Sun, 9 Feb 2003, Jeff Epler wrote:

>Roman,
>we're sorry there's such a minefield of different encodings.  But what
>happens if you write something koi8-r, and somebody using cp1251 downloads
>it?  

It depends on what browser do it. Some browsers automatically convert text
files from one encoding to another... Mail is also transparently converted
from one encoding to another.

>Without an encoding cookie, he'll get gibberish when he runs the
>program, since all non-ASCII strings will be in the wrong encoding.
>
>With an encoding cookie, he'll get the right thing.

No. It depends on output. When raw-8-bit are used, it is just a matter of
recoding source to get it to work. With encookies one will get gibberish on
the stdout (if stdout is used).

So, one must make 2 things instead of just recoding the file:

1. recode source file
2. change the cookie

But this is probably very specific to Russia as we have 6 encodings for
cyrillic letter: all of them in more or less use! 

BTW, it's the same with HTML and meta-tag.

Encookie will be in full glory only when most users will have Unicode-capable
stdin/stdout.

>I don't know what to suggest for printed code listings.  The GUI editor
>that people use should simply insert # -*- coding: xxx -*- automatically,
>using the right 'xxx' value.  (we're talking about idiots here, so it'll
>have to be done automatically)  And in your listing, you could just print
>    # -*- encoding: /see text/ -*-
>with // denoting italics or something that is obviously not simple program
>text.
>
>"Your" way, of trying to assume the contents of a file with high bits set,
>means that the common way of exchanging Python programs (as electronic
>files) won't work, but an uncommon way seems to present a small problem
>that you'd be forced to explain.

Ok. 

>Jeff

Sincerely yours, Roman Suzi
-- 
rnd at onego.ru =\= My AI powered by Linux RedHat 7.3







More information about the Python-list mailing list