annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/python3.8/codecs.h @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
rev   line source
jpayne@69 1 #ifndef Py_CODECREGISTRY_H
jpayne@69 2 #define Py_CODECREGISTRY_H
jpayne@69 3 #ifdef __cplusplus
jpayne@69 4 extern "C" {
jpayne@69 5 #endif
jpayne@69 6
jpayne@69 7 /* ------------------------------------------------------------------------
jpayne@69 8
jpayne@69 9 Python Codec Registry and support functions
jpayne@69 10
jpayne@69 11
jpayne@69 12 Written by Marc-Andre Lemburg (mal@lemburg.com).
jpayne@69 13
jpayne@69 14 Copyright (c) Corporation for National Research Initiatives.
jpayne@69 15
jpayne@69 16 ------------------------------------------------------------------------ */
jpayne@69 17
jpayne@69 18 /* Register a new codec search function.
jpayne@69 19
jpayne@69 20 As side effect, this tries to load the encodings package, if not
jpayne@69 21 yet done, to make sure that it is always first in the list of
jpayne@69 22 search functions.
jpayne@69 23
jpayne@69 24 The search_function's refcount is incremented by this function. */
jpayne@69 25
jpayne@69 26 PyAPI_FUNC(int) PyCodec_Register(
jpayne@69 27 PyObject *search_function
jpayne@69 28 );
jpayne@69 29
jpayne@69 30 /* Codec registry lookup API.
jpayne@69 31
jpayne@69 32 Looks up the given encoding and returns a CodecInfo object with
jpayne@69 33 function attributes which implement the different aspects of
jpayne@69 34 processing the encoding.
jpayne@69 35
jpayne@69 36 The encoding string is looked up converted to all lower-case
jpayne@69 37 characters. This makes encodings looked up through this mechanism
jpayne@69 38 effectively case-insensitive.
jpayne@69 39
jpayne@69 40 If no codec is found, a KeyError is set and NULL returned.
jpayne@69 41
jpayne@69 42 As side effect, this tries to load the encodings package, if not
jpayne@69 43 yet done. This is part of the lazy load strategy for the encodings
jpayne@69 44 package.
jpayne@69 45
jpayne@69 46 */
jpayne@69 47
jpayne@69 48 #ifndef Py_LIMITED_API
jpayne@69 49 PyAPI_FUNC(PyObject *) _PyCodec_Lookup(
jpayne@69 50 const char *encoding
jpayne@69 51 );
jpayne@69 52
jpayne@69 53 PyAPI_FUNC(int) _PyCodec_Forget(
jpayne@69 54 const char *encoding
jpayne@69 55 );
jpayne@69 56 #endif
jpayne@69 57
jpayne@69 58 /* Codec registry encoding check API.
jpayne@69 59
jpayne@69 60 Returns 1/0 depending on whether there is a registered codec for
jpayne@69 61 the given encoding.
jpayne@69 62
jpayne@69 63 */
jpayne@69 64
jpayne@69 65 PyAPI_FUNC(int) PyCodec_KnownEncoding(
jpayne@69 66 const char *encoding
jpayne@69 67 );
jpayne@69 68
jpayne@69 69 /* Generic codec based encoding API.
jpayne@69 70
jpayne@69 71 object is passed through the encoder function found for the given
jpayne@69 72 encoding using the error handling method defined by errors. errors
jpayne@69 73 may be NULL to use the default method defined for the codec.
jpayne@69 74
jpayne@69 75 Raises a LookupError in case no encoder can be found.
jpayne@69 76
jpayne@69 77 */
jpayne@69 78
jpayne@69 79 PyAPI_FUNC(PyObject *) PyCodec_Encode(
jpayne@69 80 PyObject *object,
jpayne@69 81 const char *encoding,
jpayne@69 82 const char *errors
jpayne@69 83 );
jpayne@69 84
jpayne@69 85 /* Generic codec based decoding API.
jpayne@69 86
jpayne@69 87 object is passed through the decoder function found for the given
jpayne@69 88 encoding using the error handling method defined by errors. errors
jpayne@69 89 may be NULL to use the default method defined for the codec.
jpayne@69 90
jpayne@69 91 Raises a LookupError in case no encoder can be found.
jpayne@69 92
jpayne@69 93 */
jpayne@69 94
jpayne@69 95 PyAPI_FUNC(PyObject *) PyCodec_Decode(
jpayne@69 96 PyObject *object,
jpayne@69 97 const char *encoding,
jpayne@69 98 const char *errors
jpayne@69 99 );
jpayne@69 100
jpayne@69 101 #ifndef Py_LIMITED_API
jpayne@69 102 /* Text codec specific encoding and decoding API.
jpayne@69 103
jpayne@69 104 Checks the encoding against a list of codecs which do not
jpayne@69 105 implement a str<->bytes encoding before attempting the
jpayne@69 106 operation.
jpayne@69 107
jpayne@69 108 Please note that these APIs are internal and should not
jpayne@69 109 be used in Python C extensions.
jpayne@69 110
jpayne@69 111 XXX (ncoghlan): should we make these, or something like them, public
jpayne@69 112 in Python 3.5+?
jpayne@69 113
jpayne@69 114 */
jpayne@69 115 PyAPI_FUNC(PyObject *) _PyCodec_LookupTextEncoding(
jpayne@69 116 const char *encoding,
jpayne@69 117 const char *alternate_command
jpayne@69 118 );
jpayne@69 119
jpayne@69 120 PyAPI_FUNC(PyObject *) _PyCodec_EncodeText(
jpayne@69 121 PyObject *object,
jpayne@69 122 const char *encoding,
jpayne@69 123 const char *errors
jpayne@69 124 );
jpayne@69 125
jpayne@69 126 PyAPI_FUNC(PyObject *) _PyCodec_DecodeText(
jpayne@69 127 PyObject *object,
jpayne@69 128 const char *encoding,
jpayne@69 129 const char *errors
jpayne@69 130 );
jpayne@69 131
jpayne@69 132 /* These two aren't actually text encoding specific, but _io.TextIOWrapper
jpayne@69 133 * is the only current API consumer.
jpayne@69 134 */
jpayne@69 135 PyAPI_FUNC(PyObject *) _PyCodecInfo_GetIncrementalDecoder(
jpayne@69 136 PyObject *codec_info,
jpayne@69 137 const char *errors
jpayne@69 138 );
jpayne@69 139
jpayne@69 140 PyAPI_FUNC(PyObject *) _PyCodecInfo_GetIncrementalEncoder(
jpayne@69 141 PyObject *codec_info,
jpayne@69 142 const char *errors
jpayne@69 143 );
jpayne@69 144 #endif
jpayne@69 145
jpayne@69 146
jpayne@69 147
jpayne@69 148 /* --- Codec Lookup APIs --------------------------------------------------
jpayne@69 149
jpayne@69 150 All APIs return a codec object with incremented refcount and are
jpayne@69 151 based on _PyCodec_Lookup(). The same comments w/r to the encoding
jpayne@69 152 name also apply to these APIs.
jpayne@69 153
jpayne@69 154 */
jpayne@69 155
jpayne@69 156 /* Get an encoder function for the given encoding. */
jpayne@69 157
jpayne@69 158 PyAPI_FUNC(PyObject *) PyCodec_Encoder(
jpayne@69 159 const char *encoding
jpayne@69 160 );
jpayne@69 161
jpayne@69 162 /* Get a decoder function for the given encoding. */
jpayne@69 163
jpayne@69 164 PyAPI_FUNC(PyObject *) PyCodec_Decoder(
jpayne@69 165 const char *encoding
jpayne@69 166 );
jpayne@69 167
jpayne@69 168 /* Get an IncrementalEncoder object for the given encoding. */
jpayne@69 169
jpayne@69 170 PyAPI_FUNC(PyObject *) PyCodec_IncrementalEncoder(
jpayne@69 171 const char *encoding,
jpayne@69 172 const char *errors
jpayne@69 173 );
jpayne@69 174
jpayne@69 175 /* Get an IncrementalDecoder object function for the given encoding. */
jpayne@69 176
jpayne@69 177 PyAPI_FUNC(PyObject *) PyCodec_IncrementalDecoder(
jpayne@69 178 const char *encoding,
jpayne@69 179 const char *errors
jpayne@69 180 );
jpayne@69 181
jpayne@69 182 /* Get a StreamReader factory function for the given encoding. */
jpayne@69 183
jpayne@69 184 PyAPI_FUNC(PyObject *) PyCodec_StreamReader(
jpayne@69 185 const char *encoding,
jpayne@69 186 PyObject *stream,
jpayne@69 187 const char *errors
jpayne@69 188 );
jpayne@69 189
jpayne@69 190 /* Get a StreamWriter factory function for the given encoding. */
jpayne@69 191
jpayne@69 192 PyAPI_FUNC(PyObject *) PyCodec_StreamWriter(
jpayne@69 193 const char *encoding,
jpayne@69 194 PyObject *stream,
jpayne@69 195 const char *errors
jpayne@69 196 );
jpayne@69 197
jpayne@69 198 /* Unicode encoding error handling callback registry API */
jpayne@69 199
jpayne@69 200 /* Register the error handling callback function error under the given
jpayne@69 201 name. This function will be called by the codec when it encounters
jpayne@69 202 unencodable characters/undecodable bytes and doesn't know the
jpayne@69 203 callback name, when name is specified as the error parameter
jpayne@69 204 in the call to the encode/decode function.
jpayne@69 205 Return 0 on success, -1 on error */
jpayne@69 206 PyAPI_FUNC(int) PyCodec_RegisterError(const char *name, PyObject *error);
jpayne@69 207
jpayne@69 208 /* Lookup the error handling callback function registered under the given
jpayne@69 209 name. As a special case NULL can be passed, in which case
jpayne@69 210 the error handling callback for "strict" will be returned. */
jpayne@69 211 PyAPI_FUNC(PyObject *) PyCodec_LookupError(const char *name);
jpayne@69 212
jpayne@69 213 /* raise exc as an exception */
jpayne@69 214 PyAPI_FUNC(PyObject *) PyCodec_StrictErrors(PyObject *exc);
jpayne@69 215
jpayne@69 216 /* ignore the unicode error, skipping the faulty input */
jpayne@69 217 PyAPI_FUNC(PyObject *) PyCodec_IgnoreErrors(PyObject *exc);
jpayne@69 218
jpayne@69 219 /* replace the unicode encode error with ? or U+FFFD */
jpayne@69 220 PyAPI_FUNC(PyObject *) PyCodec_ReplaceErrors(PyObject *exc);
jpayne@69 221
jpayne@69 222 /* replace the unicode encode error with XML character references */
jpayne@69 223 PyAPI_FUNC(PyObject *) PyCodec_XMLCharRefReplaceErrors(PyObject *exc);
jpayne@69 224
jpayne@69 225 /* replace the unicode encode error with backslash escapes (\x, \u and \U) */
jpayne@69 226 PyAPI_FUNC(PyObject *) PyCodec_BackslashReplaceErrors(PyObject *exc);
jpayne@69 227
jpayne@69 228 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
jpayne@69 229 /* replace the unicode encode error with backslash escapes (\N, \x, \u and \U) */
jpayne@69 230 PyAPI_FUNC(PyObject *) PyCodec_NameReplaceErrors(PyObject *exc);
jpayne@69 231 #endif
jpayne@69 232
jpayne@69 233 #ifndef Py_LIMITED_API
jpayne@69 234 PyAPI_DATA(const char *) Py_hexdigits;
jpayne@69 235 #endif
jpayne@69 236
jpayne@69 237 #ifdef __cplusplus
jpayne@69 238 }
jpayne@69 239 #endif
jpayne@69 240 #endif /* !Py_CODECREGISTRY_H */