]> git.proxmox.com Git - mirror_edk2.git/blame - AppPkg/Applications/Python/Python-2.7.10/Include/codecs.h
AppPkg/Applications/Python/Python-2.7.10: Initial Checkin part 1/5.
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.10 / Include / codecs.h
CommitLineData
c8042e10
DM
1#ifndef Py_CODECREGISTRY_H\r
2#define Py_CODECREGISTRY_H\r
3#ifdef __cplusplus\r
4extern "C" {\r
5#endif\r
6\r
7/* ------------------------------------------------------------------------\r
8\r
9 Python Codec Registry and support functions\r
10\r
11\r
12Written by Marc-Andre Lemburg (mal@lemburg.com).\r
13\r
14Copyright (c) Corporation for National Research Initiatives.\r
15\r
16 ------------------------------------------------------------------------ */\r
17\r
18/* Register a new codec search function.\r
19\r
20 As side effect, this tries to load the encodings package, if not\r
21 yet done, to make sure that it is always first in the list of\r
22 search functions.\r
23\r
24 The search_function's refcount is incremented by this function. */\r
25\r
26PyAPI_FUNC(int) PyCodec_Register(\r
27 PyObject *search_function\r
28 );\r
29\r
30/* Codec register lookup API.\r
31\r
32 Looks up the given encoding and returns a CodecInfo object with\r
33 function attributes which implement the different aspects of\r
34 processing the encoding.\r
35\r
36 The encoding string is looked up converted to all lower-case\r
37 characters. This makes encodings looked up through this mechanism\r
38 effectively case-insensitive.\r
39\r
40 If no codec is found, a KeyError is set and NULL returned.\r
41\r
42 As side effect, this tries to load the encodings package, if not\r
43 yet done. This is part of the lazy load strategy for the encodings\r
44 package.\r
45\r
46 */\r
47\r
48PyAPI_FUNC(PyObject *) _PyCodec_Lookup(\r
49 const char *encoding\r
50 );\r
51\r
52/* Generic codec based encoding API.\r
53\r
54 object is passed through the encoder function found for the given\r
55 encoding using the error handling method defined by errors. errors\r
56 may be NULL to use the default method defined for the codec.\r
57 \r
58 Raises a LookupError in case no encoder can be found.\r
59\r
60 */\r
61\r
62PyAPI_FUNC(PyObject *) PyCodec_Encode(\r
63 PyObject *object,\r
64 const char *encoding,\r
65 const char *errors\r
66 );\r
67\r
68/* Generic codec based decoding API.\r
69\r
70 object is passed through the decoder function found for the given\r
71 encoding using the error handling method defined by errors. errors\r
72 may be NULL to use the default method defined for the codec.\r
73 \r
74 Raises a LookupError in case no encoder can be found.\r
75\r
76 */\r
77\r
78PyAPI_FUNC(PyObject *) PyCodec_Decode(\r
79 PyObject *object,\r
80 const char *encoding,\r
81 const char *errors\r
82 );\r
83\r
84/* --- Codec Lookup APIs -------------------------------------------------- \r
85\r
86 All APIs return a codec object with incremented refcount and are\r
87 based on _PyCodec_Lookup(). The same comments w/r to the encoding\r
88 name also apply to these APIs.\r
89\r
90*/\r
91\r
92/* Get an encoder function for the given encoding. */\r
93\r
94PyAPI_FUNC(PyObject *) PyCodec_Encoder(\r
95 const char *encoding\r
96 );\r
97\r
98/* Get a decoder function for the given encoding. */\r
99\r
100PyAPI_FUNC(PyObject *) PyCodec_Decoder(\r
101 const char *encoding\r
102 );\r
103\r
104/* Get a IncrementalEncoder object for the given encoding. */\r
105\r
106PyAPI_FUNC(PyObject *) PyCodec_IncrementalEncoder(\r
107 const char *encoding,\r
108 const char *errors\r
109 );\r
110\r
111/* Get a IncrementalDecoder object function for the given encoding. */\r
112\r
113PyAPI_FUNC(PyObject *) PyCodec_IncrementalDecoder(\r
114 const char *encoding,\r
115 const char *errors\r
116 );\r
117\r
118/* Get a StreamReader factory function for the given encoding. */\r
119\r
120PyAPI_FUNC(PyObject *) PyCodec_StreamReader(\r
121 const char *encoding,\r
122 PyObject *stream,\r
123 const char *errors\r
124 );\r
125\r
126/* Get a StreamWriter factory function for the given encoding. */\r
127\r
128PyAPI_FUNC(PyObject *) PyCodec_StreamWriter(\r
129 const char *encoding,\r
130 PyObject *stream,\r
131 const char *errors\r
132 );\r
133\r
134/* Unicode encoding error handling callback registry API */\r
135\r
136/* Register the error handling callback function error under the given\r
137 name. This function will be called by the codec when it encounters\r
138 unencodable characters/undecodable bytes and doesn't know the\r
139 callback name, when name is specified as the error parameter\r
140 in the call to the encode/decode function.\r
141 Return 0 on success, -1 on error */\r
142PyAPI_FUNC(int) PyCodec_RegisterError(const char *name, PyObject *error);\r
143\r
144/* Lookup the error handling callback function registered under the given\r
145 name. As a special case NULL can be passed, in which case\r
146 the error handling callback for "strict" will be returned. */\r
147PyAPI_FUNC(PyObject *) PyCodec_LookupError(const char *name);\r
148\r
149/* raise exc as an exception */\r
150PyAPI_FUNC(PyObject *) PyCodec_StrictErrors(PyObject *exc);\r
151\r
152/* ignore the unicode error, skipping the faulty input */\r
153PyAPI_FUNC(PyObject *) PyCodec_IgnoreErrors(PyObject *exc);\r
154\r
155/* replace the unicode encode error with ? or U+FFFD */\r
156PyAPI_FUNC(PyObject *) PyCodec_ReplaceErrors(PyObject *exc);\r
157\r
158/* replace the unicode encode error with XML character references */\r
159PyAPI_FUNC(PyObject *) PyCodec_XMLCharRefReplaceErrors(PyObject *exc);\r
160\r
161/* replace the unicode encode error with backslash escapes (\x, \u and \U) */\r
162PyAPI_FUNC(PyObject *) PyCodec_BackslashReplaceErrors(PyObject *exc);\r
163\r
164#ifdef __cplusplus\r
165}\r
166#endif\r
167#endif /* !Py_CODECREGISTRY_H */\r