[Python-Dev] How to add an encoding alias?
M.-A. Lemburg
mal@lemburg.com
Thu, 26 Sep 2002 22:14:28 +0200
Guido van Rossum wrote:
>>Guido van Rossum wrote:
>>
>>> import encodings.aliases
>>> encodings.aliases.aliases['ansi-x3-4-1968'] = 'ascii'
>>
>>In order for the lookup to work, you have to replace hyphens
>>with underscores; see the top of aliases.py.
>
>
> Good catch! Then my "fix" to aliases.py was also wrong.
>
> 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.
--
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
_______________________________________________________________________
eGenix.com -- Makers of the Python mx Extensions: mxDateTime,mxODBC,...
Python Consulting: http://www.egenix.com/
Python Software: http://www.egenix.com/files/python/