|
|
|||
File indexing completed on 2025-11-19 09:50:53
0001 #ifndef Py_CODECREGISTRY_H 0002 #define Py_CODECREGISTRY_H 0003 #ifdef __cplusplus 0004 extern "C" { 0005 #endif 0006 0007 /* ------------------------------------------------------------------------ 0008 0009 Python Codec Registry and support functions 0010 0011 0012 Written by Marc-Andre Lemburg (mal@lemburg.com). 0013 0014 Copyright (c) Corporation for National Research Initiatives. 0015 0016 ------------------------------------------------------------------------ */ 0017 0018 /* Register a new codec search function. 0019 0020 As side effect, this tries to load the encodings package, if not 0021 yet done, to make sure that it is always first in the list of 0022 search functions. 0023 0024 The search_function's refcount is incremented by this function. */ 0025 0026 PyAPI_FUNC(int) PyCodec_Register( 0027 PyObject *search_function 0028 ); 0029 0030 /* Unregister a codec search function and clear the registry's cache. 0031 If the search function is not registered, do nothing. 0032 Return 0 on success. Raise an exception and return -1 on error. */ 0033 0034 PyAPI_FUNC(int) PyCodec_Unregister( 0035 PyObject *search_function 0036 ); 0037 0038 /* Codec registry encoding check API. 0039 0040 Returns 1/0 depending on whether there is a registered codec for 0041 the given encoding. 0042 0043 */ 0044 0045 PyAPI_FUNC(int) PyCodec_KnownEncoding( 0046 const char *encoding 0047 ); 0048 0049 /* Generic codec based encoding API. 0050 0051 object is passed through the encoder function found for the given 0052 encoding using the error handling method defined by errors. errors 0053 may be NULL to use the default method defined for the codec. 0054 0055 Raises a LookupError in case no encoder can be found. 0056 0057 */ 0058 0059 PyAPI_FUNC(PyObject *) PyCodec_Encode( 0060 PyObject *object, 0061 const char *encoding, 0062 const char *errors 0063 ); 0064 0065 /* Generic codec based decoding API. 0066 0067 object is passed through the decoder function found for the given 0068 encoding using the error handling method defined by errors. errors 0069 may be NULL to use the default method defined for the codec. 0070 0071 Raises a LookupError in case no encoder can be found. 0072 0073 */ 0074 0075 PyAPI_FUNC(PyObject *) PyCodec_Decode( 0076 PyObject *object, 0077 const char *encoding, 0078 const char *errors 0079 ); 0080 0081 // --- Codec Lookup APIs -------------------------------------------------- 0082 0083 /* Codec registry lookup API. 0084 0085 Looks up the given encoding and returns a CodecInfo object with 0086 function attributes which implement the different aspects of 0087 processing the encoding. 0088 0089 The encoding string is looked up converted to all lower-case 0090 characters. This makes encodings looked up through this mechanism 0091 effectively case-insensitive. 0092 0093 If no codec is found, a KeyError is set and NULL returned. 0094 0095 As side effect, this tries to load the encodings package, if not 0096 yet done. This is part of the lazy load strategy for the encodings 0097 package. 0098 */ 0099 0100 /* Get an encoder function for the given encoding. */ 0101 0102 PyAPI_FUNC(PyObject *) PyCodec_Encoder(const char *encoding); 0103 0104 /* Get a decoder function for the given encoding. */ 0105 0106 PyAPI_FUNC(PyObject *) PyCodec_Decoder(const char *encoding); 0107 0108 /* Get an IncrementalEncoder object for the given encoding. */ 0109 0110 PyAPI_FUNC(PyObject *) PyCodec_IncrementalEncoder( 0111 const char *encoding, 0112 const char *errors); 0113 0114 /* Get an IncrementalDecoder object function for the given encoding. */ 0115 0116 PyAPI_FUNC(PyObject *) PyCodec_IncrementalDecoder( 0117 const char *encoding, 0118 const char *errors); 0119 0120 /* Get a StreamReader factory function for the given encoding. */ 0121 0122 PyAPI_FUNC(PyObject *) PyCodec_StreamReader( 0123 const char *encoding, 0124 PyObject *stream, 0125 const char *errors); 0126 0127 /* Get a StreamWriter factory function for the given encoding. */ 0128 0129 PyAPI_FUNC(PyObject *) PyCodec_StreamWriter( 0130 const char *encoding, 0131 PyObject *stream, 0132 const char *errors); 0133 0134 /* Unicode encoding error handling callback registry API */ 0135 0136 /* Register the error handling callback function error under the given 0137 name. This function will be called by the codec when it encounters 0138 unencodable characters/undecodable bytes and doesn't know the 0139 callback name, when name is specified as the error parameter 0140 in the call to the encode/decode function. 0141 Return 0 on success, -1 on error */ 0142 PyAPI_FUNC(int) PyCodec_RegisterError(const char *name, PyObject *error); 0143 0144 /* Lookup the error handling callback function registered under the given 0145 name. As a special case NULL can be passed, in which case 0146 the error handling callback for "strict" will be returned. */ 0147 PyAPI_FUNC(PyObject *) PyCodec_LookupError(const char *name); 0148 0149 /* raise exc as an exception */ 0150 PyAPI_FUNC(PyObject *) PyCodec_StrictErrors(PyObject *exc); 0151 0152 /* ignore the unicode error, skipping the faulty input */ 0153 PyAPI_FUNC(PyObject *) PyCodec_IgnoreErrors(PyObject *exc); 0154 0155 /* replace the unicode encode error with ? or U+FFFD */ 0156 PyAPI_FUNC(PyObject *) PyCodec_ReplaceErrors(PyObject *exc); 0157 0158 /* replace the unicode encode error with XML character references */ 0159 PyAPI_FUNC(PyObject *) PyCodec_XMLCharRefReplaceErrors(PyObject *exc); 0160 0161 /* replace the unicode encode error with backslash escapes (\x, \u and \U) */ 0162 PyAPI_FUNC(PyObject *) PyCodec_BackslashReplaceErrors(PyObject *exc); 0163 0164 #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000 0165 /* replace the unicode encode error with backslash escapes (\N, \x, \u and \U) */ 0166 PyAPI_FUNC(PyObject *) PyCodec_NameReplaceErrors(PyObject *exc); 0167 #endif 0168 0169 #ifndef Py_LIMITED_API 0170 PyAPI_DATA(const char *) Py_hexdigits; 0171 #endif 0172 0173 #ifdef __cplusplus 0174 } 0175 #endif 0176 #endif /* !Py_CODECREGISTRY_H */
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|