/usr/share/doc/python3-docs/html/_sources/c-api
NameSizeModeActions
abstract.rst.txt7150644editdlrm
allocation.rst.txt26530644editdlrm
apiabiversion.rst.txt22420644editdlrm
arg.rst.txt306510644editdlrm
bool.rst.txt12000644editdlrm
buffer.rst.txt222670644editdlrm
bytearray.rst.txt22500644editdlrm
bytes.rst.txt92110644editdlrm
capsule.rst.txt57410644editdlrm
cell.rst.txt19400644editdlrm
code.rst.txt16660644editdlrm
codec.rst.txt47990644editdlrm
complex.rst.txt39460644editdlrm
concrete.rst.txt20460644editdlrm
conversion.rst.txt55160644editdlrm
coro.rst.txt8200644editdlrm
datetime.rst.txt64150644editdlrm
descriptor.rst.txt11110644editdlrm
dict.rst.txt79520644editdlrm
exceptions.rst.txt478140644editdlrm
file.rst.txt32480644editdlrm
float.rst.txt22430644editdlrm
function.rst.txt33480644editdlrm
gcsupport.rst.txt60570644editdlrm
gen.rst.txt13010644editdlrm
import.rst.txt128250644editdlrm
index.rst.txt6130644editdlrm
init.rst.txt523830644editdlrm
intro.rst.txt287510644editdlrm
iter.rst.txt11290644editdlrm
iterator.rst.txt16400644editdlrm
list.rst.txt47350644editdlrm
long.rst.txt104360644editdlrm
mapping.rst.txt28710644editdlrm
marshal.rst.txt35610644editdlrm
memory.rst.txt213690644editdlrm
memoryview.rst.txt23480644editdlrm
method.rst.txt28180644editdlrm
module.rst.txt182660644editdlrm
none.rst.txt7400644editdlrm
number.rst.txt105830644editdlrm
objbuffer.rst.txt21980644editdlrm
object.rst.txt174200644editdlrm
objimpl.rst.txt3040644editdlrm
refcounting.rst.txt29090644editdlrm
reflection.rst.txt14170644editdlrm
sequence.rst.txt65470644editdlrm
set.rst.txt61440644editdlrm
slice.rst.txt24040644editdlrm
stable.rst.txt19690644editdlrm
structures.rst.txt137870644editdlrm
sys.rst.txt99440644editdlrm
tuple.rst.txt80310644editdlrm
type.rst.txt39630644editdlrm
typeobj.rst.txt601840644editdlrm
unicode.rst.txt680740644editdlrm
utilities.rst.txt4140644editdlrm
veryhigh.rst.txt166550644editdlrm
weakref.rst.txt26350644editdlrm
Edit: /usr/share/doc/python3-docs/html/_sources/c-api/codec.rst.txt (4799B)
.. _codec-registry: Codec registry and support functions ==================================== .. c:function:: int PyCodec_Register(PyObject *search_function) Register a new codec search function. As side effect, this tries to load the :mod:`encodings` package, if not yet done, to make sure that it is always first in the list of search functions. .. c:function:: int PyCodec_KnownEncoding(const char *encoding) Return ``1`` or ``0`` depending on whether there is a registered codec for the given *encoding*. .. c:function:: PyObject* PyCodec_Encode(PyObject *object, const char *encoding, const char *errors) Generic codec based encoding API. *object* is passed through the encoder function found for the given *encoding* using the error handling method defined by *errors*. *errors* may be *NULL* to use the default method defined for the codec. Raises a :exc:`LookupError` if no encoder can be found. .. c:function:: PyObject* PyCodec_Decode(PyObject *object, const char *encoding, const char *errors) Generic codec based decoding API. *object* is passed through the decoder function found for the given *encoding* using the error handling method defined by *errors*. *errors* may be *NULL* to use the default method defined for the codec. Raises a :exc:`LookupError` if no encoder can be found. Codec lookup API ---------------- In the following functions, the *encoding* string is looked up converted to all lower-case characters, which makes encodings looked up through this mechanism effectively case-insensitive. If no codec is found, a :exc:`KeyError` is set and *NULL* returned. .. c:function:: PyObject* PyCodec_Encoder(const char *encoding) Get an encoder function for the given *encoding*. .. c:function:: PyObject* PyCodec_Decoder(const char *encoding) Get a decoder function for the given *encoding*. .. c:function:: PyObject* PyCodec_IncrementalEncoder(const char *encoding, const char *errors) Get an :class:`~codecs.IncrementalEncoder` object for the given *encoding*. .. c:function:: PyObject* PyCodec_IncrementalDecoder(const char *encoding, const char *errors) Get an :class:`~codecs.IncrementalDecoder` object for the given *encoding*. .. c:function:: PyObject* PyCodec_StreamReader(const char *encoding, PyObject *stream, const char *errors) Get a :class:`~codecs.StreamReader` factory function for the given *encoding*. .. c:function:: PyObject* PyCodec_StreamWriter(const char *encoding, PyObject *stream, const char *errors) Get a :class:`~codecs.StreamWriter` factory function for the given *encoding*. Registry API for Unicode encoding error handlers ------------------------------------------------ .. c:function:: int PyCodec_RegisterError(const char *name, PyObject *error) Register the error handling callback function *error* under the given *name*. This callback function will be called by a codec when it encounters unencodable characters/undecodable bytes and *name* is specified as the error parameter in the call to the encode/decode function. The callback gets a single argument, an instance of :exc:`UnicodeEncodeError`, :exc:`UnicodeDecodeError` or :exc:`UnicodeTranslateError` that holds information about the problematic sequence of characters or bytes and their offset in the original string (see :ref:`unicodeexceptions` for functions to extract this information). The callback must either raise the given exception, or return a two-item tuple containing the replacement for the problematic sequence, and an integer giving the offset in the original string at which encoding/decoding should be resumed. Return ``0`` on success, ``-1`` on error. .. c:function:: PyObject* PyCodec_LookupError(const char *name) Lookup the error handling callback function registered under *name*. As a special case *NULL* can be passed, in which case the error handling callback for "strict" will be returned. .. c:function:: PyObject* PyCodec_StrictErrors(PyObject *exc) Raise *exc* as an exception. .. c:function:: PyObject* PyCodec_IgnoreErrors(PyObject *exc) Ignore the unicode error, skipping the faulty input. .. c:function:: PyObject* PyCodec_ReplaceErrors(PyObject *exc) Replace the unicode encode error with ``?`` or ``U+FFFD``. .. c:function:: PyObject* PyCodec_XMLCharRefReplaceErrors(PyObject *exc) Replace the unicode encode error with XML character references. .. c:function:: PyObject* PyCodec_BackslashReplaceErrors(PyObject *exc) Replace the unicode encode error with backslash escapes (``\x``, ``\u`` and ``\U``). .. c:function:: PyObject* PyCodec_NameReplaceErrors(PyObject *exc) Replace the unicode encode error with ``\N{...}`` escapes. .. versionadded:: 3.5