codekingpro/portable-devtools
114k
1#ifndef Py_INTERNAL_CODECS_H2#define Py_INTERNAL_CODECS_H3#ifdef __cplusplus4extern "C" {5#endif6 7#ifndef Py_BUILD_CORE8# error "this header requires Py_BUILD_CORE define"9#endif10 11#include "pycore_interp_structs.h" // struct codecs_state12 13/* Initialize codecs-related state for the given interpreter, including14 registering the first codec search function. Must be called before any other15 PyCodec-related functions, and while only one thread is active. */16extern PyStatus _PyCodec_InitRegistry(PyInterpreterState *interp);17 18/* Finalize codecs-related state for the given interpreter. No PyCodec-related19 functions other than PyCodec_Unregister() may be called after this. */20extern void _PyCodec_Fini(PyInterpreterState *interp);21 22extern PyObject* _PyCodec_Lookup(const char *encoding);23 24/*25 * Un-register the error handling callback function registered under26 * the given 'name'. Only custom error handlers can be un-registered.27 *28 * - Return -1 and set an exception if 'name' refers to a built-in29 * error handling name (e.g., 'strict'), or if an error occurred.30 * - Return 0 if no custom error handler can be found for 'name'.31 * - Return 1 if the custom error handler was successfully removed.32 */33extern int _PyCodec_UnregisterError(const char *name);34 35/* Text codec specific encoding and decoding API.36 37 Checks the encoding against a list of codecs which do not38 implement a str<->bytes encoding before attempting the39 operation.40 41 Please note that these APIs are internal and should not42 be used in Python C extensions.43 44 XXX (ncoghlan): should we make these, or something like them, public45 in Python 3.5+?46 47 */48extern PyObject* _PyCodec_LookupTextEncoding(49 const char *encoding,50 const char *alternate_command);51 52extern PyObject* _PyCodec_EncodeText(53 PyObject *object,54 const char *encoding,55 const char *errors);56 57extern PyObject* _PyCodec_DecodeText(58 PyObject *object,59 const char *encoding,60 const char *errors);61 62/* These two aren't actually text encoding specific, but _io.TextIOWrapper63 * is the only current API consumer.64 */65extern PyObject* _PyCodecInfo_GetIncrementalDecoder(66 PyObject *codec_info,67 const char *errors);68 69extern PyObject* _PyCodecInfo_GetIncrementalEncoder(70 PyObject *codec_info,71 const char *errors);72 73#ifdef __cplusplus74}75#endif76#endif /* !Py_INTERNAL_CODECS_H */77 