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

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


> > 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.

Thanks, I'll do that.

> > (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:
> 
> http://www.archivists.org/catalog/stds99/chapter7.html#x3_4
> 
> 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.

Wow.  Cute.

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