Back to index

python3.2  3.2.2
Public Member Functions
codecs.Codec Class Reference

Inherited by codecs.StreamReader, codecs.StreamWriter, encodings.ascii.Codec, encodings.base64_codec.Codec, encodings.big5.Codec, encodings.big5hkscs.Codec, encodings.bz2_codec.Codec, encodings.charmap.Codec, encodings.cp037.Codec, encodings.cp1006.Codec, encodings.cp1026.Codec, encodings.cp1140.Codec, encodings.cp1250.Codec, encodings.cp1251.Codec, encodings.cp1252.Codec, encodings.cp1253.Codec, encodings.cp1254.Codec, encodings.cp1255.Codec, encodings.cp1256.Codec, encodings.cp1257.Codec, encodings.cp1258.Codec, encodings.cp424.Codec, encodings.cp437.Codec, encodings.cp500.Codec, encodings.cp720.Codec, encodings.cp737.Codec, encodings.cp775.Codec, encodings.cp850.Codec, encodings.cp852.Codec, encodings.cp855.Codec, encodings.cp856.Codec, encodings.cp857.Codec, encodings.cp858.Codec, encodings.cp860.Codec, encodings.cp861.Codec, encodings.cp862.Codec, encodings.cp863.Codec, encodings.cp864.Codec, encodings.cp865.Codec, encodings.cp866.Codec, encodings.cp869.Codec, encodings.cp874.Codec, encodings.cp875.Codec, encodings.cp932.Codec, encodings.cp949.Codec, encodings.cp950.Codec, encodings.euc_jis_2004.Codec, encodings.euc_jisx0213.Codec, encodings.euc_jp.Codec, encodings.euc_kr.Codec, encodings.gb18030.Codec, encodings.gb2312.Codec, encodings.gbk.Codec, encodings.hex_codec.Codec, encodings.hp_roman8.Codec, encodings.hz.Codec, encodings.idna.Codec, encodings.iso2022_jp.Codec, encodings.iso2022_jp_1.Codec, encodings.iso2022_jp_2004.Codec, encodings.iso2022_jp_2.Codec, encodings.iso2022_jp_3.Codec, encodings.iso2022_jp_ext.Codec, encodings.iso2022_kr.Codec, encodings.iso8859_10.Codec, encodings.iso8859_11.Codec, encodings.iso8859_13.Codec, encodings.iso8859_14.Codec, encodings.iso8859_15.Codec, encodings.iso8859_16.Codec, encodings.iso8859_1.Codec, encodings.iso8859_2.Codec, encodings.iso8859_3.Codec, encodings.iso8859_4.Codec, encodings.iso8859_5.Codec, encodings.iso8859_6.Codec, encodings.iso8859_7.Codec, encodings.iso8859_8.Codec, encodings.iso8859_9.Codec, encodings.johab.Codec, encodings.koi8_r.Codec, encodings.koi8_u.Codec, encodings.latin_1.Codec, encodings.mac_arabic.Codec, encodings.mac_centeuro.Codec, encodings.mac_croatian.Codec, encodings.mac_cyrillic.Codec, encodings.mac_farsi.Codec, encodings.mac_greek.Codec, encodings.mac_iceland.Codec, encodings.mac_latin2.Codec, encodings.mac_roman.Codec, encodings.mac_romanian.Codec, encodings.mac_turkish.Codec, encodings.palmos.Codec, encodings.ptcp154.Codec, encodings.punycode.Codec, encodings.quopri_codec.Codec, encodings.raw_unicode_escape.Codec, encodings.rot_13.Codec, encodings.shift_jis.Codec, encodings.shift_jis_2004.Codec, encodings.shift_jisx0213.Codec, encodings.tis_620.Codec, encodings.undefined.Codec, encodings.unicode_escape.Codec, encodings.unicode_internal.Codec, encodings.uu_codec.Codec, encodings.zlib_codec.Codec, and test.testcodec.Codec.

List of all members.

Public Member Functions

def encode
def decode

Detailed Description

