O'Reilly logo

Python: Essential Reference, Third Edition by David Beazley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

codecs

The codecs module provides an interface for accessing different string encoding and decoding functions (codecs) as well as a collection of base classes that can be used to define new codecs. The following functions are available:

register(search_function)

Registers a new codec search function. This function should take a single argument in the form of an encoding string (for example, 'utf-8') and return a tuple of functions (encoder, decoder, streamreader, streamwriter).

lookup(encoding)

Looks up a codec in the codec registry. encoding is a string such as 'utf-8'. Returns a tuple of functions (encoder, decoder, streamreader, streamwriter). Internally, this function keeps a cache of previously used encodings. If a match is not found in ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required