1 #ifndef Py_CODECREGISTRY_H
2 #define Py_CODECREGISTRY_H
7 /* ------------------------------------------------------------------------
9 Python Codec Registry and support functions
12 Written by Marc-Andre Lemburg (mal@lemburg.com).
14 Copyright (c) Corporation for National Research Initiatives.
16 ------------------------------------------------------------------------ */
18 /* Register a new codec search function.
20 As side effect, this tries to load the encodings package, if not
21 yet done, to make sure that it is always first in the list of
24 The search_function's refcount is incremented by this function. */
26 extern DL_IMPORT(int) PyCodec_Register(
27 PyObject
*search_function
30 /* Codec register lookup API.
32 Looks up the given encoding and returns a tuple (encoder, decoder,
33 stream reader, stream writer) of functions which implement the
34 different aspects of processing the encoding.
36 The encoding string is looked up converted to all lower-case
37 characters. This makes encodings looked up through this mechanism
38 effectively case-insensitive.
40 If no codec is found, a KeyError is set and NULL returned.
42 As side effect, this tries to load the encodings package, if not
43 yet done. This is part of the lazy load strategy for the encodings
48 extern DL_IMPORT(PyObject
*) _PyCodec_Lookup(
52 /* Generic codec based encoding API.
54 object is passed through the encoder function found for the given
55 encoding using the error handling method defined by errors. errors
56 may be NULL to use the default method defined for the codec.
58 Raises a LookupError in case no encoder can be found.
62 extern DL_IMPORT(PyObject
*) PyCodec_Encode(
68 /* Generic codec based decoding API.
70 object is passed through the decoder function found for the given
71 encoding using the error handling method defined by errors. errors
72 may be NULL to use the default method defined for the codec.
74 Raises a LookupError in case no encoder can be found.
78 extern DL_IMPORT(PyObject
*) PyCodec_Decode(
84 /* --- Codec Lookup APIs --------------------------------------------------
86 All APIs return a codec object with incremented refcount and are
87 based on _PyCodec_Lookup(). The same comments w/r to the encoding
88 name also apply to these APIs.
92 /* Get an encoder function for the given encoding. */
94 extern DL_IMPORT(PyObject
*) PyCodec_Encoder(
98 /* Get a decoder function for the given encoding. */
100 extern DL_IMPORT(PyObject
*) PyCodec_Decoder(
104 /* Get a StreamReader factory function for the given encoding. */
106 extern DL_IMPORT(PyObject
*) PyCodec_StreamReader(
107 const char *encoding
,
112 /* Get a StreamWriter factory function for the given encoding. */
114 extern DL_IMPORT(PyObject
*) PyCodec_StreamWriter(
115 const char *encoding
,
123 #endif /* !Py_CODECREGISTRY_H */