1 /* ------------------------------------------------------------------------
3 _codecs -- Provides access to the codec registry and the builtin
6 This module should never be imported directly. The standard library
7 module "codecs" wraps this builtin module for use within Python.
9 The codec registry is accessible via:
11 register(search_function) -> None
13 lookup(encoding) -> CodecInfo object
15 The builtin Unicode codecs use the following interface:
17 <encoding>_encode(Unicode_object[,errors='strict']) ->
18 (string object, bytes consumed)
20 <encoding>_decode(char_buffer_obj[,errors='strict']) ->
21 (Unicode object, bytes consumed)
23 <encoding>_encode() interfaces also accept non-Unicode object as
24 input. The objects are then converted to Unicode using
25 PyUnicode_FromObject() prior to applying the conversion.
27 These <encoding>s are available: utf_8, unicode_escape,
28 raw_unicode_escape, unicode_internal, latin_1, ascii (7-bit),
32 Written by Marc-Andre Lemburg (mal@lemburg.com).
34 Copyright (c) Corporation for National Research Initiatives.
36 ------------------------------------------------------------------------ */
38 #define PY_SSIZE_T_CLEAN
41 /* --- Registry ----------------------------------------------------------- */
43 PyDoc_STRVAR(register__doc__
,
44 "register(search_function)\n\
46 Register a codec search function. Search functions are expected to take\n\
47 one argument, the encoding name in all lower case letters, and return\n\
48 a tuple of functions (encoder, decoder, stream_reader, stream_writer)\n\
49 (or a CodecInfo object).");
52 PyObject
*codec_register(PyObject
*self
, PyObject
*search_function
)
54 if (PyCodec_Register(search_function
))
60 PyDoc_STRVAR(lookup__doc__
,
61 "lookup(encoding) -> CodecInfo\n\
63 Looks up a codec tuple in the Python codec registry and returns\n\
64 a tuple of function (or a CodecInfo object).");
67 PyObject
*codec_lookup(PyObject
*self
, PyObject
*args
)
71 if (!PyArg_ParseTuple(args
, "s:lookup", &encoding
))
74 return _PyCodec_Lookup(encoding
);
77 PyDoc_STRVAR(encode__doc__
,
78 "encode(obj, [encoding[,errors]]) -> object\n\
80 Encodes obj using the codec registered for encoding. encoding defaults\n\
81 to the default encoding. errors may be given to set a different error\n\
82 handling scheme. Default is 'strict' meaning that encoding errors raise\n\
83 a ValueError. Other possible values are 'ignore', 'replace' and\n\
84 'xmlcharrefreplace' as well as any other name registered with\n\
85 codecs.register_error that can handle ValueErrors.");
88 codec_encode(PyObject
*self
, PyObject
*args
)
90 const char *encoding
= NULL
;
91 const char *errors
= NULL
;
94 if (!PyArg_ParseTuple(args
, "O|ss:encode", &v
, &encoding
, &errors
))
97 #ifdef Py_USING_UNICODE
99 encoding
= PyUnicode_GetDefaultEncoding();
101 if (encoding
== NULL
) {
102 PyErr_SetString(PyExc_ValueError
, "no encoding specified");
107 /* Encode via the codec registry */
108 return PyCodec_Encode(v
, encoding
, errors
);
111 PyDoc_STRVAR(decode__doc__
,
112 "decode(obj, [encoding[,errors]]) -> object\n\
114 Decodes obj using the codec registered for encoding. encoding defaults\n\
115 to the default encoding. errors may be given to set a different error\n\
116 handling scheme. Default is 'strict' meaning that encoding errors raise\n\
117 a ValueError. Other possible values are 'ignore' and 'replace'\n\
118 as well as any other name registered with codecs.register_error that is\n\
119 able to handle ValueErrors.");
122 codec_decode(PyObject
*self
, PyObject
*args
)
124 const char *encoding
= NULL
;
125 const char *errors
= NULL
;
128 if (!PyArg_ParseTuple(args
, "O|ss:decode", &v
, &encoding
, &errors
))
131 #ifdef Py_USING_UNICODE
132 if (encoding
== NULL
)
133 encoding
= PyUnicode_GetDefaultEncoding();
135 if (encoding
== NULL
) {
136 PyErr_SetString(PyExc_ValueError
, "no encoding specified");
141 /* Decode via the codec registry */
142 return PyCodec_Decode(v
, encoding
, errors
);
145 /* --- Helpers ------------------------------------------------------------ */
148 PyObject
*codec_tuple(PyObject
*unicode
,
154 v
= Py_BuildValue("On", unicode
, len
);
159 /* --- String codecs ------------------------------------------------------ */
161 escape_decode(PyObject
*self
,
164 const char *errors
= NULL
;
168 if (!PyArg_ParseTuple(args
, "s#|z:escape_decode",
169 &data
, &size
, &errors
))
171 return codec_tuple(PyString_DecodeEscape(data
, size
, errors
, 0, NULL
),
176 escape_encode(PyObject
*self
,
180 const char *errors
= NULL
;
184 if (!PyArg_ParseTuple(args
, "O!|z:escape_encode",
185 &PyString_Type
, &str
, &errors
))
188 str
= PyString_Repr(str
, 0);
192 /* The string will be quoted. Unquote, similar to unicode-escape. */
193 buf
= PyString_AS_STRING (str
);
194 len
= PyString_GET_SIZE (str
);
195 memmove(buf
, buf
+1, len
-2);
196 if (_PyString_Resize(&str
, len
-2) < 0)
199 return codec_tuple(str
, PyString_Size(str
));
202 #ifdef Py_USING_UNICODE
203 /* --- Decoder ------------------------------------------------------------ */
206 unicode_internal_decode(PyObject
*self
,
210 const char *errors
= NULL
;
214 if (!PyArg_ParseTuple(args
, "O|z:unicode_internal_decode",
218 if (PyUnicode_Check(obj
)) {
220 return codec_tuple(obj
, PyUnicode_GET_SIZE(obj
));
223 if (PyObject_AsReadBuffer(obj
, (const void **)&data
, &size
))
226 return codec_tuple(_PyUnicode_DecodeUnicodeInternal(data
, size
, errors
),
232 utf_7_decode(PyObject
*self
,
236 const char *errors
= NULL
;
239 PyObject
*decoded
= NULL
;
241 if (!PyArg_ParseTuple(args
, "s*|zi:utf_7_decode",
242 &pbuf
, &errors
, &final
))
246 decoded
= PyUnicode_DecodeUTF7Stateful(pbuf
.buf
, pbuf
.len
, errors
,
247 final
? NULL
: &consumed
);
248 PyBuffer_Release(&pbuf
);
251 return codec_tuple(decoded
, consumed
);
255 utf_8_decode(PyObject
*self
,
259 const char *errors
= NULL
;
262 PyObject
*decoded
= NULL
;
264 if (!PyArg_ParseTuple(args
, "s*|zi:utf_8_decode",
265 &pbuf
, &errors
, &final
))
269 decoded
= PyUnicode_DecodeUTF8Stateful(pbuf
.buf
, pbuf
.len
, errors
,
270 final
? NULL
: &consumed
);
271 PyBuffer_Release(&pbuf
);
274 return codec_tuple(decoded
, consumed
);
278 utf_16_decode(PyObject
*self
,
282 const char *errors
= NULL
;
288 if (!PyArg_ParseTuple(args
, "s*|zi:utf_16_decode",
289 &pbuf
, &errors
, &final
))
291 consumed
= pbuf
.len
; /* This is overwritten unless final is true. */
292 decoded
= PyUnicode_DecodeUTF16Stateful(pbuf
.buf
, pbuf
.len
, errors
,
293 &byteorder
, final
? NULL
: &consumed
);
294 PyBuffer_Release(&pbuf
);
297 return codec_tuple(decoded
, consumed
);
301 utf_16_le_decode(PyObject
*self
,
305 const char *errors
= NULL
;
309 PyObject
*decoded
= NULL
;
311 if (!PyArg_ParseTuple(args
, "s*|zi:utf_16_le_decode",
312 &pbuf
, &errors
, &final
))
315 consumed
= pbuf
.len
; /* This is overwritten unless final is true. */
316 decoded
= PyUnicode_DecodeUTF16Stateful(pbuf
.buf
, pbuf
.len
, errors
,
317 &byteorder
, final
? NULL
: &consumed
);
318 PyBuffer_Release(&pbuf
);
321 return codec_tuple(decoded
, consumed
);
325 utf_16_be_decode(PyObject
*self
,
329 const char *errors
= NULL
;
333 PyObject
*decoded
= NULL
;
335 if (!PyArg_ParseTuple(args
, "s*|zi:utf_16_be_decode",
336 &pbuf
, &errors
, &final
))
339 consumed
= pbuf
.len
; /* This is overwritten unless final is true. */
340 decoded
= PyUnicode_DecodeUTF16Stateful(pbuf
.buf
, pbuf
.len
, errors
,
341 &byteorder
, final
? NULL
: &consumed
);
342 PyBuffer_Release(&pbuf
);
345 return codec_tuple(decoded
, consumed
);
348 /* This non-standard version also provides access to the byteorder
349 parameter of the builtin UTF-16 codec.
351 It returns a tuple (unicode, bytesread, byteorder) with byteorder
352 being the value in effect at the end of data.
357 utf_16_ex_decode(PyObject
*self
,
361 const char *errors
= NULL
;
363 PyObject
*unicode
, *tuple
;
367 if (!PyArg_ParseTuple(args
, "s*|zii:utf_16_ex_decode",
368 &pbuf
, &errors
, &byteorder
, &final
))
370 consumed
= pbuf
.len
; /* This is overwritten unless final is true. */
371 unicode
= PyUnicode_DecodeUTF16Stateful(pbuf
.buf
, pbuf
.len
, errors
,
372 &byteorder
, final
? NULL
: &consumed
);
373 PyBuffer_Release(&pbuf
);
376 tuple
= Py_BuildValue("Oni", unicode
, consumed
, byteorder
);
382 utf_32_decode(PyObject
*self
,
386 const char *errors
= NULL
;
392 if (!PyArg_ParseTuple(args
, "s*|zi:utf_32_decode",
393 &pbuf
, &errors
, &final
))
395 consumed
= pbuf
.len
; /* This is overwritten unless final is true. */
396 decoded
= PyUnicode_DecodeUTF32Stateful(pbuf
.buf
, pbuf
.len
, errors
,
397 &byteorder
, final
? NULL
: &consumed
);
398 PyBuffer_Release(&pbuf
);
401 return codec_tuple(decoded
, consumed
);
405 utf_32_le_decode(PyObject
*self
,
409 const char *errors
= NULL
;
415 if (!PyArg_ParseTuple(args
, "s*|zi:utf_32_le_decode",
416 &pbuf
, &errors
, &final
))
418 consumed
= pbuf
.len
; /* This is overwritten unless final is true. */
419 decoded
= PyUnicode_DecodeUTF32Stateful(pbuf
.buf
, pbuf
.len
, errors
,
420 &byteorder
, final
? NULL
: &consumed
);
421 PyBuffer_Release(&pbuf
);
424 return codec_tuple(decoded
, consumed
);
428 utf_32_be_decode(PyObject
*self
,
432 const char *errors
= NULL
;
438 if (!PyArg_ParseTuple(args
, "s*|zi:utf_32_be_decode",
439 &pbuf
, &errors
, &final
))
441 consumed
= pbuf
.len
; /* This is overwritten unless final is true. */
442 decoded
= PyUnicode_DecodeUTF32Stateful(pbuf
.buf
, pbuf
.len
, errors
,
443 &byteorder
, final
? NULL
: &consumed
);
444 PyBuffer_Release(&pbuf
);
447 return codec_tuple(decoded
, consumed
);
450 /* This non-standard version also provides access to the byteorder
451 parameter of the builtin UTF-32 codec.
453 It returns a tuple (unicode, bytesread, byteorder) with byteorder
454 being the value in effect at the end of data.
459 utf_32_ex_decode(PyObject
*self
,
463 const char *errors
= NULL
;
465 PyObject
*unicode
, *tuple
;
469 if (!PyArg_ParseTuple(args
, "s*|zii:utf_32_ex_decode",
470 &pbuf
, &errors
, &byteorder
, &final
))
472 consumed
= pbuf
.len
; /* This is overwritten unless final is true. */
473 unicode
= PyUnicode_DecodeUTF32Stateful(pbuf
.buf
, pbuf
.len
, errors
,
474 &byteorder
, final
? NULL
: &consumed
);
475 PyBuffer_Release(&pbuf
);
478 tuple
= Py_BuildValue("Oni", unicode
, consumed
, byteorder
);
484 unicode_escape_decode(PyObject
*self
,
488 const char *errors
= NULL
;
491 if (!PyArg_ParseTuple(args
, "s*|z:unicode_escape_decode",
495 unicode
= PyUnicode_DecodeUnicodeEscape(pbuf
.buf
, pbuf
.len
, errors
);
496 PyBuffer_Release(&pbuf
);
497 return codec_tuple(unicode
, pbuf
.len
);
501 raw_unicode_escape_decode(PyObject
*self
,
505 const char *errors
= NULL
;
508 if (!PyArg_ParseTuple(args
, "s*|z:raw_unicode_escape_decode",
512 unicode
= PyUnicode_DecodeRawUnicodeEscape(pbuf
.buf
, pbuf
.len
, errors
);
513 PyBuffer_Release(&pbuf
);
514 return codec_tuple(unicode
, pbuf
.len
);
518 latin_1_decode(PyObject
*self
,
523 const char *errors
= NULL
;
525 if (!PyArg_ParseTuple(args
, "s*|z:latin_1_decode",
529 unicode
= PyUnicode_DecodeLatin1(pbuf
.buf
, pbuf
.len
, errors
);
530 PyBuffer_Release(&pbuf
);
531 return codec_tuple(unicode
, pbuf
.len
);
535 ascii_decode(PyObject
*self
,
540 const char *errors
= NULL
;
542 if (!PyArg_ParseTuple(args
, "s*|z:ascii_decode",
546 unicode
= PyUnicode_DecodeASCII(pbuf
.buf
, pbuf
.len
, errors
);
547 PyBuffer_Release(&pbuf
);
548 return codec_tuple(unicode
, pbuf
.len
);
552 charmap_decode(PyObject
*self
,
557 const char *errors
= NULL
;
558 PyObject
*mapping
= NULL
;
560 if (!PyArg_ParseTuple(args
, "s*|zO:charmap_decode",
561 &pbuf
, &errors
, &mapping
))
563 if (mapping
== Py_None
)
566 unicode
= PyUnicode_DecodeCharmap(pbuf
.buf
, pbuf
.len
, mapping
, errors
);
567 PyBuffer_Release(&pbuf
);
568 return codec_tuple(unicode
, pbuf
.len
);
571 #if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
574 mbcs_decode(PyObject
*self
,
578 const char *errors
= NULL
;
581 PyObject
*decoded
= NULL
;
583 if (!PyArg_ParseTuple(args
, "s*|zi:mbcs_decode",
584 &pbuf
, &errors
, &final
))
588 decoded
= PyUnicode_DecodeMBCSStateful(pbuf
.buf
, pbuf
.len
, errors
,
589 final
? NULL
: &consumed
);
590 PyBuffer_Release(&pbuf
);
593 return codec_tuple(decoded
, consumed
);
596 #endif /* MS_WINDOWS */
598 /* --- Encoder ------------------------------------------------------------ */
601 readbuffer_encode(PyObject
*self
,
606 const char *errors
= NULL
;
608 if (!PyArg_ParseTuple(args
, "s#|z:readbuffer_encode",
609 &data
, &size
, &errors
))
612 return codec_tuple(PyString_FromStringAndSize(data
, size
),
617 charbuffer_encode(PyObject
*self
,
622 const char *errors
= NULL
;
624 if (!PyArg_ParseTuple(args
, "t#|z:charbuffer_encode",
625 &data
, &size
, &errors
))
628 return codec_tuple(PyString_FromStringAndSize(data
, size
),
633 unicode_internal_encode(PyObject
*self
,
637 const char *errors
= NULL
;
641 if (!PyArg_ParseTuple(args
, "O|z:unicode_internal_encode",
645 if (PyUnicode_Check(obj
)) {
646 data
= PyUnicode_AS_DATA(obj
);
647 size
= PyUnicode_GET_DATA_SIZE(obj
);
648 return codec_tuple(PyString_FromStringAndSize(data
, size
),
652 if (PyObject_AsReadBuffer(obj
, (const void **)&data
, &size
))
654 return codec_tuple(PyString_FromStringAndSize(data
, size
),
660 utf_7_encode(PyObject
*self
,
664 const char *errors
= NULL
;
666 if (!PyArg_ParseTuple(args
, "O|z:utf_7_encode",
670 str
= PyUnicode_FromObject(str
);
673 v
= codec_tuple(PyUnicode_EncodeUTF7(PyUnicode_AS_UNICODE(str
),
674 PyUnicode_GET_SIZE(str
),
678 PyUnicode_GET_SIZE(str
));
684 utf_8_encode(PyObject
*self
,
688 const char *errors
= NULL
;
690 if (!PyArg_ParseTuple(args
, "O|z:utf_8_encode",
694 str
= PyUnicode_FromObject(str
);
697 v
= codec_tuple(PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(str
),
698 PyUnicode_GET_SIZE(str
),
700 PyUnicode_GET_SIZE(str
));
705 /* This version provides access to the byteorder parameter of the
706 builtin UTF-16 codecs as optional third argument. It defaults to 0
707 which means: use the native byte order and prepend the data with a
713 utf_16_encode(PyObject
*self
,
717 const char *errors
= NULL
;
720 if (!PyArg_ParseTuple(args
, "O|zi:utf_16_encode",
721 &str
, &errors
, &byteorder
))
724 str
= PyUnicode_FromObject(str
);
727 v
= codec_tuple(PyUnicode_EncodeUTF16(PyUnicode_AS_UNICODE(str
),
728 PyUnicode_GET_SIZE(str
),
731 PyUnicode_GET_SIZE(str
));
737 utf_16_le_encode(PyObject
*self
,
741 const char *errors
= NULL
;
743 if (!PyArg_ParseTuple(args
, "O|z:utf_16_le_encode",
747 str
= PyUnicode_FromObject(str
);
750 v
= codec_tuple(PyUnicode_EncodeUTF16(PyUnicode_AS_UNICODE(str
),
751 PyUnicode_GET_SIZE(str
),
754 PyUnicode_GET_SIZE(str
));
760 utf_16_be_encode(PyObject
*self
,
764 const char *errors
= NULL
;
766 if (!PyArg_ParseTuple(args
, "O|z:utf_16_be_encode",
770 str
= PyUnicode_FromObject(str
);
773 v
= codec_tuple(PyUnicode_EncodeUTF16(PyUnicode_AS_UNICODE(str
),
774 PyUnicode_GET_SIZE(str
),
777 PyUnicode_GET_SIZE(str
));
782 /* This version provides access to the byteorder parameter of the
783 builtin UTF-32 codecs as optional third argument. It defaults to 0
784 which means: use the native byte order and prepend the data with a
790 utf_32_encode(PyObject
*self
,
794 const char *errors
= NULL
;
797 if (!PyArg_ParseTuple(args
, "O|zi:utf_32_encode",
798 &str
, &errors
, &byteorder
))
801 str
= PyUnicode_FromObject(str
);
804 v
= codec_tuple(PyUnicode_EncodeUTF32(PyUnicode_AS_UNICODE(str
),
805 PyUnicode_GET_SIZE(str
),
808 PyUnicode_GET_SIZE(str
));
814 utf_32_le_encode(PyObject
*self
,
818 const char *errors
= NULL
;
820 if (!PyArg_ParseTuple(args
, "O|z:utf_32_le_encode",
824 str
= PyUnicode_FromObject(str
);
827 v
= codec_tuple(PyUnicode_EncodeUTF32(PyUnicode_AS_UNICODE(str
),
828 PyUnicode_GET_SIZE(str
),
831 PyUnicode_GET_SIZE(str
));
837 utf_32_be_encode(PyObject
*self
,
841 const char *errors
= NULL
;
843 if (!PyArg_ParseTuple(args
, "O|z:utf_32_be_encode",
847 str
= PyUnicode_FromObject(str
);
850 v
= codec_tuple(PyUnicode_EncodeUTF32(PyUnicode_AS_UNICODE(str
),
851 PyUnicode_GET_SIZE(str
),
854 PyUnicode_GET_SIZE(str
));
860 unicode_escape_encode(PyObject
*self
,
864 const char *errors
= NULL
;
866 if (!PyArg_ParseTuple(args
, "O|z:unicode_escape_encode",
870 str
= PyUnicode_FromObject(str
);
873 v
= codec_tuple(PyUnicode_EncodeUnicodeEscape(PyUnicode_AS_UNICODE(str
),
874 PyUnicode_GET_SIZE(str
)),
875 PyUnicode_GET_SIZE(str
));
881 raw_unicode_escape_encode(PyObject
*self
,
885 const char *errors
= NULL
;
887 if (!PyArg_ParseTuple(args
, "O|z:raw_unicode_escape_encode",
891 str
= PyUnicode_FromObject(str
);
894 v
= codec_tuple(PyUnicode_EncodeRawUnicodeEscape(
895 PyUnicode_AS_UNICODE(str
),
896 PyUnicode_GET_SIZE(str
)),
897 PyUnicode_GET_SIZE(str
));
903 latin_1_encode(PyObject
*self
,
907 const char *errors
= NULL
;
909 if (!PyArg_ParseTuple(args
, "O|z:latin_1_encode",
913 str
= PyUnicode_FromObject(str
);
916 v
= codec_tuple(PyUnicode_EncodeLatin1(
917 PyUnicode_AS_UNICODE(str
),
918 PyUnicode_GET_SIZE(str
),
920 PyUnicode_GET_SIZE(str
));
926 ascii_encode(PyObject
*self
,
930 const char *errors
= NULL
;
932 if (!PyArg_ParseTuple(args
, "O|z:ascii_encode",
936 str
= PyUnicode_FromObject(str
);
939 v
= codec_tuple(PyUnicode_EncodeASCII(
940 PyUnicode_AS_UNICODE(str
),
941 PyUnicode_GET_SIZE(str
),
943 PyUnicode_GET_SIZE(str
));
949 charmap_encode(PyObject
*self
,
953 const char *errors
= NULL
;
954 PyObject
*mapping
= NULL
;
956 if (!PyArg_ParseTuple(args
, "O|zO:charmap_encode",
957 &str
, &errors
, &mapping
))
959 if (mapping
== Py_None
)
962 str
= PyUnicode_FromObject(str
);
965 v
= codec_tuple(PyUnicode_EncodeCharmap(
966 PyUnicode_AS_UNICODE(str
),
967 PyUnicode_GET_SIZE(str
),
970 PyUnicode_GET_SIZE(str
));
976 charmap_build(PyObject
*self
, PyObject
*args
)
979 if (!PyArg_ParseTuple(args
, "U:charmap_build", &map
))
981 return PyUnicode_BuildEncodingMap(map
);
984 #if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
987 mbcs_encode(PyObject
*self
,
991 const char *errors
= NULL
;
993 if (!PyArg_ParseTuple(args
, "O|z:mbcs_encode",
997 str
= PyUnicode_FromObject(str
);
1000 v
= codec_tuple(PyUnicode_EncodeMBCS(
1001 PyUnicode_AS_UNICODE(str
),
1002 PyUnicode_GET_SIZE(str
),
1004 PyUnicode_GET_SIZE(str
));
1009 #endif /* MS_WINDOWS */
1010 #endif /* Py_USING_UNICODE */
1012 /* --- Error handler registry --------------------------------------------- */
1014 PyDoc_STRVAR(register_error__doc__
,
1015 "register_error(errors, handler)\n\
1017 Register the specified error handler under the name\n\
1018 errors. handler must be a callable object, that\n\
1019 will be called with an exception instance containing\n\
1020 information about the location of the encoding/decoding\n\
1021 error and must return a (replacement, new position) tuple.");
1023 static PyObject
*register_error(PyObject
*self
, PyObject
*args
)
1028 if (!PyArg_ParseTuple(args
, "sO:register_error",
1031 if (PyCodec_RegisterError(name
, handler
))
1036 PyDoc_STRVAR(lookup_error__doc__
,
1037 "lookup_error(errors) -> handler\n\
1039 Return the error handler for the specified error handling name\n\
1040 or raise a LookupError, if no handler exists under this name.");
1042 static PyObject
*lookup_error(PyObject
*self
, PyObject
*args
)
1046 if (!PyArg_ParseTuple(args
, "s:lookup_error",
1049 return PyCodec_LookupError(name
);
1052 /* --- Module API --------------------------------------------------------- */
1054 static PyMethodDef _codecs_functions
[] = {
1055 {"register", codec_register
, METH_O
,
1057 {"lookup", codec_lookup
, METH_VARARGS
,
1059 {"encode", codec_encode
, METH_VARARGS
,
1061 {"decode", codec_decode
, METH_VARARGS
,
1063 {"escape_encode", escape_encode
, METH_VARARGS
},
1064 {"escape_decode", escape_decode
, METH_VARARGS
},
1065 #ifdef Py_USING_UNICODE
1066 {"utf_8_encode", utf_8_encode
, METH_VARARGS
},
1067 {"utf_8_decode", utf_8_decode
, METH_VARARGS
},
1068 {"utf_7_encode", utf_7_encode
, METH_VARARGS
},
1069 {"utf_7_decode", utf_7_decode
, METH_VARARGS
},
1070 {"utf_16_encode", utf_16_encode
, METH_VARARGS
},
1071 {"utf_16_le_encode", utf_16_le_encode
, METH_VARARGS
},
1072 {"utf_16_be_encode", utf_16_be_encode
, METH_VARARGS
},
1073 {"utf_16_decode", utf_16_decode
, METH_VARARGS
},
1074 {"utf_16_le_decode", utf_16_le_decode
, METH_VARARGS
},
1075 {"utf_16_be_decode", utf_16_be_decode
, METH_VARARGS
},
1076 {"utf_16_ex_decode", utf_16_ex_decode
, METH_VARARGS
},
1077 {"utf_32_encode", utf_32_encode
, METH_VARARGS
},
1078 {"utf_32_le_encode", utf_32_le_encode
, METH_VARARGS
},
1079 {"utf_32_be_encode", utf_32_be_encode
, METH_VARARGS
},
1080 {"utf_32_decode", utf_32_decode
, METH_VARARGS
},
1081 {"utf_32_le_decode", utf_32_le_decode
, METH_VARARGS
},
1082 {"utf_32_be_decode", utf_32_be_decode
, METH_VARARGS
},
1083 {"utf_32_ex_decode", utf_32_ex_decode
, METH_VARARGS
},
1084 {"unicode_escape_encode", unicode_escape_encode
, METH_VARARGS
},
1085 {"unicode_escape_decode", unicode_escape_decode
, METH_VARARGS
},
1086 {"unicode_internal_encode", unicode_internal_encode
, METH_VARARGS
},
1087 {"unicode_internal_decode", unicode_internal_decode
, METH_VARARGS
},
1088 {"raw_unicode_escape_encode", raw_unicode_escape_encode
, METH_VARARGS
},
1089 {"raw_unicode_escape_decode", raw_unicode_escape_decode
, METH_VARARGS
},
1090 {"latin_1_encode", latin_1_encode
, METH_VARARGS
},
1091 {"latin_1_decode", latin_1_decode
, METH_VARARGS
},
1092 {"ascii_encode", ascii_encode
, METH_VARARGS
},
1093 {"ascii_decode", ascii_decode
, METH_VARARGS
},
1094 {"charmap_encode", charmap_encode
, METH_VARARGS
},
1095 {"charmap_decode", charmap_decode
, METH_VARARGS
},
1096 {"charmap_build", charmap_build
, METH_VARARGS
},
1097 {"readbuffer_encode", readbuffer_encode
, METH_VARARGS
},
1098 {"charbuffer_encode", charbuffer_encode
, METH_VARARGS
},
1099 #if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
1100 {"mbcs_encode", mbcs_encode
, METH_VARARGS
},
1101 {"mbcs_decode", mbcs_decode
, METH_VARARGS
},
1103 #endif /* Py_USING_UNICODE */
1104 {"register_error", register_error
, METH_VARARGS
,
1105 register_error__doc__
},
1106 {"lookup_error", lookup_error
, METH_VARARGS
,
1107 lookup_error__doc__
},
1108 {NULL
, NULL
} /* sentinel */
1114 Py_InitModule("_codecs", _codecs_functions
);