blob: 6a63cec66c9fe71bc828601d96c216a827194f45 [file] [log] [blame]
Serhiy Storchaka1009bf12015-04-03 23:53:51 +03001/*[clinic input]
2preserve
3[clinic start generated code]*/
4
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03005PyDoc_STRVAR(_codecs_register__doc__,
6"register($module, search_function, /)\n"
7"--\n"
8"\n"
9"Register a codec search function.\n"
10"\n"
11"Search functions are expected to take one argument, the encoding name in\n"
12"all lower case letters, and either return None, or a tuple of functions\n"
13"(encoder, decoder, stream_reader, stream_writer) (or a CodecInfo object).");
14
15#define _CODECS_REGISTER_METHODDEF \
16 {"register", (PyCFunction)_codecs_register, METH_O, _codecs_register__doc__},
17
18PyDoc_STRVAR(_codecs_lookup__doc__,
19"lookup($module, encoding, /)\n"
20"--\n"
21"\n"
22"Looks up a codec tuple in the Python codec registry and returns a CodecInfo object.");
23
24#define _CODECS_LOOKUP_METHODDEF \
25 {"lookup", (PyCFunction)_codecs_lookup, METH_O, _codecs_lookup__doc__},
26
27static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +030028_codecs_lookup_impl(PyObject *module, const char *encoding);
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +030029
30static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +030031_codecs_lookup(PyObject *module, PyObject *arg)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +030032{
33 PyObject *return_value = NULL;
34 const char *encoding;
35
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030036 if (!PyArg_Parse(arg, "s:lookup", &encoding)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +030037 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030038 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +030039 return_value = _codecs_lookup_impl(module, encoding);
40
41exit:
42 return return_value;
43}
44
45PyDoc_STRVAR(_codecs_encode__doc__,
Serhiy Storchakac97a9622015-08-09 12:23:08 +030046"encode($module, /, obj, encoding=\'utf-8\', errors=\'strict\')\n"
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +030047"--\n"
48"\n"
49"Encodes obj using the codec registered for encoding.\n"
50"\n"
Serhiy Storchakac97a9622015-08-09 12:23:08 +030051"The default encoding is \'utf-8\'. errors may be given to set a\n"
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +030052"different error handling scheme. Default is \'strict\' meaning that encoding\n"
53"errors raise a ValueError. Other possible values are \'ignore\', \'replace\'\n"
54"and \'backslashreplace\' as well as any other name registered with\n"
55"codecs.register_error that can handle ValueErrors.");
56
57#define _CODECS_ENCODE_METHODDEF \
58 {"encode", (PyCFunction)_codecs_encode, METH_VARARGS|METH_KEYWORDS, _codecs_encode__doc__},
59
60static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +030061_codecs_encode_impl(PyObject *module, PyObject *obj, const char *encoding,
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +030062 const char *errors);
63
64static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +030065_codecs_encode(PyObject *module, PyObject *args, PyObject *kwargs)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +030066{
67 PyObject *return_value = NULL;
Serhiy Storchaka9171a8b2016-08-14 10:52:18 +030068 static const char * const _keywords[] = {"obj", "encoding", "errors", NULL};
69 static _PyArg_Parser _parser = {"O|ss:encode", _keywords, 0};
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +030070 PyObject *obj;
71 const char *encoding = NULL;
72 const char *errors = NULL;
73
Serhiy Storchaka9171a8b2016-08-14 10:52:18 +030074 if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030075 &obj, &encoding, &errors)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +030076 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030077 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +030078 return_value = _codecs_encode_impl(module, obj, encoding, errors);
79
80exit:
81 return return_value;
82}
83
84PyDoc_STRVAR(_codecs_decode__doc__,
Serhiy Storchakac97a9622015-08-09 12:23:08 +030085"decode($module, /, obj, encoding=\'utf-8\', errors=\'strict\')\n"
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +030086"--\n"
87"\n"
88"Decodes obj using the codec registered for encoding.\n"
89"\n"
Serhiy Storchakac97a9622015-08-09 12:23:08 +030090"Default encoding is \'utf-8\'. errors may be given to set a\n"
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +030091"different error handling scheme. Default is \'strict\' meaning that encoding\n"
92"errors raise a ValueError. Other possible values are \'ignore\', \'replace\'\n"
93"and \'backslashreplace\' as well as any other name registered with\n"
94"codecs.register_error that can handle ValueErrors.");
95
96#define _CODECS_DECODE_METHODDEF \
97 {"decode", (PyCFunction)_codecs_decode, METH_VARARGS|METH_KEYWORDS, _codecs_decode__doc__},
98
99static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300100_codecs_decode_impl(PyObject *module, PyObject *obj, const char *encoding,
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300101 const char *errors);
102
103static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300104_codecs_decode(PyObject *module, PyObject *args, PyObject *kwargs)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300105{
106 PyObject *return_value = NULL;
Serhiy Storchaka9171a8b2016-08-14 10:52:18 +0300107 static const char * const _keywords[] = {"obj", "encoding", "errors", NULL};
108 static _PyArg_Parser _parser = {"O|ss:decode", _keywords, 0};
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300109 PyObject *obj;
110 const char *encoding = NULL;
111 const char *errors = NULL;
112
Serhiy Storchaka9171a8b2016-08-14 10:52:18 +0300113 if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300114 &obj, &encoding, &errors)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300115 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300116 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300117 return_value = _codecs_decode_impl(module, obj, encoding, errors);
118
119exit:
120 return return_value;
121}
122
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300123PyDoc_STRVAR(_codecs__forget_codec__doc__,
124"_forget_codec($module, encoding, /)\n"
125"--\n"
126"\n"
127"Purge the named codec from the internal codec lookup cache");
128
129#define _CODECS__FORGET_CODEC_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300130 {"_forget_codec", (PyCFunction)_codecs__forget_codec, METH_O, _codecs__forget_codec__doc__},
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300131
132static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300133_codecs__forget_codec_impl(PyObject *module, const char *encoding);
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300134
135static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300136_codecs__forget_codec(PyObject *module, PyObject *arg)
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300137{
138 PyObject *return_value = NULL;
139 const char *encoding;
140
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300141 if (!PyArg_Parse(arg, "s:_forget_codec", &encoding)) {
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300142 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300143 }
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300144 return_value = _codecs__forget_codec_impl(module, encoding);
145
146exit:
147 return return_value;
148}
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300149
150PyDoc_STRVAR(_codecs_escape_decode__doc__,
151"escape_decode($module, data, errors=None, /)\n"
152"--\n"
153"\n");
154
155#define _CODECS_ESCAPE_DECODE_METHODDEF \
156 {"escape_decode", (PyCFunction)_codecs_escape_decode, METH_VARARGS, _codecs_escape_decode__doc__},
157
158static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300159_codecs_escape_decode_impl(PyObject *module, Py_buffer *data,
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300160 const char *errors);
161
162static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300163_codecs_escape_decode(PyObject *module, PyObject *args)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300164{
165 PyObject *return_value = NULL;
166 Py_buffer data = {NULL, NULL};
167 const char *errors = NULL;
168
169 if (!PyArg_ParseTuple(args, "s*|z:escape_decode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300170 &data, &errors)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300171 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300172 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300173 return_value = _codecs_escape_decode_impl(module, &data, errors);
174
175exit:
176 /* Cleanup for data */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300177 if (data.obj) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300178 PyBuffer_Release(&data);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300179 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300180
181 return return_value;
182}
183
184PyDoc_STRVAR(_codecs_escape_encode__doc__,
185"escape_encode($module, data, errors=None, /)\n"
186"--\n"
187"\n");
188
189#define _CODECS_ESCAPE_ENCODE_METHODDEF \
190 {"escape_encode", (PyCFunction)_codecs_escape_encode, METH_VARARGS, _codecs_escape_encode__doc__},
191
192static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300193_codecs_escape_encode_impl(PyObject *module, PyObject *data,
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300194 const char *errors);
195
196static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300197_codecs_escape_encode(PyObject *module, PyObject *args)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300198{
199 PyObject *return_value = NULL;
200 PyObject *data;
201 const char *errors = NULL;
202
203 if (!PyArg_ParseTuple(args, "O!|z:escape_encode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300204 &PyBytes_Type, &data, &errors)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300205 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300206 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300207 return_value = _codecs_escape_encode_impl(module, data, errors);
208
209exit:
210 return return_value;
211}
212
213PyDoc_STRVAR(_codecs_unicode_internal_decode__doc__,
214"unicode_internal_decode($module, obj, errors=None, /)\n"
215"--\n"
216"\n");
217
218#define _CODECS_UNICODE_INTERNAL_DECODE_METHODDEF \
219 {"unicode_internal_decode", (PyCFunction)_codecs_unicode_internal_decode, METH_VARARGS, _codecs_unicode_internal_decode__doc__},
220
221static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300222_codecs_unicode_internal_decode_impl(PyObject *module, PyObject *obj,
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300223 const char *errors);
224
225static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300226_codecs_unicode_internal_decode(PyObject *module, PyObject *args)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300227{
228 PyObject *return_value = NULL;
229 PyObject *obj;
230 const char *errors = NULL;
231
232 if (!PyArg_ParseTuple(args, "O|z:unicode_internal_decode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300233 &obj, &errors)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300234 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300235 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300236 return_value = _codecs_unicode_internal_decode_impl(module, obj, errors);
237
238exit:
239 return return_value;
240}
241
242PyDoc_STRVAR(_codecs_utf_7_decode__doc__,
243"utf_7_decode($module, data, errors=None, final=False, /)\n"
244"--\n"
245"\n");
246
247#define _CODECS_UTF_7_DECODE_METHODDEF \
248 {"utf_7_decode", (PyCFunction)_codecs_utf_7_decode, METH_VARARGS, _codecs_utf_7_decode__doc__},
249
250static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300251_codecs_utf_7_decode_impl(PyObject *module, Py_buffer *data,
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300252 const char *errors, int final);
253
254static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300255_codecs_utf_7_decode(PyObject *module, PyObject *args)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300256{
257 PyObject *return_value = NULL;
258 Py_buffer data = {NULL, NULL};
259 const char *errors = NULL;
260 int final = 0;
261
262 if (!PyArg_ParseTuple(args, "y*|zi:utf_7_decode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300263 &data, &errors, &final)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300264 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300265 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300266 return_value = _codecs_utf_7_decode_impl(module, &data, errors, final);
267
268exit:
269 /* Cleanup for data */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300270 if (data.obj) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300271 PyBuffer_Release(&data);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300272 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300273
274 return return_value;
275}
276
277PyDoc_STRVAR(_codecs_utf_8_decode__doc__,
278"utf_8_decode($module, data, errors=None, final=False, /)\n"
279"--\n"
280"\n");
281
282#define _CODECS_UTF_8_DECODE_METHODDEF \
283 {"utf_8_decode", (PyCFunction)_codecs_utf_8_decode, METH_VARARGS, _codecs_utf_8_decode__doc__},
284
285static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300286_codecs_utf_8_decode_impl(PyObject *module, Py_buffer *data,
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300287 const char *errors, int final);
288
289static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300290_codecs_utf_8_decode(PyObject *module, PyObject *args)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300291{
292 PyObject *return_value = NULL;
293 Py_buffer data = {NULL, NULL};
294 const char *errors = NULL;
295 int final = 0;
296
297 if (!PyArg_ParseTuple(args, "y*|zi:utf_8_decode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300298 &data, &errors, &final)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300299 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300300 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300301 return_value = _codecs_utf_8_decode_impl(module, &data, errors, final);
302
303exit:
304 /* Cleanup for data */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300305 if (data.obj) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300306 PyBuffer_Release(&data);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300307 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300308
309 return return_value;
310}
311
312PyDoc_STRVAR(_codecs_utf_16_decode__doc__,
313"utf_16_decode($module, data, errors=None, final=False, /)\n"
314"--\n"
315"\n");
316
317#define _CODECS_UTF_16_DECODE_METHODDEF \
318 {"utf_16_decode", (PyCFunction)_codecs_utf_16_decode, METH_VARARGS, _codecs_utf_16_decode__doc__},
319
320static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300321_codecs_utf_16_decode_impl(PyObject *module, Py_buffer *data,
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300322 const char *errors, int final);
323
324static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300325_codecs_utf_16_decode(PyObject *module, PyObject *args)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300326{
327 PyObject *return_value = NULL;
328 Py_buffer data = {NULL, NULL};
329 const char *errors = NULL;
330 int final = 0;
331
332 if (!PyArg_ParseTuple(args, "y*|zi:utf_16_decode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300333 &data, &errors, &final)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300334 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300335 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300336 return_value = _codecs_utf_16_decode_impl(module, &data, errors, final);
337
338exit:
339 /* Cleanup for data */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300340 if (data.obj) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300341 PyBuffer_Release(&data);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300342 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300343
344 return return_value;
345}
346
347PyDoc_STRVAR(_codecs_utf_16_le_decode__doc__,
348"utf_16_le_decode($module, data, errors=None, final=False, /)\n"
349"--\n"
350"\n");
351
352#define _CODECS_UTF_16_LE_DECODE_METHODDEF \
353 {"utf_16_le_decode", (PyCFunction)_codecs_utf_16_le_decode, METH_VARARGS, _codecs_utf_16_le_decode__doc__},
354
355static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300356_codecs_utf_16_le_decode_impl(PyObject *module, Py_buffer *data,
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300357 const char *errors, int final);
358
359static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300360_codecs_utf_16_le_decode(PyObject *module, PyObject *args)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300361{
362 PyObject *return_value = NULL;
363 Py_buffer data = {NULL, NULL};
364 const char *errors = NULL;
365 int final = 0;
366
367 if (!PyArg_ParseTuple(args, "y*|zi:utf_16_le_decode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300368 &data, &errors, &final)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300369 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300370 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300371 return_value = _codecs_utf_16_le_decode_impl(module, &data, errors, final);
372
373exit:
374 /* Cleanup for data */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300375 if (data.obj) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300376 PyBuffer_Release(&data);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300377 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300378
379 return return_value;
380}
381
382PyDoc_STRVAR(_codecs_utf_16_be_decode__doc__,
383"utf_16_be_decode($module, data, errors=None, final=False, /)\n"
384"--\n"
385"\n");
386
387#define _CODECS_UTF_16_BE_DECODE_METHODDEF \
388 {"utf_16_be_decode", (PyCFunction)_codecs_utf_16_be_decode, METH_VARARGS, _codecs_utf_16_be_decode__doc__},
389
390static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300391_codecs_utf_16_be_decode_impl(PyObject *module, Py_buffer *data,
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300392 const char *errors, int final);
393
394static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300395_codecs_utf_16_be_decode(PyObject *module, PyObject *args)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300396{
397 PyObject *return_value = NULL;
398 Py_buffer data = {NULL, NULL};
399 const char *errors = NULL;
400 int final = 0;
401
402 if (!PyArg_ParseTuple(args, "y*|zi:utf_16_be_decode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300403 &data, &errors, &final)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300404 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300405 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300406 return_value = _codecs_utf_16_be_decode_impl(module, &data, errors, final);
407
408exit:
409 /* Cleanup for data */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300410 if (data.obj) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300411 PyBuffer_Release(&data);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300412 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300413
414 return return_value;
415}
416
417PyDoc_STRVAR(_codecs_utf_16_ex_decode__doc__,
418"utf_16_ex_decode($module, data, errors=None, byteorder=0, final=False,\n"
419" /)\n"
420"--\n"
421"\n");
422
423#define _CODECS_UTF_16_EX_DECODE_METHODDEF \
424 {"utf_16_ex_decode", (PyCFunction)_codecs_utf_16_ex_decode, METH_VARARGS, _codecs_utf_16_ex_decode__doc__},
425
426static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300427_codecs_utf_16_ex_decode_impl(PyObject *module, Py_buffer *data,
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300428 const char *errors, int byteorder, int final);
429
430static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300431_codecs_utf_16_ex_decode(PyObject *module, PyObject *args)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300432{
433 PyObject *return_value = NULL;
434 Py_buffer data = {NULL, NULL};
435 const char *errors = NULL;
436 int byteorder = 0;
437 int final = 0;
438
439 if (!PyArg_ParseTuple(args, "y*|zii:utf_16_ex_decode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300440 &data, &errors, &byteorder, &final)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300441 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300442 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300443 return_value = _codecs_utf_16_ex_decode_impl(module, &data, errors, byteorder, final);
444
445exit:
446 /* Cleanup for data */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300447 if (data.obj) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300448 PyBuffer_Release(&data);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300449 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300450
451 return return_value;
452}
453
454PyDoc_STRVAR(_codecs_utf_32_decode__doc__,
455"utf_32_decode($module, data, errors=None, final=False, /)\n"
456"--\n"
457"\n");
458
459#define _CODECS_UTF_32_DECODE_METHODDEF \
460 {"utf_32_decode", (PyCFunction)_codecs_utf_32_decode, METH_VARARGS, _codecs_utf_32_decode__doc__},
461
462static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300463_codecs_utf_32_decode_impl(PyObject *module, Py_buffer *data,
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300464 const char *errors, int final);
465
466static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300467_codecs_utf_32_decode(PyObject *module, PyObject *args)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300468{
469 PyObject *return_value = NULL;
470 Py_buffer data = {NULL, NULL};
471 const char *errors = NULL;
472 int final = 0;
473
474 if (!PyArg_ParseTuple(args, "y*|zi:utf_32_decode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300475 &data, &errors, &final)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300476 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300477 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300478 return_value = _codecs_utf_32_decode_impl(module, &data, errors, final);
479
480exit:
481 /* Cleanup for data */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300482 if (data.obj) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300483 PyBuffer_Release(&data);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300484 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300485
486 return return_value;
487}
488
489PyDoc_STRVAR(_codecs_utf_32_le_decode__doc__,
490"utf_32_le_decode($module, data, errors=None, final=False, /)\n"
491"--\n"
492"\n");
493
494#define _CODECS_UTF_32_LE_DECODE_METHODDEF \
495 {"utf_32_le_decode", (PyCFunction)_codecs_utf_32_le_decode, METH_VARARGS, _codecs_utf_32_le_decode__doc__},
496
497static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300498_codecs_utf_32_le_decode_impl(PyObject *module, Py_buffer *data,
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300499 const char *errors, int final);
500
501static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300502_codecs_utf_32_le_decode(PyObject *module, PyObject *args)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300503{
504 PyObject *return_value = NULL;
505 Py_buffer data = {NULL, NULL};
506 const char *errors = NULL;
507 int final = 0;
508
509 if (!PyArg_ParseTuple(args, "y*|zi:utf_32_le_decode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300510 &data, &errors, &final)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300511 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300512 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300513 return_value = _codecs_utf_32_le_decode_impl(module, &data, errors, final);
514
515exit:
516 /* Cleanup for data */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300517 if (data.obj) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300518 PyBuffer_Release(&data);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300519 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300520
521 return return_value;
522}
523
524PyDoc_STRVAR(_codecs_utf_32_be_decode__doc__,
525"utf_32_be_decode($module, data, errors=None, final=False, /)\n"
526"--\n"
527"\n");
528
529#define _CODECS_UTF_32_BE_DECODE_METHODDEF \
530 {"utf_32_be_decode", (PyCFunction)_codecs_utf_32_be_decode, METH_VARARGS, _codecs_utf_32_be_decode__doc__},
531
532static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300533_codecs_utf_32_be_decode_impl(PyObject *module, Py_buffer *data,
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300534 const char *errors, int final);
535
536static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300537_codecs_utf_32_be_decode(PyObject *module, PyObject *args)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300538{
539 PyObject *return_value = NULL;
540 Py_buffer data = {NULL, NULL};
541 const char *errors = NULL;
542 int final = 0;
543
544 if (!PyArg_ParseTuple(args, "y*|zi:utf_32_be_decode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300545 &data, &errors, &final)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300546 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300547 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300548 return_value = _codecs_utf_32_be_decode_impl(module, &data, errors, final);
549
550exit:
551 /* Cleanup for data */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300552 if (data.obj) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300553 PyBuffer_Release(&data);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300554 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300555
556 return return_value;
557}
558
559PyDoc_STRVAR(_codecs_utf_32_ex_decode__doc__,
560"utf_32_ex_decode($module, data, errors=None, byteorder=0, final=False,\n"
561" /)\n"
562"--\n"
563"\n");
564
565#define _CODECS_UTF_32_EX_DECODE_METHODDEF \
566 {"utf_32_ex_decode", (PyCFunction)_codecs_utf_32_ex_decode, METH_VARARGS, _codecs_utf_32_ex_decode__doc__},
567
568static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300569_codecs_utf_32_ex_decode_impl(PyObject *module, Py_buffer *data,
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300570 const char *errors, int byteorder, int final);
571
572static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300573_codecs_utf_32_ex_decode(PyObject *module, PyObject *args)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300574{
575 PyObject *return_value = NULL;
576 Py_buffer data = {NULL, NULL};
577 const char *errors = NULL;
578 int byteorder = 0;
579 int final = 0;
580
581 if (!PyArg_ParseTuple(args, "y*|zii:utf_32_ex_decode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300582 &data, &errors, &byteorder, &final)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300583 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300584 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300585 return_value = _codecs_utf_32_ex_decode_impl(module, &data, errors, byteorder, final);
586
587exit:
588 /* Cleanup for data */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300589 if (data.obj) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300590 PyBuffer_Release(&data);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300591 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300592
593 return return_value;
594}
595
596PyDoc_STRVAR(_codecs_unicode_escape_decode__doc__,
597"unicode_escape_decode($module, data, errors=None, /)\n"
598"--\n"
599"\n");
600
601#define _CODECS_UNICODE_ESCAPE_DECODE_METHODDEF \
602 {"unicode_escape_decode", (PyCFunction)_codecs_unicode_escape_decode, METH_VARARGS, _codecs_unicode_escape_decode__doc__},
603
604static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300605_codecs_unicode_escape_decode_impl(PyObject *module, Py_buffer *data,
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300606 const char *errors);
607
608static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300609_codecs_unicode_escape_decode(PyObject *module, PyObject *args)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300610{
611 PyObject *return_value = NULL;
612 Py_buffer data = {NULL, NULL};
613 const char *errors = NULL;
614
615 if (!PyArg_ParseTuple(args, "s*|z:unicode_escape_decode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300616 &data, &errors)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300617 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300618 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300619 return_value = _codecs_unicode_escape_decode_impl(module, &data, errors);
620
621exit:
622 /* Cleanup for data */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300623 if (data.obj) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300624 PyBuffer_Release(&data);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300625 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300626
627 return return_value;
628}
629
630PyDoc_STRVAR(_codecs_raw_unicode_escape_decode__doc__,
631"raw_unicode_escape_decode($module, data, errors=None, /)\n"
632"--\n"
633"\n");
634
635#define _CODECS_RAW_UNICODE_ESCAPE_DECODE_METHODDEF \
636 {"raw_unicode_escape_decode", (PyCFunction)_codecs_raw_unicode_escape_decode, METH_VARARGS, _codecs_raw_unicode_escape_decode__doc__},
637
638static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300639_codecs_raw_unicode_escape_decode_impl(PyObject *module, Py_buffer *data,
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300640 const char *errors);
641
642static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300643_codecs_raw_unicode_escape_decode(PyObject *module, PyObject *args)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300644{
645 PyObject *return_value = NULL;
646 Py_buffer data = {NULL, NULL};
647 const char *errors = NULL;
648
649 if (!PyArg_ParseTuple(args, "s*|z:raw_unicode_escape_decode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300650 &data, &errors)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300651 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300652 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300653 return_value = _codecs_raw_unicode_escape_decode_impl(module, &data, errors);
654
655exit:
656 /* Cleanup for data */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300657 if (data.obj) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300658 PyBuffer_Release(&data);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300659 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300660
661 return return_value;
662}
663
664PyDoc_STRVAR(_codecs_latin_1_decode__doc__,
665"latin_1_decode($module, data, errors=None, /)\n"
666"--\n"
667"\n");
668
669#define _CODECS_LATIN_1_DECODE_METHODDEF \
670 {"latin_1_decode", (PyCFunction)_codecs_latin_1_decode, METH_VARARGS, _codecs_latin_1_decode__doc__},
671
672static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300673_codecs_latin_1_decode_impl(PyObject *module, Py_buffer *data,
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300674 const char *errors);
675
676static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300677_codecs_latin_1_decode(PyObject *module, PyObject *args)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300678{
679 PyObject *return_value = NULL;
680 Py_buffer data = {NULL, NULL};
681 const char *errors = NULL;
682
683 if (!PyArg_ParseTuple(args, "y*|z:latin_1_decode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300684 &data, &errors)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300685 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300686 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300687 return_value = _codecs_latin_1_decode_impl(module, &data, errors);
688
689exit:
690 /* Cleanup for data */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300691 if (data.obj) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300692 PyBuffer_Release(&data);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300693 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300694
695 return return_value;
696}
697
698PyDoc_STRVAR(_codecs_ascii_decode__doc__,
699"ascii_decode($module, data, errors=None, /)\n"
700"--\n"
701"\n");
702
703#define _CODECS_ASCII_DECODE_METHODDEF \
704 {"ascii_decode", (PyCFunction)_codecs_ascii_decode, METH_VARARGS, _codecs_ascii_decode__doc__},
705
706static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300707_codecs_ascii_decode_impl(PyObject *module, Py_buffer *data,
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300708 const char *errors);
709
710static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300711_codecs_ascii_decode(PyObject *module, PyObject *args)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300712{
713 PyObject *return_value = NULL;
714 Py_buffer data = {NULL, NULL};
715 const char *errors = NULL;
716
717 if (!PyArg_ParseTuple(args, "y*|z:ascii_decode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300718 &data, &errors)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300719 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300720 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300721 return_value = _codecs_ascii_decode_impl(module, &data, errors);
722
723exit:
724 /* Cleanup for data */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300725 if (data.obj) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300726 PyBuffer_Release(&data);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300727 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300728
729 return return_value;
730}
731
732PyDoc_STRVAR(_codecs_charmap_decode__doc__,
733"charmap_decode($module, data, errors=None, mapping=None, /)\n"
734"--\n"
735"\n");
736
737#define _CODECS_CHARMAP_DECODE_METHODDEF \
738 {"charmap_decode", (PyCFunction)_codecs_charmap_decode, METH_VARARGS, _codecs_charmap_decode__doc__},
739
740static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300741_codecs_charmap_decode_impl(PyObject *module, Py_buffer *data,
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300742 const char *errors, PyObject *mapping);
743
744static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300745_codecs_charmap_decode(PyObject *module, PyObject *args)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300746{
747 PyObject *return_value = NULL;
748 Py_buffer data = {NULL, NULL};
749 const char *errors = NULL;
750 PyObject *mapping = NULL;
751
752 if (!PyArg_ParseTuple(args, "y*|zO:charmap_decode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300753 &data, &errors, &mapping)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300754 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300755 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300756 return_value = _codecs_charmap_decode_impl(module, &data, errors, mapping);
757
758exit:
759 /* Cleanup for data */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300760 if (data.obj) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300761 PyBuffer_Release(&data);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300762 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300763
764 return return_value;
765}
766
767#if defined(HAVE_MBCS)
768
769PyDoc_STRVAR(_codecs_mbcs_decode__doc__,
770"mbcs_decode($module, data, errors=None, final=False, /)\n"
771"--\n"
772"\n");
773
774#define _CODECS_MBCS_DECODE_METHODDEF \
775 {"mbcs_decode", (PyCFunction)_codecs_mbcs_decode, METH_VARARGS, _codecs_mbcs_decode__doc__},
776
777static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300778_codecs_mbcs_decode_impl(PyObject *module, Py_buffer *data,
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300779 const char *errors, int final);
780
781static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300782_codecs_mbcs_decode(PyObject *module, PyObject *args)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300783{
784 PyObject *return_value = NULL;
785 Py_buffer data = {NULL, NULL};
786 const char *errors = NULL;
787 int final = 0;
788
789 if (!PyArg_ParseTuple(args, "y*|zi:mbcs_decode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300790 &data, &errors, &final)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300791 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300792 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300793 return_value = _codecs_mbcs_decode_impl(module, &data, errors, final);
794
795exit:
796 /* Cleanup for data */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300797 if (data.obj) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300798 PyBuffer_Release(&data);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300799 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300800
801 return return_value;
802}
803
804#endif /* defined(HAVE_MBCS) */
805
806#if defined(HAVE_MBCS)
807
Steve Dowerf5aba582016-09-06 19:42:27 -0700808PyDoc_STRVAR(_codecs_oem_decode__doc__,
809"oem_decode($module, data, errors=None, final=False, /)\n"
810"--\n"
811"\n");
812
813#define _CODECS_OEM_DECODE_METHODDEF \
814 {"oem_decode", (PyCFunction)_codecs_oem_decode, METH_VARARGS, _codecs_oem_decode__doc__},
815
816static PyObject *
817_codecs_oem_decode_impl(PyObject *module, Py_buffer *data,
818 const char *errors, int final);
819
820static PyObject *
821_codecs_oem_decode(PyObject *module, PyObject *args)
822{
823 PyObject *return_value = NULL;
824 Py_buffer data = {NULL, NULL};
825 const char *errors = NULL;
826 int final = 0;
827
828 if (!PyArg_ParseTuple(args, "y*|zi:oem_decode",
829 &data, &errors, &final)) {
830 goto exit;
831 }
832 return_value = _codecs_oem_decode_impl(module, &data, errors, final);
833
834exit:
835 /* Cleanup for data */
836 if (data.obj) {
837 PyBuffer_Release(&data);
838 }
839
840 return return_value;
841}
842
843#endif /* defined(HAVE_MBCS) */
844
845#if defined(HAVE_MBCS)
846
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300847PyDoc_STRVAR(_codecs_code_page_decode__doc__,
848"code_page_decode($module, codepage, data, errors=None, final=False, /)\n"
849"--\n"
850"\n");
851
852#define _CODECS_CODE_PAGE_DECODE_METHODDEF \
853 {"code_page_decode", (PyCFunction)_codecs_code_page_decode, METH_VARARGS, _codecs_code_page_decode__doc__},
854
855static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300856_codecs_code_page_decode_impl(PyObject *module, int codepage,
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300857 Py_buffer *data, const char *errors, int final);
858
859static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300860_codecs_code_page_decode(PyObject *module, PyObject *args)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300861{
862 PyObject *return_value = NULL;
863 int codepage;
864 Py_buffer data = {NULL, NULL};
865 const char *errors = NULL;
866 int final = 0;
867
868 if (!PyArg_ParseTuple(args, "iy*|zi:code_page_decode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300869 &codepage, &data, &errors, &final)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300870 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300871 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300872 return_value = _codecs_code_page_decode_impl(module, codepage, &data, errors, final);
873
874exit:
875 /* Cleanup for data */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300876 if (data.obj) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300877 PyBuffer_Release(&data);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300878 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300879
880 return return_value;
881}
882
883#endif /* defined(HAVE_MBCS) */
884
885PyDoc_STRVAR(_codecs_readbuffer_encode__doc__,
886"readbuffer_encode($module, data, errors=None, /)\n"
887"--\n"
888"\n");
889
890#define _CODECS_READBUFFER_ENCODE_METHODDEF \
891 {"readbuffer_encode", (PyCFunction)_codecs_readbuffer_encode, METH_VARARGS, _codecs_readbuffer_encode__doc__},
892
893static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300894_codecs_readbuffer_encode_impl(PyObject *module, Py_buffer *data,
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300895 const char *errors);
896
897static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300898_codecs_readbuffer_encode(PyObject *module, PyObject *args)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300899{
900 PyObject *return_value = NULL;
901 Py_buffer data = {NULL, NULL};
902 const char *errors = NULL;
903
904 if (!PyArg_ParseTuple(args, "s*|z:readbuffer_encode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300905 &data, &errors)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300906 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300907 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300908 return_value = _codecs_readbuffer_encode_impl(module, &data, errors);
909
910exit:
911 /* Cleanup for data */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300912 if (data.obj) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300913 PyBuffer_Release(&data);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300914 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300915
916 return return_value;
917}
918
919PyDoc_STRVAR(_codecs_unicode_internal_encode__doc__,
920"unicode_internal_encode($module, obj, errors=None, /)\n"
921"--\n"
922"\n");
923
924#define _CODECS_UNICODE_INTERNAL_ENCODE_METHODDEF \
925 {"unicode_internal_encode", (PyCFunction)_codecs_unicode_internal_encode, METH_VARARGS, _codecs_unicode_internal_encode__doc__},
926
927static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300928_codecs_unicode_internal_encode_impl(PyObject *module, PyObject *obj,
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300929 const char *errors);
930
931static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300932_codecs_unicode_internal_encode(PyObject *module, PyObject *args)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300933{
934 PyObject *return_value = NULL;
935 PyObject *obj;
936 const char *errors = NULL;
937
938 if (!PyArg_ParseTuple(args, "O|z:unicode_internal_encode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300939 &obj, &errors)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300940 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300941 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300942 return_value = _codecs_unicode_internal_encode_impl(module, obj, errors);
943
944exit:
945 return return_value;
946}
947
948PyDoc_STRVAR(_codecs_utf_7_encode__doc__,
949"utf_7_encode($module, str, errors=None, /)\n"
950"--\n"
951"\n");
952
953#define _CODECS_UTF_7_ENCODE_METHODDEF \
954 {"utf_7_encode", (PyCFunction)_codecs_utf_7_encode, METH_VARARGS, _codecs_utf_7_encode__doc__},
955
956static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300957_codecs_utf_7_encode_impl(PyObject *module, PyObject *str,
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300958 const char *errors);
959
960static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300961_codecs_utf_7_encode(PyObject *module, PyObject *args)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300962{
963 PyObject *return_value = NULL;
964 PyObject *str;
965 const char *errors = NULL;
966
Serhiy Storchaka2eb6b0d2016-04-14 12:30:54 +0300967 if (!PyArg_ParseTuple(args, "U|z:utf_7_encode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300968 &str, &errors)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300969 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300970 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300971 return_value = _codecs_utf_7_encode_impl(module, str, errors);
972
973exit:
974 return return_value;
975}
976
977PyDoc_STRVAR(_codecs_utf_8_encode__doc__,
978"utf_8_encode($module, str, errors=None, /)\n"
979"--\n"
980"\n");
981
982#define _CODECS_UTF_8_ENCODE_METHODDEF \
983 {"utf_8_encode", (PyCFunction)_codecs_utf_8_encode, METH_VARARGS, _codecs_utf_8_encode__doc__},
984
985static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300986_codecs_utf_8_encode_impl(PyObject *module, PyObject *str,
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300987 const char *errors);
988
989static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300990_codecs_utf_8_encode(PyObject *module, PyObject *args)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300991{
992 PyObject *return_value = NULL;
993 PyObject *str;
994 const char *errors = NULL;
995
Serhiy Storchaka2eb6b0d2016-04-14 12:30:54 +0300996 if (!PyArg_ParseTuple(args, "U|z:utf_8_encode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300997 &str, &errors)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +0300998 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300999 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001000 return_value = _codecs_utf_8_encode_impl(module, str, errors);
1001
1002exit:
1003 return return_value;
1004}
1005
1006PyDoc_STRVAR(_codecs_utf_16_encode__doc__,
1007"utf_16_encode($module, str, errors=None, byteorder=0, /)\n"
1008"--\n"
1009"\n");
1010
1011#define _CODECS_UTF_16_ENCODE_METHODDEF \
1012 {"utf_16_encode", (PyCFunction)_codecs_utf_16_encode, METH_VARARGS, _codecs_utf_16_encode__doc__},
1013
1014static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +03001015_codecs_utf_16_encode_impl(PyObject *module, PyObject *str,
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001016 const char *errors, int byteorder);
1017
1018static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +03001019_codecs_utf_16_encode(PyObject *module, PyObject *args)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001020{
1021 PyObject *return_value = NULL;
1022 PyObject *str;
1023 const char *errors = NULL;
1024 int byteorder = 0;
1025
Serhiy Storchaka2eb6b0d2016-04-14 12:30:54 +03001026 if (!PyArg_ParseTuple(args, "U|zi:utf_16_encode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +03001027 &str, &errors, &byteorder)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001028 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +03001029 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001030 return_value = _codecs_utf_16_encode_impl(module, str, errors, byteorder);
1031
1032exit:
1033 return return_value;
1034}
1035
1036PyDoc_STRVAR(_codecs_utf_16_le_encode__doc__,
1037"utf_16_le_encode($module, str, errors=None, /)\n"
1038"--\n"
1039"\n");
1040
1041#define _CODECS_UTF_16_LE_ENCODE_METHODDEF \
1042 {"utf_16_le_encode", (PyCFunction)_codecs_utf_16_le_encode, METH_VARARGS, _codecs_utf_16_le_encode__doc__},
1043
1044static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +03001045_codecs_utf_16_le_encode_impl(PyObject *module, PyObject *str,
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001046 const char *errors);
1047
1048static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +03001049_codecs_utf_16_le_encode(PyObject *module, PyObject *args)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001050{
1051 PyObject *return_value = NULL;
1052 PyObject *str;
1053 const char *errors = NULL;
1054
Serhiy Storchaka2eb6b0d2016-04-14 12:30:54 +03001055 if (!PyArg_ParseTuple(args, "U|z:utf_16_le_encode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +03001056 &str, &errors)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001057 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +03001058 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001059 return_value = _codecs_utf_16_le_encode_impl(module, str, errors);
1060
1061exit:
1062 return return_value;
1063}
1064
1065PyDoc_STRVAR(_codecs_utf_16_be_encode__doc__,
1066"utf_16_be_encode($module, str, errors=None, /)\n"
1067"--\n"
1068"\n");
1069
1070#define _CODECS_UTF_16_BE_ENCODE_METHODDEF \
1071 {"utf_16_be_encode", (PyCFunction)_codecs_utf_16_be_encode, METH_VARARGS, _codecs_utf_16_be_encode__doc__},
1072
1073static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +03001074_codecs_utf_16_be_encode_impl(PyObject *module, PyObject *str,
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001075 const char *errors);
1076
1077static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +03001078_codecs_utf_16_be_encode(PyObject *module, PyObject *args)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001079{
1080 PyObject *return_value = NULL;
1081 PyObject *str;
1082 const char *errors = NULL;
1083
Serhiy Storchaka2eb6b0d2016-04-14 12:30:54 +03001084 if (!PyArg_ParseTuple(args, "U|z:utf_16_be_encode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +03001085 &str, &errors)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001086 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +03001087 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001088 return_value = _codecs_utf_16_be_encode_impl(module, str, errors);
1089
1090exit:
1091 return return_value;
1092}
1093
1094PyDoc_STRVAR(_codecs_utf_32_encode__doc__,
1095"utf_32_encode($module, str, errors=None, byteorder=0, /)\n"
1096"--\n"
1097"\n");
1098
1099#define _CODECS_UTF_32_ENCODE_METHODDEF \
1100 {"utf_32_encode", (PyCFunction)_codecs_utf_32_encode, METH_VARARGS, _codecs_utf_32_encode__doc__},
1101
1102static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +03001103_codecs_utf_32_encode_impl(PyObject *module, PyObject *str,
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001104 const char *errors, int byteorder);
1105
1106static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +03001107_codecs_utf_32_encode(PyObject *module, PyObject *args)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001108{
1109 PyObject *return_value = NULL;
1110 PyObject *str;
1111 const char *errors = NULL;
1112 int byteorder = 0;
1113
Serhiy Storchaka2eb6b0d2016-04-14 12:30:54 +03001114 if (!PyArg_ParseTuple(args, "U|zi:utf_32_encode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +03001115 &str, &errors, &byteorder)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001116 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +03001117 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001118 return_value = _codecs_utf_32_encode_impl(module, str, errors, byteorder);
1119
1120exit:
1121 return return_value;
1122}
1123
1124PyDoc_STRVAR(_codecs_utf_32_le_encode__doc__,
1125"utf_32_le_encode($module, str, errors=None, /)\n"
1126"--\n"
1127"\n");
1128
1129#define _CODECS_UTF_32_LE_ENCODE_METHODDEF \
1130 {"utf_32_le_encode", (PyCFunction)_codecs_utf_32_le_encode, METH_VARARGS, _codecs_utf_32_le_encode__doc__},
1131
1132static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +03001133_codecs_utf_32_le_encode_impl(PyObject *module, PyObject *str,
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001134 const char *errors);
1135
1136static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +03001137_codecs_utf_32_le_encode(PyObject *module, PyObject *args)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001138{
1139 PyObject *return_value = NULL;
1140 PyObject *str;
1141 const char *errors = NULL;
1142
Serhiy Storchaka2eb6b0d2016-04-14 12:30:54 +03001143 if (!PyArg_ParseTuple(args, "U|z:utf_32_le_encode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +03001144 &str, &errors)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001145 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +03001146 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001147 return_value = _codecs_utf_32_le_encode_impl(module, str, errors);
1148
1149exit:
1150 return return_value;
1151}
1152
1153PyDoc_STRVAR(_codecs_utf_32_be_encode__doc__,
1154"utf_32_be_encode($module, str, errors=None, /)\n"
1155"--\n"
1156"\n");
1157
1158#define _CODECS_UTF_32_BE_ENCODE_METHODDEF \
1159 {"utf_32_be_encode", (PyCFunction)_codecs_utf_32_be_encode, METH_VARARGS, _codecs_utf_32_be_encode__doc__},
1160
1161static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +03001162_codecs_utf_32_be_encode_impl(PyObject *module, PyObject *str,
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001163 const char *errors);
1164
1165static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +03001166_codecs_utf_32_be_encode(PyObject *module, PyObject *args)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001167{
1168 PyObject *return_value = NULL;
1169 PyObject *str;
1170 const char *errors = NULL;
1171
Serhiy Storchaka2eb6b0d2016-04-14 12:30:54 +03001172 if (!PyArg_ParseTuple(args, "U|z:utf_32_be_encode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +03001173 &str, &errors)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001174 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +03001175 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001176 return_value = _codecs_utf_32_be_encode_impl(module, str, errors);
1177
1178exit:
1179 return return_value;
1180}
1181
1182PyDoc_STRVAR(_codecs_unicode_escape_encode__doc__,
1183"unicode_escape_encode($module, str, errors=None, /)\n"
1184"--\n"
1185"\n");
1186
1187#define _CODECS_UNICODE_ESCAPE_ENCODE_METHODDEF \
1188 {"unicode_escape_encode", (PyCFunction)_codecs_unicode_escape_encode, METH_VARARGS, _codecs_unicode_escape_encode__doc__},
1189
1190static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +03001191_codecs_unicode_escape_encode_impl(PyObject *module, PyObject *str,
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001192 const char *errors);
1193
1194static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +03001195_codecs_unicode_escape_encode(PyObject *module, PyObject *args)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001196{
1197 PyObject *return_value = NULL;
1198 PyObject *str;
1199 const char *errors = NULL;
1200
Serhiy Storchaka2eb6b0d2016-04-14 12:30:54 +03001201 if (!PyArg_ParseTuple(args, "U|z:unicode_escape_encode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +03001202 &str, &errors)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001203 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +03001204 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001205 return_value = _codecs_unicode_escape_encode_impl(module, str, errors);
1206
1207exit:
1208 return return_value;
1209}
1210
1211PyDoc_STRVAR(_codecs_raw_unicode_escape_encode__doc__,
1212"raw_unicode_escape_encode($module, str, errors=None, /)\n"
1213"--\n"
1214"\n");
1215
1216#define _CODECS_RAW_UNICODE_ESCAPE_ENCODE_METHODDEF \
1217 {"raw_unicode_escape_encode", (PyCFunction)_codecs_raw_unicode_escape_encode, METH_VARARGS, _codecs_raw_unicode_escape_encode__doc__},
1218
1219static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +03001220_codecs_raw_unicode_escape_encode_impl(PyObject *module, PyObject *str,
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001221 const char *errors);
1222
1223static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +03001224_codecs_raw_unicode_escape_encode(PyObject *module, PyObject *args)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001225{
1226 PyObject *return_value = NULL;
1227 PyObject *str;
1228 const char *errors = NULL;
1229
Serhiy Storchaka2eb6b0d2016-04-14 12:30:54 +03001230 if (!PyArg_ParseTuple(args, "U|z:raw_unicode_escape_encode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +03001231 &str, &errors)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001232 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +03001233 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001234 return_value = _codecs_raw_unicode_escape_encode_impl(module, str, errors);
1235
1236exit:
1237 return return_value;
1238}
1239
1240PyDoc_STRVAR(_codecs_latin_1_encode__doc__,
1241"latin_1_encode($module, str, errors=None, /)\n"
1242"--\n"
1243"\n");
1244
1245#define _CODECS_LATIN_1_ENCODE_METHODDEF \
1246 {"latin_1_encode", (PyCFunction)_codecs_latin_1_encode, METH_VARARGS, _codecs_latin_1_encode__doc__},
1247
1248static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +03001249_codecs_latin_1_encode_impl(PyObject *module, PyObject *str,
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001250 const char *errors);
1251
1252static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +03001253_codecs_latin_1_encode(PyObject *module, PyObject *args)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001254{
1255 PyObject *return_value = NULL;
1256 PyObject *str;
1257 const char *errors = NULL;
1258
Serhiy Storchaka2eb6b0d2016-04-14 12:30:54 +03001259 if (!PyArg_ParseTuple(args, "U|z:latin_1_encode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +03001260 &str, &errors)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001261 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +03001262 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001263 return_value = _codecs_latin_1_encode_impl(module, str, errors);
1264
1265exit:
1266 return return_value;
1267}
1268
1269PyDoc_STRVAR(_codecs_ascii_encode__doc__,
1270"ascii_encode($module, str, errors=None, /)\n"
1271"--\n"
1272"\n");
1273
1274#define _CODECS_ASCII_ENCODE_METHODDEF \
1275 {"ascii_encode", (PyCFunction)_codecs_ascii_encode, METH_VARARGS, _codecs_ascii_encode__doc__},
1276
1277static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +03001278_codecs_ascii_encode_impl(PyObject *module, PyObject *str,
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001279 const char *errors);
1280
1281static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +03001282_codecs_ascii_encode(PyObject *module, PyObject *args)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001283{
1284 PyObject *return_value = NULL;
1285 PyObject *str;
1286 const char *errors = NULL;
1287
Serhiy Storchaka2eb6b0d2016-04-14 12:30:54 +03001288 if (!PyArg_ParseTuple(args, "U|z:ascii_encode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +03001289 &str, &errors)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001290 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +03001291 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001292 return_value = _codecs_ascii_encode_impl(module, str, errors);
1293
1294exit:
1295 return return_value;
1296}
1297
1298PyDoc_STRVAR(_codecs_charmap_encode__doc__,
1299"charmap_encode($module, str, errors=None, mapping=None, /)\n"
1300"--\n"
1301"\n");
1302
1303#define _CODECS_CHARMAP_ENCODE_METHODDEF \
1304 {"charmap_encode", (PyCFunction)_codecs_charmap_encode, METH_VARARGS, _codecs_charmap_encode__doc__},
1305
1306static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +03001307_codecs_charmap_encode_impl(PyObject *module, PyObject *str,
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001308 const char *errors, PyObject *mapping);
1309
1310static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +03001311_codecs_charmap_encode(PyObject *module, PyObject *args)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001312{
1313 PyObject *return_value = NULL;
1314 PyObject *str;
1315 const char *errors = NULL;
1316 PyObject *mapping = NULL;
1317
Serhiy Storchaka2eb6b0d2016-04-14 12:30:54 +03001318 if (!PyArg_ParseTuple(args, "U|zO:charmap_encode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +03001319 &str, &errors, &mapping)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001320 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +03001321 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001322 return_value = _codecs_charmap_encode_impl(module, str, errors, mapping);
1323
1324exit:
1325 return return_value;
1326}
1327
1328PyDoc_STRVAR(_codecs_charmap_build__doc__,
1329"charmap_build($module, map, /)\n"
1330"--\n"
1331"\n");
1332
1333#define _CODECS_CHARMAP_BUILD_METHODDEF \
1334 {"charmap_build", (PyCFunction)_codecs_charmap_build, METH_O, _codecs_charmap_build__doc__},
1335
1336static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +03001337_codecs_charmap_build_impl(PyObject *module, PyObject *map);
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001338
1339static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +03001340_codecs_charmap_build(PyObject *module, PyObject *arg)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001341{
1342 PyObject *return_value = NULL;
1343 PyObject *map;
1344
Serhiy Storchaka5dee6552016-06-09 16:16:06 +03001345 if (!PyArg_Parse(arg, "U:charmap_build", &map)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001346 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +03001347 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001348 return_value = _codecs_charmap_build_impl(module, map);
1349
1350exit:
1351 return return_value;
1352}
1353
1354#if defined(HAVE_MBCS)
1355
1356PyDoc_STRVAR(_codecs_mbcs_encode__doc__,
1357"mbcs_encode($module, str, errors=None, /)\n"
1358"--\n"
1359"\n");
1360
1361#define _CODECS_MBCS_ENCODE_METHODDEF \
1362 {"mbcs_encode", (PyCFunction)_codecs_mbcs_encode, METH_VARARGS, _codecs_mbcs_encode__doc__},
1363
1364static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +03001365_codecs_mbcs_encode_impl(PyObject *module, PyObject *str, const char *errors);
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001366
1367static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +03001368_codecs_mbcs_encode(PyObject *module, PyObject *args)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001369{
1370 PyObject *return_value = NULL;
1371 PyObject *str;
1372 const char *errors = NULL;
1373
Serhiy Storchaka2eb6b0d2016-04-14 12:30:54 +03001374 if (!PyArg_ParseTuple(args, "U|z:mbcs_encode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +03001375 &str, &errors)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001376 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +03001377 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001378 return_value = _codecs_mbcs_encode_impl(module, str, errors);
1379
1380exit:
1381 return return_value;
1382}
1383
1384#endif /* defined(HAVE_MBCS) */
1385
1386#if defined(HAVE_MBCS)
1387
Steve Dowerf5aba582016-09-06 19:42:27 -07001388PyDoc_STRVAR(_codecs_oem_encode__doc__,
1389"oem_encode($module, str, errors=None, /)\n"
1390"--\n"
1391"\n");
1392
1393#define _CODECS_OEM_ENCODE_METHODDEF \
1394 {"oem_encode", (PyCFunction)_codecs_oem_encode, METH_VARARGS, _codecs_oem_encode__doc__},
1395
1396static PyObject *
1397_codecs_oem_encode_impl(PyObject *module, PyObject *str, const char *errors);
1398
1399static PyObject *
1400_codecs_oem_encode(PyObject *module, PyObject *args)
1401{
1402 PyObject *return_value = NULL;
1403 PyObject *str;
1404 const char *errors = NULL;
1405
1406 if (!PyArg_ParseTuple(args, "U|z:oem_encode",
1407 &str, &errors)) {
1408 goto exit;
1409 }
1410 return_value = _codecs_oem_encode_impl(module, str, errors);
1411
1412exit:
1413 return return_value;
1414}
1415
1416#endif /* defined(HAVE_MBCS) */
1417
1418#if defined(HAVE_MBCS)
1419
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001420PyDoc_STRVAR(_codecs_code_page_encode__doc__,
1421"code_page_encode($module, code_page, str, errors=None, /)\n"
1422"--\n"
1423"\n");
1424
1425#define _CODECS_CODE_PAGE_ENCODE_METHODDEF \
1426 {"code_page_encode", (PyCFunction)_codecs_code_page_encode, METH_VARARGS, _codecs_code_page_encode__doc__},
1427
1428static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +03001429_codecs_code_page_encode_impl(PyObject *module, int code_page, PyObject *str,
1430 const char *errors);
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001431
1432static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +03001433_codecs_code_page_encode(PyObject *module, PyObject *args)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001434{
1435 PyObject *return_value = NULL;
1436 int code_page;
1437 PyObject *str;
1438 const char *errors = NULL;
1439
Serhiy Storchaka2eb6b0d2016-04-14 12:30:54 +03001440 if (!PyArg_ParseTuple(args, "iU|z:code_page_encode",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +03001441 &code_page, &str, &errors)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001442 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +03001443 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001444 return_value = _codecs_code_page_encode_impl(module, code_page, str, errors);
1445
1446exit:
1447 return return_value;
1448}
1449
1450#endif /* defined(HAVE_MBCS) */
1451
1452PyDoc_STRVAR(_codecs_register_error__doc__,
1453"register_error($module, errors, handler, /)\n"
1454"--\n"
1455"\n"
1456"Register the specified error handler under the name errors.\n"
1457"\n"
1458"handler must be a callable object, that will be called with an exception\n"
1459"instance containing information about the location of the encoding/decoding\n"
1460"error and must return a (replacement, new position) tuple.");
1461
1462#define _CODECS_REGISTER_ERROR_METHODDEF \
1463 {"register_error", (PyCFunction)_codecs_register_error, METH_VARARGS, _codecs_register_error__doc__},
1464
1465static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +03001466_codecs_register_error_impl(PyObject *module, const char *errors,
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001467 PyObject *handler);
1468
1469static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +03001470_codecs_register_error(PyObject *module, PyObject *args)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001471{
1472 PyObject *return_value = NULL;
1473 const char *errors;
1474 PyObject *handler;
1475
1476 if (!PyArg_ParseTuple(args, "sO:register_error",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +03001477 &errors, &handler)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001478 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +03001479 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001480 return_value = _codecs_register_error_impl(module, errors, handler);
1481
1482exit:
1483 return return_value;
1484}
1485
1486PyDoc_STRVAR(_codecs_lookup_error__doc__,
1487"lookup_error($module, name, /)\n"
1488"--\n"
1489"\n"
1490"lookup_error(errors) -> handler\n"
1491"\n"
1492"Return the error handler for the specified error handling name or raise a\n"
1493"LookupError, if no handler exists under this name.");
1494
1495#define _CODECS_LOOKUP_ERROR_METHODDEF \
1496 {"lookup_error", (PyCFunction)_codecs_lookup_error, METH_O, _codecs_lookup_error__doc__},
1497
1498static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +03001499_codecs_lookup_error_impl(PyObject *module, const char *name);
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001500
1501static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +03001502_codecs_lookup_error(PyObject *module, PyObject *arg)
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001503{
1504 PyObject *return_value = NULL;
1505 const char *name;
1506
Serhiy Storchaka5dee6552016-06-09 16:16:06 +03001507 if (!PyArg_Parse(arg, "s:lookup_error", &name)) {
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001508 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +03001509 }
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001510 return_value = _codecs_lookup_error_impl(module, name);
1511
1512exit:
1513 return return_value;
1514}
1515
1516#ifndef _CODECS_MBCS_DECODE_METHODDEF
1517 #define _CODECS_MBCS_DECODE_METHODDEF
1518#endif /* !defined(_CODECS_MBCS_DECODE_METHODDEF) */
1519
Steve Dowerf5aba582016-09-06 19:42:27 -07001520#ifndef _CODECS_OEM_DECODE_METHODDEF
1521 #define _CODECS_OEM_DECODE_METHODDEF
1522#endif /* !defined(_CODECS_OEM_DECODE_METHODDEF) */
1523
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001524#ifndef _CODECS_CODE_PAGE_DECODE_METHODDEF
1525 #define _CODECS_CODE_PAGE_DECODE_METHODDEF
1526#endif /* !defined(_CODECS_CODE_PAGE_DECODE_METHODDEF) */
1527
1528#ifndef _CODECS_MBCS_ENCODE_METHODDEF
1529 #define _CODECS_MBCS_ENCODE_METHODDEF
1530#endif /* !defined(_CODECS_MBCS_ENCODE_METHODDEF) */
1531
Steve Dowerf5aba582016-09-06 19:42:27 -07001532#ifndef _CODECS_OEM_ENCODE_METHODDEF
1533 #define _CODECS_OEM_ENCODE_METHODDEF
1534#endif /* !defined(_CODECS_OEM_ENCODE_METHODDEF) */
1535
Serhiy Storchaka0c59ff62015-05-12 13:15:57 +03001536#ifndef _CODECS_CODE_PAGE_ENCODE_METHODDEF
1537 #define _CODECS_CODE_PAGE_ENCODE_METHODDEF
1538#endif /* !defined(_CODECS_CODE_PAGE_ENCODE_METHODDEF) */
Steve Dowerf5aba582016-09-06 19:42:27 -07001539/*[clinic end generated code: output=7874e2d559d49368 input=a9049054013a1b77]*/