Defines the interface for stateless encoders/decoders.

    The .encode()/.decode() methods may use different error
    handling schemes by providing the errors argument. These
    string values are predefined:

     'strict' - raise a ValueError error (or a subclass)
     'ignore' - ignore the character and continue with the next
     'replace' - replace with a suitable replacement character;
                Python will use the official U+FFFD REPLACEMENT
                CHARACTER for the builtin Unicode codecs on
                decoding and '?' on encoding.
     'xmlcharrefreplace' - Replace with the appropriate XML
                           character reference (only for encoding).
     'backslashreplace'  - Replace with backslashed escape sequences
                           (only for encoding).

    The set of allowed values can be extended via register_error.

Definition at line 94 of file codecs.py.


Member Function Documentation

def codecs.Codec.decode (   self,
  input,
  errors = 'strict' 
)
Decodes the object input and returns a tuple (output
    object, length consumed).

    input must be an object which provides the bf_getreadbuf
    buffer slot. Python strings, buffer objects and memory
    mapped files are examples of objects providing this slot.

    errors defines the error handling to apply. It defaults to
    'strict' handling.

    The method may not store state in the Codec instance. Use
    StreamCodec for codecs which have to keep state in order to
    make encoding/decoding efficient.

    The decoder must be able to handle zero length input and
    return an empty object of the output object type in this
    situation.

Reimplemented in codecs.StreamReader, encodings.punycode.Codec, encodings.idna.Codec, encodings.utf_16.StreamReader, encodings.utf_32.StreamReader, encodings.utf_8_sig.StreamReader, encodings.uu_codec.Codec, encodings.charmap.StreamReader, encodings.quopri_codec.Codec, encodings.bz2_codec.Codec, encodings.base64_codec.Codec, encodings.hex_codec.Codec, encodings.zlib_codec.Codec, encodings.undefined.Codec, encodings.hp_roman8.Codec, encodings.mac_latin2.Codec, encodings.ptcp154.Codec, encodings.rot_13.Codec, test.testcodec.Codec, encodings.cp720.Codec, encodings.palmos.Codec, encodings.cp037.Codec, encodings.cp1006.Codec, encodings.cp1026.Codec, encodings.cp1140.Codec, encodings.cp1250.Codec, encodings.cp1251.Codec, encodings.cp1252.Codec, encodings.cp1253.Codec, encodings.cp1254.Codec, encodings.cp1255.Codec, encodings.cp1256.Codec, encodings.cp1257.Codec, encodings.cp1258.Codec, encodings.cp424.Codec, encodings.cp437.Codec, encodings.cp500.Codec, encodings.cp737.Codec, encodings.cp775.Codec, encodings.cp850.Codec, encodings.cp852.Codec, encodings.cp855.Codec, encodings.cp856.Codec, encodings.cp857.Codec, encodings.cp858.Codec, encodings.cp860.Codec, encodings.cp861.Codec, encodings.cp862.Codec, encodings.cp863.Codec, encodings.cp864.Codec, encodings.cp865.Codec, encodings.cp866.Codec, encodings.cp869.Codec, encodings.cp874.Codec, encodings.cp875.Codec, encodings.iso8859_1.Codec, encodings.iso8859_10.Codec, encodings.iso8859_11.Codec, encodings.iso8859_13.Codec, encodings.iso8859_14.Codec, encodings.iso8859_15.Codec, encodings.iso8859_16.Codec, encodings.iso8859_2.Codec, encodings.iso8859_3.Codec, encodings.iso8859_4.Codec, encodings.iso8859_5.Codec, encodings.iso8859_6.Codec, encodings.iso8859_7.Codec, encodings.iso8859_8.Codec, encodings.iso8859_9.Codec, encodings.koi8_r.Codec, encodings.koi8_u.Codec, encodings.mac_arabic.Codec, encodings.mac_centeuro.Codec, encodings.mac_croatian.Codec, encodings.mac_cyrillic.Codec, encodings.mac_farsi.Codec, encodings.mac_greek.Codec, encodings.mac_iceland.Codec, encodings.mac_roman.Codec, encodings.mac_romanian.Codec, encodings.mac_turkish.Codec, and encodings.tis_620.Codec.

Definition at line 135 of file codecs.py.

00135 
00136     def decode(self, input, errors='strict'):
00137 
00138         """ Decodes the object input and returns a tuple (output
00139             object, length consumed).
00140 
00141             input must be an object which provides the bf_getreadbuf
00142             buffer slot. Python strings, buffer objects and memory
00143             mapped files are examples of objects providing this slot.
00144 
00145             errors defines the error handling to apply. It defaults to
00146             'strict' handling.
00147 
00148             The method may not store state in the Codec instance. Use
00149             StreamCodec for codecs which have to keep state in order to
00150             make encoding/decoding efficient.
00151 
00152             The decoder must be able to handle zero length input and
00153             return an empty object of the output object type in this
00154             situation.
00155 
00156         """
00157         raise NotImplementedError

