[Python-Dev] PEP 263 - default encoding
Martin v. Loewis
martin@v.loewis.de
15 Mar 2002 21:33:29 +0100
Paul Prescod <paul@prescod.net> writes:
> > 1. Implement the magic comment detection, but only apply the
> > detected encoding to Unicode literals in the source file.
> >
> > If no magic comment is used, Python should continue to
> > use the standard [raw-]unicode-escape codecs for Unicode
> > literals.
>
> Are we thinking about Python's unicode literal syntax as just a codec? I
> know that there is a codec that implements that syntax but I would hate
> to find out that if I use KOI8-R, I no longer have the ability to use \U
> in my code to insert Kanji.
That will continue to be possible. With an encoding declaration, it is
not the "standard" unicode-escape codec anymore. Instead, the string
is first decoded into a Unicode object, then again decoded for
escapes. The second step is a Unicode->Unicode transformation that
will be available only to parser (although there is currently a debate
whether to make it share code with the byte->unicode unicode-escape
codec).
Regards,
Martin