Orbits
1
|
Classes | |
class | CodecInfo |
Codec base classes (defining the API) More... | |
class | Codec |
class | IncrementalEncoder |
class | BufferedIncrementalEncoder |
class | IncrementalDecoder |
class | BufferedIncrementalDecoder |
class | StreamWriter |
class | StreamReader |
class | StreamReaderWriter |
class | StreamRecoder |
Functions | |
def | open |
def | EncodedFile |
def | getencoder |
Helpers for codec lookup. More... | |
def | getdecoder |
def | getincrementalencoder |
def | getincrementaldecoder |
def | getreader |
def | getwriter |
def | iterencode |
def | iterdecode |
def | make_identity_dict |
Helpers for charmap-based codecs. More... | |
def | make_encoding_map |
Variables | |
list | __all__ |
string | BOM_UTF8 = '\xef\xbb\xbf' |
Constants. More... | |
string | BOM_LE = '\xff\xfe' |
string | BOM_BE = '\xfe\xff' |
string | BOM_UTF32_LE = '\xff\xfe\x00\x00' |
string | BOM_UTF32_BE = '\x00\x00\xfe\xff' |
BOM = BOM_UTF16_LE | |
BOM_UTF32 = BOM_UTF32_LE | |
BOM32_LE = BOM_UTF16_LE | |
BOM32_BE = BOM_UTF16_BE | |
BOM64_LE = BOM_UTF32_LE | |
BOM64_BE = BOM_UTF32_BE | |
tuple | strict_errors = lookup_error("strict") |
error handlers More... | |
tuple | ignore_errors = lookup_error("ignore") |
tuple | replace_errors = lookup_error("replace") |
tuple | xmlcharrefreplace_errors = lookup_error("xmlcharrefreplace") |
tuple | backslashreplace_errors = lookup_error("backslashreplace") |
int | _false = 0 |
codecs -- Python Codec Registry, API and helpers. Written by Marc-Andre Lemburg (mal@lemburg.com). (c) Copyright CNRI, All Rights Reserved. NO WARRANTY.
def codecs.EncodedFile | ( | file, | |
data_encoding, | |||
file_encoding = None , |
|||
errors = 'strict' |
|||
) |
Return a wrapped version of file which provides transparent encoding translation. Strings written to the wrapped file are interpreted according to the given data_encoding and then written to the original file as string using file_encoding. The intermediate encoding will usually be Unicode but depends on the specified codecs. Strings are read from the file using file_encoding and then passed back to the caller as string using data_encoding. If file_encoding is not given, it defaults to data_encoding. errors may be given to define the error handling. It defaults to 'strict' which causes ValueErrors to be raised in case an encoding error occurs. The returned wrapped file object provides two extra attributes .data_encoding and .file_encoding which reflect the given parameters of the same name. The attributes can be used for introspection by Python programs.
def codecs.getdecoder | ( | encoding | ) |
Lookup up the codec for the given encoding and return its decoder function. Raises a LookupError in case the encoding cannot be found.
def codecs.getencoder | ( | encoding | ) |
Helpers for codec lookup.
Lookup up the codec for the given encoding and return its encoder function. Raises a LookupError in case the encoding cannot be found.
def codecs.getincrementaldecoder | ( | encoding | ) |
Lookup up the codec for the given encoding and return its IncrementalDecoder class or factory function. Raises a LookupError in case the encoding cannot be found or the codecs doesn't provide an incremental decoder.
def codecs.getincrementalencoder | ( | encoding | ) |
Lookup up the codec for the given encoding and return its IncrementalEncoder class or factory function. Raises a LookupError in case the encoding cannot be found or the codecs doesn't provide an incremental encoder.
def codecs.getreader | ( | encoding | ) |
Lookup up the codec for the given encoding and return its StreamReader class or factory function. Raises a LookupError in case the encoding cannot be found.
def codecs.getwriter | ( | encoding | ) |
Lookup up the codec for the given encoding and return its StreamWriter class or factory function. Raises a LookupError in case the encoding cannot be found.
def codecs.iterdecode | ( | iterator, | |
encoding, | |||
errors = 'strict' , |
|||
kwargs | |||
) |
Decoding iterator. Decodes the input strings from the iterator using a IncrementalDecoder. errors and kwargs are passed through to the IncrementalDecoder constructor.
def codecs.iterencode | ( | iterator, | |
encoding, | |||
errors = 'strict' , |
|||
kwargs | |||
) |
Encoding iterator. Encodes the input strings from the iterator using a IncrementalEncoder. errors and kwargs are passed through to the IncrementalEncoder constructor.
def codecs.make_encoding_map | ( | decoding_map | ) |
Creates an encoding map from a decoding map. If a target mapping in the decoding map occurs multiple times, then that target is mapped to None (undefined mapping), causing an exception when encountered by the charmap codec during translation. One example where this happens is cp875.py which decodes multiple character to \u001a.
def codecs.make_identity_dict | ( | rng | ) |
Helpers for charmap-based codecs.
make_identity_dict(rng) -> dict Return a dictionary where elements of the rng sequence are mapped to themselves.
def codecs.open | ( | filename, | |
mode = 'rb' , |
|||
encoding = None , |
|||
errors = 'strict' , |
|||
buffering = 1 |
|||
) |
Open an encoded file using the given mode and return a wrapped version providing transparent encoding/decoding. Note: The wrapped version will only accept the object format defined by the codecs, i.e. Unicode objects for most builtin codecs. Output is also codec dependent and will usually be Unicode as well. Files are always opened in binary mode, even if no binary mode was specified. This is done to avoid data loss due to encodings using 8-bit values. The default file mode is 'rb' meaning to open the file in binary read mode. encoding specifies the encoding which is to be used for the file. errors may be given to define the error handling. It defaults to 'strict' which causes ValueErrors to be raised in case an encoding error occurs. buffering has the same meaning as for the builtin open() API. It defaults to line buffered. The returned wrapped file object provides an extra attribute .encoding which allows querying the used encoding. This attribute is only available if an encoding was specified as parameter.
list codecs.__all__ |
int codecs._false = 0 |
codecs.backslashreplace_errors = lookup_error("backslashreplace") |
codecs.BOM = BOM_UTF16_LE |
codecs.BOM32_BE = BOM_UTF16_BE |
codecs.BOM32_LE = BOM_UTF16_LE |
codecs.BOM64_BE = BOM_UTF32_BE |
codecs.BOM64_LE = BOM_UTF32_LE |
string codecs.BOM_BE = '\xfe\xff' |
string codecs.BOM_LE = '\xff\xfe' |
codecs.BOM_UTF32 = BOM_UTF32_LE |
string codecs.BOM_UTF32_BE = '\x00\x00\xfe\xff' |
string codecs.BOM_UTF32_LE = '\xff\xfe\x00\x00' |
string codecs.BOM_UTF8 = '\xef\xbb\xbf' |
Constants.
codecs.ignore_errors = lookup_error("ignore") |
codecs.replace_errors = lookup_error("replace") |
codecs.strict_errors = lookup_error("strict") |
error handlers
codecs.xmlcharrefreplace_errors = lookup_error("xmlcharrefreplace") |
Copyright 2014 Google Inc. All rights reserved.