[I18n-sig] Codecs for Big Five and GB 2312

M.-A. Lemburg mal@lemburg.com
Tue, 31 Oct 2000 21:30:07 +0100


"Martin v. Loewis" wrote:
> 
> > Than have your application register a new search function which
> > does the necessary aliasing.
> 
> That's my point: The application author does not *know* all the
> aliases in advance. She expects Python to know about these things, for
> the same reason that Python knows about many other things (e.g. how
> base64 works, or how to find out the format of a database by just
> looking at a few bytes).

Python can't possibly know all encoding aliases nomatter how
hard we try. That's why the codec interface is open and allows
you to add aliasing support whereever needed.

Note that MIME support works in a very similar way... you can
register your own new MIME types at run-time in case you need
them.

> > Another possibility would be dropping your shift_jis.py codec
> > into the sitecodecs package... at your own risk, though, since
> > it might overwrite some already installed codec.
> 
> See, this just won't work. If I have a package sitecodecs, and
> codecs.py just does "import sitecodecs", then shift_jis.py will not be
> considered for conversions.

Sure it will: the encodings search function would be extended
to look in that specific package too.

> > Using the fully qualified name helps in case you want to use
> > different codec implementations for the same encoding.
> 
> If you want to do that, you can instantiate the codec yourself, and
> use the codec interface. No need to play magic with the strings passed
> to .encode().

But then you won't be able to pass the encoding string through
any aliasing engine... and that's what you intended, right ?

-- 
Marc-Andre Lemburg
______________________________________________________________________
Business:                                      http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/