Here is the caller graph for this function:

def codecs.Codec.encode (   self,
  input,
  errors = 'strict' 
)
Encodes the object input and returns a tuple (output
    object, length consumed).

    errors defines the error handling to apply. It defaults to
    'strict' handling.

    The method may not store state in the Codec instance. Use
    StreamCodec for codecs which have to keep state in order to
    make encoding/decoding efficient.

    The encoder must be able to handle zero length input and
    return an empty object of the output object type in this
    situation.

Reimplemented in encodings.punycode.Codec, encodings.idna.Codec, encodings.utf_16.StreamWriter, encodings.utf_32.StreamWriter, encodings.utf_8_sig.StreamWriter, encodings.uu_codec.Codec, encodings.charmap.StreamWriter, encodings.quopri_codec.Codec, encodings.bz2_codec.Codec, encodings.base64_codec.Codec, encodings.hex_codec.Codec, encodings.zlib_codec.Codec, encodings.undefined.Codec, encodings.hp_roman8.Codec, encodings.mac_latin2.Codec, encodings.ptcp154.Codec, encodings.rot_13.Codec, test.testcodec.Codec, encodings.cp720.Codec, encodings.palmos.Codec, encodings.cp037.Codec, encodings.cp1006.Codec, encodings.cp1026.Codec, encodings.cp1140.Codec, encodings.cp1250.Codec, encodings.cp1251.Codec, encodings.cp1252.Codec, encodings.cp1253.Codec, encodings.cp1254.Codec, encodings.cp1255.Codec, encodings.cp1256.Codec, encodings.cp1257.Codec, encodings.cp1258.Codec, encodings.cp424.Codec, encodings.cp437.Codec, encodings.cp500.Codec, encodings.cp737.Codec, encodings.cp775.Codec, encodings.cp850.Codec, encodings.cp852.Codec, encodings.cp855.Codec, encodings.cp856.Codec, encodings.cp857.Codec, encodings.cp858.Codec, encodings.cp860.Codec, encodings.cp861.Codec, encodings.cp862.Codec, encodings.cp863.Codec, encodings.cp864.Codec, encodings.cp865.Codec, encodings.cp866.Codec, encodings.cp869.Codec, encodings.cp874.Codec, encodings.cp875.Codec, encodings.iso8859_1.Codec, encodings.iso8859_10.Codec, encodings.iso8859_11.Codec, encodings.iso8859_13.Codec, encodings.iso8859_14.Codec, encodings.iso8859_15.Codec, encodings.iso8859_16.Codec, encodings.iso8859_2.Codec, encodings.iso8859_3.Codec, encodings.iso8859_4.Codec, encodings.iso8859_5.Codec, encodings.iso8859_6.Codec, encodings.iso8859_7.Codec, encodings.iso8859_8.Codec, encodings.iso8859_9.Codec, encodings.koi8_r.Codec, encodings.koi8_u.Codec, encodings.mac_arabic.Codec, encodings.mac_centeuro.Codec, encodings.mac_croatian.Codec, encodings.mac_cyrillic.Codec, encodings.mac_farsi.Codec, encodings.mac_greek.Codec, encodings.mac_iceland.Codec, encodings.mac_roman.Codec, encodings.mac_romanian.Codec, encodings.mac_turkish.Codec, and encodings.tis_620.Codec.

Definition at line 116 of file codecs.py.

00116 
00117     def encode(self, input, errors='strict'):
00118 
00119         """ Encodes the object input and returns a tuple (output
00120             object, length consumed).
00121 
00122             errors defines the error handling to apply. It defaults to
00123             'strict' handling.
00124 
00125             The method may not store state in the Codec instance. Use
00126             StreamCodec for codecs which have to keep state in order to
00127             make encoding/decoding efficient.
00128 
00129             The encoder must be able to handle zero length input and
00130             return an empty object of the output object type in this
00131             situation.
00132 
00133         """
00134         raise NotImplementedError

Here is the caller graph for this function:


The documentation for this class was generated from the following file: