codecs¶
codecs – Python Codec Registry, API and helpers.
Written by Marc-Andre Lemburg (mal@lemburg.com).
- Copyright CNRI, All Rights Reserved. NO WARRANTY.
Functions¶
EncodedFile(file, data_encoding[, ...]) |
Return a wrapped version of file which provides transparent encoding translation. |
ascii_decode |
|
ascii_encode |
|
backslashreplace_errors |
Implements the ‘backslashreplace’ error handling, which replaces an unencodable character with a backslashed escape sequence. |
charbuffer_encode |
|
charmap_build |
|
charmap_decode |
|
charmap_encode |
|
decode((obj, [encoding[,errors]]) -> object) |
Decodes obj using the codec registered for encoding. |
encode((obj, [encoding[,errors]]) -> object) |
Encodes obj using the codec registered for encoding. |
escape_decode |
|
escape_encode |
|
getdecoder(encoding) |
Lookup up the codec for the given encoding and return its decoder function. |
getencoder(encoding) |
Lookup up the codec for the given encoding and return its encoder function. |
getincrementaldecoder(encoding) |
Lookup up the codec for the given encoding and return its IncrementalDecoder class or factory function. |
getincrementalencoder(encoding) |
Lookup up the codec for the given encoding and return its IncrementalEncoder class or factory function. |
getreader(encoding) |
Lookup up the codec for the given encoding and return its StreamReader class or factory function. |
getwriter(encoding) |
Lookup up the codec for the given encoding and return its StreamWriter class or factory function. |
ignore_errors |
Implements the ‘ignore’ error handling, which ignores malformed data and continues. |
iterdecode(iterator, encoding[, errors]) |
Decoding iterator. |
iterencode(iterator, encoding[, errors]) |
Encoding iterator. |
latin_1_decode |
|
latin_1_encode |
|
lookup((encoding) -> CodecInfo) |
Looks up a codec tuple in the Python codec registry and returns a CodecInfo object. |
lookup_error((errors) -> handler) |
Return the error handler for the specified error handling name or raise a LookupError, if no handler exists under this name. |
make_encoding_map(decoding_map) |
Creates an encoding map from a decoding map. |
make_identity_dict((rng) -> dict) |
Return a dictionary where elements of the rng sequence are mapped to themselves. |
open(filename[, mode, encoding, errors, ...]) |
Open an encoded file using the given mode and return a wrapped version providing transparent encoding/decoding. |
raw_unicode_escape_decode |
|
raw_unicode_escape_encode |
|
readbuffer_encode |
|
register(search_function) |
Register a codec search function. |
register_error(errors, handler) |
Register the specified error handler under the name errors. |
replace_errors |
Implements the ‘replace’ error handling, which replaces malformed data with a replacement marker. |
strict_errors |
Implements the ‘strict’ error handling, which raises a UnicodeError on coding errors. |
unicode_escape_decode |
|
unicode_escape_encode |
|
unicode_internal_decode |
|
unicode_internal_encode |
|
utf_16_be_decode |
|
utf_16_be_encode |
|
utf_16_decode |
|
utf_16_encode |
|
utf_16_ex_decode |
|
utf_16_le_decode |
|
utf_16_le_encode |
|
utf_32_be_decode |
|
utf_32_be_encode |
|
utf_32_decode |
|
utf_32_encode |
|
utf_32_ex_decode |
|
utf_32_le_decode |
|
utf_32_le_encode |
|
utf_7_decode |
|
utf_7_encode |
|
utf_8_decode |
|
utf_8_encode |
|
xmlcharrefreplace_errors |
Implements the ‘xmlcharrefreplace’ error handling, which replaces an unencodable character with the appropriate XML character reference. |
Classes¶
BufferedIncrementalDecoder([errors]) |
This subclass of IncrementalDecoder can be used as the baseclass for an incremental decoder if the decoder must be able to handle incomplete byte sequences. |
BufferedIncrementalEncoder([errors]) |
This subclass of IncrementalEncoder can be used as the baseclass for an incremental encoder if the encoder must keep some of the output in a buffer between calls to encode(). |
Codec |
Defines the interface for stateless encoders/decoders. |
CodecInfo |
Codec details when looking up the codec registry |
IncrementalDecoder([errors]) |
An IncrementalDecoder decodes an input in multiple steps. |
IncrementalEncoder([errors]) |
An IncrementalEncoder encodes an input in multiple steps. |
StreamReader(stream[, errors]) |
|
StreamReaderWriter(stream, Reader, Writer[, ...]) |
StreamReaderWriter instances allow wrapping streams which work in both read and write modes. |
StreamRecoder(stream, encode, decode, ...[, ...]) |
StreamRecoder instances provide a frontend - backend view of encoding data. |
StreamWriter(stream[, errors]) |