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 registerd 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
,
237 const char *errors
= NULL
;
239 if (!PyArg_ParseTuple(args
, "t#|z:utf_7_decode",
240 &data
, &size
, &errors
))
243 return codec_tuple(PyUnicode_DecodeUTF7(data
, size
, errors
),
248 utf_8_decode(PyObject
*self
,
253 const char *errors
= NULL
;
256 PyObject
*decoded
= NULL
;
258 if (!PyArg_ParseTuple(args
, "t#|zi:utf_8_decode",
259 &data
, &size
, &errors
, &final
))
262 PyErr_SetString(PyExc_ValueError
, "negative argument");
267 decoded
= PyUnicode_DecodeUTF8Stateful(data
, size
, errors
,
268 final
? NULL
: &consumed
);
271 return codec_tuple(decoded
, consumed
);
275 utf_16_decode(PyObject
*self
,
280 const char *errors
= NULL
;
286 if (!PyArg_ParseTuple(args
, "t#|zi:utf_16_decode",
287 &data
, &size
, &errors
, &final
))
290 PyErr_SetString(PyExc_ValueError
, "negative argument");
293 consumed
= size
; /* This is overwritten unless final is true. */
294 decoded
= PyUnicode_DecodeUTF16Stateful(data
, size
, errors
, &byteorder
,
295 final
? NULL
: &consumed
);
298 return codec_tuple(decoded
, consumed
);
302 utf_16_le_decode(PyObject
*self
,
307 const char *errors
= NULL
;
311 PyObject
*decoded
= NULL
;
313 if (!PyArg_ParseTuple(args
, "t#|zi:utf_16_le_decode",
314 &data
, &size
, &errors
, &final
))
318 PyErr_SetString(PyExc_ValueError
, "negative argument");
321 consumed
= size
; /* This is overwritten unless final is true. */
322 decoded
= PyUnicode_DecodeUTF16Stateful(data
, size
, errors
,
323 &byteorder
, final
? NULL
: &consumed
);
326 return codec_tuple(decoded
, consumed
);
331 utf_16_be_decode(PyObject
*self
,
336 const char *errors
= NULL
;
340 PyObject
*decoded
= NULL
;
342 if (!PyArg_ParseTuple(args
, "t#|zi:utf_16_be_decode",
343 &data
, &size
, &errors
, &final
))
346 PyErr_SetString(PyExc_ValueError
, "negative argument");
349 consumed
= size
; /* This is overwritten unless final is true. */
350 decoded
= PyUnicode_DecodeUTF16Stateful(data
, size
, errors
,
351 &byteorder
, final
? NULL
: &consumed
);
354 return codec_tuple(decoded
, consumed
);
357 /* This non-standard version also provides access to the byteorder
358 parameter of the builtin UTF-16 codec.
360 It returns a tuple (unicode, bytesread, byteorder) with byteorder
361 being the value in effect at the end of data.
366 utf_16_ex_decode(PyObject
*self
,
371 const char *errors
= NULL
;
373 PyObject
*unicode
, *tuple
;
377 if (!PyArg_ParseTuple(args
, "t#|zii:utf_16_ex_decode",
378 &data
, &size
, &errors
, &byteorder
, &final
))
381 PyErr_SetString(PyExc_ValueError
, "negative argument");
384 consumed
= size
; /* This is overwritten unless final is true. */
385 unicode
= PyUnicode_DecodeUTF16Stateful(data
, size
, errors
, &byteorder
,
386 final
? NULL
: &consumed
);
389 tuple
= Py_BuildValue("Oni", unicode
, consumed
, byteorder
);
395 utf_32_decode(PyObject
*self
,
400 const char *errors
= NULL
;
406 if (!PyArg_ParseTuple(args
, "t#|zi:utf_32_decode",
407 &data
, &size
, &errors
, &final
))
410 PyErr_SetString(PyExc_ValueError
, "negative argument");
413 consumed
= size
; /* This is overwritten unless final is true. */
414 decoded
= PyUnicode_DecodeUTF32Stateful(data
, size
, errors
, &byteorder
,
415 final
? NULL
: &consumed
);
418 return codec_tuple(decoded
, consumed
);
422 utf_32_le_decode(PyObject
*self
,
427 const char *errors
= NULL
;
431 PyObject
*decoded
= NULL
;
433 if (!PyArg_ParseTuple(args
, "t#|zi:utf_32_le_decode",
434 &data
, &size
, &errors
, &final
))
438 PyErr_SetString(PyExc_ValueError
, "negative argument");
441 consumed
= size
; /* This is overwritten unless final is true. */
442 decoded
= PyUnicode_DecodeUTF32Stateful(data
, size
, errors
,
443 &byteorder
, final
? NULL
: &consumed
);
446 return codec_tuple(decoded
, consumed
);
451 utf_32_be_decode(PyObject
*self
,
456 const char *errors
= NULL
;
460 PyObject
*decoded
= NULL
;
462 if (!PyArg_ParseTuple(args
, "t#|zi:utf_32_be_decode",
463 &data
, &size
, &errors
, &final
))
466 PyErr_SetString(PyExc_ValueError
, "negative argument");
469 consumed
= size
; /* This is overwritten unless final is true. */
470 decoded
= PyUnicode_DecodeUTF32Stateful(data
, size
, errors
,
471 &byteorder
, final
? NULL
: &consumed
);
474 return codec_tuple(decoded
, consumed
);
477 /* This non-standard version also provides access to the byteorder
478 parameter of the builtin UTF-32 codec.
480 It returns a tuple (unicode, bytesread, byteorder) with byteorder
481 being the value in effect at the end of data.
486 utf_32_ex_decode(PyObject
*self
,
491 const char *errors
= NULL
;
493 PyObject
*unicode
, *tuple
;
497 if (!PyArg_ParseTuple(args
, "t#|zii:utf_32_ex_decode",
498 &data
, &size
, &errors
, &byteorder
, &final
))
501 PyErr_SetString(PyExc_ValueError
, "negative argument");
504 consumed
= size
; /* This is overwritten unless final is true. */
505 unicode
= PyUnicode_DecodeUTF32Stateful(data
, size
, errors
, &byteorder
,
506 final
? NULL
: &consumed
);
509 tuple
= Py_BuildValue("Oni", unicode
, consumed
, byteorder
);
515 unicode_escape_decode(PyObject
*self
,
520 const char *errors
= NULL
;
522 if (!PyArg_ParseTuple(args
, "t#|z:unicode_escape_decode",
523 &data
, &size
, &errors
))
526 return codec_tuple(PyUnicode_DecodeUnicodeEscape(data
, size
, errors
),
531 raw_unicode_escape_decode(PyObject
*self
,
536 const char *errors
= NULL
;
538 if (!PyArg_ParseTuple(args
, "t#|z:raw_unicode_escape_decode",
539 &data
, &size
, &errors
))
542 return codec_tuple(PyUnicode_DecodeRawUnicodeEscape(data
, size
, errors
),
547 latin_1_decode(PyObject
*self
,
552 const char *errors
= NULL
;
554 if (!PyArg_ParseTuple(args
, "t#|z:latin_1_decode",
555 &data
, &size
, &errors
))
558 return codec_tuple(PyUnicode_DecodeLatin1(data
, size
, errors
),
563 ascii_decode(PyObject
*self
,
568 const char *errors
= NULL
;
570 if (!PyArg_ParseTuple(args
, "t#|z:ascii_decode",
571 &data
, &size
, &errors
))
574 return codec_tuple(PyUnicode_DecodeASCII(data
, size
, errors
),
579 charmap_decode(PyObject
*self
,
584 const char *errors
= NULL
;
585 PyObject
*mapping
= NULL
;
587 if (!PyArg_ParseTuple(args
, "t#|zO:charmap_decode",
588 &data
, &size
, &errors
, &mapping
))
590 if (mapping
== Py_None
)
593 return codec_tuple(PyUnicode_DecodeCharmap(data
, size
, mapping
, errors
),
597 #if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
600 mbcs_decode(PyObject
*self
,
604 Py_ssize_t size
, consumed
;
605 const char *errors
= NULL
;
609 if (!PyArg_ParseTuple(args
, "t#|zi:mbcs_decode",
610 &data
, &size
, &errors
, &final
))
613 decoded
= PyUnicode_DecodeMBCSStateful(
614 data
, size
, errors
, final
? NULL
: &consumed
);
617 return codec_tuple(decoded
, final
? size
: consumed
);
620 #endif /* MS_WINDOWS */
622 /* --- Encoder ------------------------------------------------------------ */
625 readbuffer_encode(PyObject
*self
,
630 const char *errors
= NULL
;
632 if (!PyArg_ParseTuple(args
, "s#|z:readbuffer_encode",
633 &data
, &size
, &errors
))
636 return codec_tuple(PyString_FromStringAndSize(data
, size
),
641 charbuffer_encode(PyObject
*self
,
646 const char *errors
= NULL
;
648 if (!PyArg_ParseTuple(args
, "t#|z:charbuffer_encode",
649 &data
, &size
, &errors
))
652 return codec_tuple(PyString_FromStringAndSize(data
, size
),
657 unicode_internal_encode(PyObject
*self
,
661 const char *errors
= NULL
;
665 if (!PyArg_ParseTuple(args
, "O|z:unicode_internal_encode",
669 if (PyUnicode_Check(obj
)) {
670 data
= PyUnicode_AS_DATA(obj
);
671 size
= PyUnicode_GET_DATA_SIZE(obj
);
672 return codec_tuple(PyString_FromStringAndSize(data
, size
),
676 if (PyObject_AsReadBuffer(obj
, (const void **)&data
, &size
))
678 return codec_tuple(PyString_FromStringAndSize(data
, size
),
684 utf_7_encode(PyObject
*self
,
688 const char *errors
= NULL
;
690 if (!PyArg_ParseTuple(args
, "O|z:utf_7_encode",
694 str
= PyUnicode_FromObject(str
);
697 v
= codec_tuple(PyUnicode_EncodeUTF7(PyUnicode_AS_UNICODE(str
),
698 PyUnicode_GET_SIZE(str
),
702 PyUnicode_GET_SIZE(str
));
708 utf_8_encode(PyObject
*self
,
712 const char *errors
= NULL
;
714 if (!PyArg_ParseTuple(args
, "O|z:utf_8_encode",
718 str
= PyUnicode_FromObject(str
);
721 v
= codec_tuple(PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(str
),
722 PyUnicode_GET_SIZE(str
),
724 PyUnicode_GET_SIZE(str
));
729 /* This version provides access to the byteorder parameter of the
730 builtin UTF-16 codecs as optional third argument. It defaults to 0
731 which means: use the native byte order and prepend the data with a
737 utf_16_encode(PyObject
*self
,
741 const char *errors
= NULL
;
744 if (!PyArg_ParseTuple(args
, "O|zi:utf_16_encode",
745 &str
, &errors
, &byteorder
))
748 str
= PyUnicode_FromObject(str
);
751 v
= codec_tuple(PyUnicode_EncodeUTF16(PyUnicode_AS_UNICODE(str
),
752 PyUnicode_GET_SIZE(str
),
755 PyUnicode_GET_SIZE(str
));
761 utf_16_le_encode(PyObject
*self
,
765 const char *errors
= NULL
;
767 if (!PyArg_ParseTuple(args
, "O|z:utf_16_le_encode",
771 str
= PyUnicode_FromObject(str
);
774 v
= codec_tuple(PyUnicode_EncodeUTF16(PyUnicode_AS_UNICODE(str
),
775 PyUnicode_GET_SIZE(str
),
778 PyUnicode_GET_SIZE(str
));
784 utf_16_be_encode(PyObject
*self
,
788 const char *errors
= NULL
;
790 if (!PyArg_ParseTuple(args
, "O|z:utf_16_be_encode",
794 str
= PyUnicode_FromObject(str
);
797 v
= codec_tuple(PyUnicode_EncodeUTF16(PyUnicode_AS_UNICODE(str
),
798 PyUnicode_GET_SIZE(str
),
801 PyUnicode_GET_SIZE(str
));
806 /* This version provides access to the byteorder parameter of the
807 builtin UTF-32 codecs as optional third argument. It defaults to 0
808 which means: use the native byte order and prepend the data with a
814 utf_32_encode(PyObject
*self
,
818 const char *errors
= NULL
;
821 if (!PyArg_ParseTuple(args
, "O|zi:utf_32_encode",
822 &str
, &errors
, &byteorder
))
825 str
= PyUnicode_FromObject(str
);
828 v
= codec_tuple(PyUnicode_EncodeUTF32(PyUnicode_AS_UNICODE(str
),
829 PyUnicode_GET_SIZE(str
),
832 PyUnicode_GET_SIZE(str
));
838 utf_32_le_encode(PyObject
*self
,
842 const char *errors
= NULL
;
844 if (!PyArg_ParseTuple(args
, "O|z:utf_32_le_encode",
848 str
= PyUnicode_FromObject(str
);
851 v
= codec_tuple(PyUnicode_EncodeUTF32(PyUnicode_AS_UNICODE(str
),
852 PyUnicode_GET_SIZE(str
),
855 PyUnicode_GET_SIZE(str
));
861 utf_32_be_encode(PyObject
*self
,
865 const char *errors
= NULL
;
867 if (!PyArg_ParseTuple(args
, "O|z:utf_32_be_encode",
871 str
= PyUnicode_FromObject(str
);
874 v
= codec_tuple(PyUnicode_EncodeUTF32(PyUnicode_AS_UNICODE(str
),
875 PyUnicode_GET_SIZE(str
),
878 PyUnicode_GET_SIZE(str
));
884 unicode_escape_encode(PyObject
*self
,
888 const char *errors
= NULL
;
890 if (!PyArg_ParseTuple(args
, "O|z:unicode_escape_encode",
894 str
= PyUnicode_FromObject(str
);
897 v
= codec_tuple(PyUnicode_EncodeUnicodeEscape(PyUnicode_AS_UNICODE(str
),
898 PyUnicode_GET_SIZE(str
)),
899 PyUnicode_GET_SIZE(str
));
905 raw_unicode_escape_encode(PyObject
*self
,
909 const char *errors
= NULL
;
911 if (!PyArg_ParseTuple(args
, "O|z:raw_unicode_escape_encode",
915 str
= PyUnicode_FromObject(str
);
918 v
= codec_tuple(PyUnicode_EncodeRawUnicodeEscape(
919 PyUnicode_AS_UNICODE(str
),
920 PyUnicode_GET_SIZE(str
)),
921 PyUnicode_GET_SIZE(str
));
927 latin_1_encode(PyObject
*self
,
931 const char *errors
= NULL
;
933 if (!PyArg_ParseTuple(args
, "O|z:latin_1_encode",
937 str
= PyUnicode_FromObject(str
);
940 v
= codec_tuple(PyUnicode_EncodeLatin1(
941 PyUnicode_AS_UNICODE(str
),
942 PyUnicode_GET_SIZE(str
),
944 PyUnicode_GET_SIZE(str
));
950 ascii_encode(PyObject
*self
,
954 const char *errors
= NULL
;
956 if (!PyArg_ParseTuple(args
, "O|z:ascii_encode",
960 str
= PyUnicode_FromObject(str
);
963 v
= codec_tuple(PyUnicode_EncodeASCII(
964 PyUnicode_AS_UNICODE(str
),
965 PyUnicode_GET_SIZE(str
),
967 PyUnicode_GET_SIZE(str
));
973 charmap_encode(PyObject
*self
,
977 const char *errors
= NULL
;
978 PyObject
*mapping
= NULL
;
980 if (!PyArg_ParseTuple(args
, "O|zO:charmap_encode",
981 &str
, &errors
, &mapping
))
983 if (mapping
== Py_None
)
986 str
= PyUnicode_FromObject(str
);
989 v
= codec_tuple(PyUnicode_EncodeCharmap(
990 PyUnicode_AS_UNICODE(str
),
991 PyUnicode_GET_SIZE(str
),
994 PyUnicode_GET_SIZE(str
));
1000 charmap_build(PyObject
*self
, PyObject
*args
)
1003 if (!PyArg_ParseTuple(args
, "U:charmap_build", &map
))
1005 return PyUnicode_BuildEncodingMap(map
);
1008 #if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
1011 mbcs_encode(PyObject
*self
,
1015 const char *errors
= NULL
;
1017 if (!PyArg_ParseTuple(args
, "O|z:mbcs_encode",
1021 str
= PyUnicode_FromObject(str
);
1024 v
= codec_tuple(PyUnicode_EncodeMBCS(
1025 PyUnicode_AS_UNICODE(str
),
1026 PyUnicode_GET_SIZE(str
),
1028 PyUnicode_GET_SIZE(str
));
1033 #endif /* MS_WINDOWS */
1034 #endif /* Py_USING_UNICODE */
1036 /* --- Error handler registry --------------------------------------------- */
1038 PyDoc_STRVAR(register_error__doc__
,
1039 "register_error(errors, handler)\n\
1041 Register the specified error handler under the name\n\
1042 errors. handler must be a callable object, that\n\
1043 will be called with an exception instance containing\n\
1044 information about the location of the encoding/decoding\n\
1045 error and must return a (replacement, new position) tuple.");
1047 static PyObject
*register_error(PyObject
*self
, PyObject
*args
)
1052 if (!PyArg_ParseTuple(args
, "sO:register_error",
1055 if (PyCodec_RegisterError(name
, handler
))
1060 PyDoc_STRVAR(lookup_error__doc__
,
1061 "lookup_error(errors) -> handler\n\
1063 Return the error handler for the specified error handling name\n\
1064 or raise a LookupError, if no handler exists under this name.");
1066 static PyObject
*lookup_error(PyObject
*self
, PyObject
*args
)
1070 if (!PyArg_ParseTuple(args
, "s:lookup_error",
1073 return PyCodec_LookupError(name
);
1076 /* --- Module API --------------------------------------------------------- */
1078 static PyMethodDef _codecs_functions
[] = {
1079 {"register", codec_register
, METH_O
,
1081 {"lookup", codec_lookup
, METH_VARARGS
,
1083 {"encode", codec_encode
, METH_VARARGS
,
1085 {"decode", codec_decode
, METH_VARARGS
,
1087 {"escape_encode", escape_encode
, METH_VARARGS
},
1088 {"escape_decode", escape_decode
, METH_VARARGS
},
1089 #ifdef Py_USING_UNICODE
1090 {"utf_8_encode", utf_8_encode
, METH_VARARGS
},
1091 {"utf_8_decode", utf_8_decode
, METH_VARARGS
},
1092 {"utf_7_encode", utf_7_encode
, METH_VARARGS
},
1093 {"utf_7_decode", utf_7_decode
, METH_VARARGS
},
1094 {"utf_16_encode", utf_16_encode
, METH_VARARGS
},
1095 {"utf_16_le_encode", utf_16_le_encode
, METH_VARARGS
},
1096 {"utf_16_be_encode", utf_16_be_encode
, METH_VARARGS
},
1097 {"utf_16_decode", utf_16_decode
, METH_VARARGS
},
1098 {"utf_16_le_decode", utf_16_le_decode
, METH_VARARGS
},
1099 {"utf_16_be_decode", utf_16_be_decode
, METH_VARARGS
},
1100 {"utf_16_ex_decode", utf_16_ex_decode
, METH_VARARGS
},
1101 {"utf_32_encode", utf_32_encode
, METH_VARARGS
},
1102 {"utf_32_le_encode", utf_32_le_encode
, METH_VARARGS
},
1103 {"utf_32_be_encode", utf_32_be_encode
, METH_VARARGS
},
1104 {"utf_32_decode", utf_32_decode
, METH_VARARGS
},
1105 {"utf_32_le_decode", utf_32_le_decode
, METH_VARARGS
},
1106 {"utf_32_be_decode", utf_32_be_decode
, METH_VARARGS
},
1107 {"utf_32_ex_decode", utf_32_ex_decode
, METH_VARARGS
},
1108 {"unicode_escape_encode", unicode_escape_encode
, METH_VARARGS
},
1109 {"unicode_escape_decode", unicode_escape_decode
, METH_VARARGS
},
1110 {"unicode_internal_encode", unicode_internal_encode
, METH_VARARGS
},
1111 {"unicode_internal_decode", unicode_internal_decode
, METH_VARARGS
},
1112 {"raw_unicode_escape_encode", raw_unicode_escape_encode
, METH_VARARGS
},
1113 {"raw_unicode_escape_decode", raw_unicode_escape_decode
, METH_VARARGS
},
1114 {"latin_1_encode", latin_1_encode
, METH_VARARGS
},
1115 {"latin_1_decode", latin_1_decode
, METH_VARARGS
},
1116 {"ascii_encode", ascii_encode
, METH_VARARGS
},
1117 {"ascii_decode", ascii_decode
, METH_VARARGS
},
1118 {"charmap_encode", charmap_encode
, METH_VARARGS
},
1119 {"charmap_decode", charmap_decode
, METH_VARARGS
},
1120 {"charmap_build", charmap_build
, METH_VARARGS
},
1121 {"readbuffer_encode", readbuffer_encode
, METH_VARARGS
},
1122 {"charbuffer_encode", charbuffer_encode
, METH_VARARGS
},
1123 #if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
1124 {"mbcs_encode", mbcs_encode
, METH_VARARGS
},
1125 {"mbcs_decode", mbcs_decode
, METH_VARARGS
},
1127 #endif /* Py_USING_UNICODE */
1128 {"register_error", register_error
, METH_VARARGS
,
1129 register_error__doc__
},
1130 {"lookup_error", lookup_error
, METH_VARARGS
,
1131 lookup_error__doc__
},
1132 {NULL
, NULL
} /* sentinel */
1138 Py_InitModule("_codecs", _codecs_functions
);