Comment on PEP 263 - Defining Python Source Code Encodings

Martin v. Loewis martin at v.loewis.de
Sat May 11 09:41:20 EDT 2002


Robin Becker <robin at jessikat.fsnet.co.uk> writes:

> ...... Which editors use this? I suppose emacs/xemac or similar, but
> since emacs is a minority editor (even amongst unixers) I think that 
> the recognition pattern issue is open. A vi(m) compatible thing reaches
> a larger audience, but then I use that :)

Actually, the PEP defines a regex that allows for

fileencoding=<name>

which is syntax supported by vim. Unfortunately, in vim 6, this
doesn't quite work: vim applies the setting at a time when it already
has decided what encoding to use.

> No doubt pythonwin will follow whatever is decided, but what about mac
> users and all the people using notepad, ed, bliss etc etc?

Notepad users should use "save as UTF-8". This inserts the UTF-8
signature, which is also supported by the PEP.

I don't know what editors are used on the Mac, and how they can be
instructed to use an encoding which potentially differs from the one
of the current locale.

> It would be nice to know which editors (today) are unicode aware and how
> they do the encoding recognition thing. If we then also had usage
> figures, perhaps there could be a reasonable numbers game.

We do, see my list above. I expect that any editor that is "unicode
aware" will support the UTF-8 signature, atleast when reading
(hopefully also when writing).

> As for the PEP itself the only snag seems to me to be the BOM + comment
> problem. If I change the BOM by hitting saveAs myWeirdEncoding the file
> is a dead python unless I also change the comment (or is that an issue
> only with utf8 at present?).

I'm not sure I understand the problem. If you do saveAs
myWeirdEncoding, there won't be a BOM in the file unless
myWeirdEncoding is UTF-8. If there are multiple conflicting encoding
specifications in a file, the file is in error.

Regards,
Martin




More information about the Python-list mailing list