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

M.-A. Lemburg mal@lemburg.com
Thu, 26 Sep 2002 21:41:59 +0200

Guido van Rossum wrote:
> In the spambayes project we encountered some mail samples that use an
> encoding name ('ansi-x3-4-1968') that's not in encodings/aliases.py.
> (At least not until I added it to CVS yesterday.)
> I'd like the spambayes code base to be compatible with Python 2.2.1,
> so I like to add this one to the list of aliases.
> Is there an official API to add an alias, or do I just have to write
>   import encodings.aliases
>   encodings.aliases.aliases['ansi-x3-4-1968'] = 'ascii'
> ???

There's no other API to do this and since new features are
not allowed in 2.2.x that's the only way to go unless you register
your own lookup function which knows about the extra alias.

> (BTW, there's an alias 'ansi_x3.4_1986' for ASCII.  Was the ASCII
> standard renewed in 1986, or is that simply because there are encoding
> designators out there in real life that contain a typo?)

That was one of the official names for ASCII:


More details on the history of ASCII can be found at the
top of that page. The original version X3.4 was approved
in 1968, so it's not a typo.

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/