[Python-Dev] How to add an encoding alias?

Guido van Rossum guido@python.org
Thu, 26 Sep 2002 16:27:47 -0400


> > Would it make sense to change the lookup function to convert *all*
> > punctuation to underscores before doing the lookup?  (Then this one
> > would actually have worked...)
> 
> Codecs must currently use names as defined by the search function in the
> encodings package:
> 
>      Codec modules must have names corresponding to standard lower-case
>      encoding names with hyphens mapped to underscores, e.g. 'utf-8' is
>      implemented by the module 'utf_8.py'.
> 
> We could extend this to:
> 
>      Codec modules must have names corresponding to standard lower-case
>      encoding names with all non-alphanumeric charactersmapped to
>      underscores, e.g. 'utf-8' is implemented by the module 'utf_8.py'
>      and 'ISO 639:1988' would be implemented as module 'iso_639_1988'.
> 
> Note that the aliasing dictionary is consulted *after*
> having applied this mapping.

+1; +1 on backport to 2.2.2 also.

Note that this requires some changes to the dict in aliases.py.

--Guido van Rossum (home page: http://www.python.org/~guido/)