summaryrefslogtreecommitdiffstats
path: root/Modules/_codecsmodule.c
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@microsoft.com>2016-09-07 02:42:27 (GMT)
committerSteve Dower <steve.dower@microsoft.com>2016-09-07 02:42:27 (GMT)
commitf5aba58480bb0dd45181f609487ac2ecfcc98673 (patch)
tree0d70301224f945e379c37058fa6b24b6ba8c78e5 /Modules/_codecsmodule.c
parent22d0698d3b034f4f4314aa793da7225a5da640ba (diff)
downloadcpython-f5aba58480bb0dd45181f609487ac2ecfcc98673.zip
cpython-f5aba58480bb0dd45181f609487ac2ecfcc98673.tar.gz
cpython-f5aba58480bb0dd45181f609487ac2ecfcc98673.tar.bz2
Issue #27959: Adds oem encoding, alias ansi to mbcs, move aliasmbcs to codec lookup
Diffstat (limited to 'Modules/_codecsmodule.c')
-rw-r--r--Modules/_codecsmodule.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/Modules/_codecsmodule.c b/Modules/_codecsmodule.c
index 4e75995..4d25a53 100644
--- a/Modules/_codecsmodule.c
+++ b/Modules/_codecsmodule.c
@@ -626,6 +626,25 @@ _codecs_mbcs_decode_impl(PyObject *module, Py_buffer *data,
}
/*[clinic input]
+_codecs.oem_decode
+ data: Py_buffer
+ errors: str(accept={str, NoneType}) = NULL
+ final: int(c_default="0") = False
+ /
+[clinic start generated code]*/
+
+static PyObject *
+_codecs_oem_decode_impl(PyObject *module, Py_buffer *data,
+ const char *errors, int final)
+/*[clinic end generated code: output=da1617612f3fcad8 input=95b8a92c446b03cd]*/
+{
+ Py_ssize_t consumed = data->len;
+ PyObject *decoded = PyUnicode_DecodeCodePageStateful(CP_OEMCP,
+ data->buf, data->len, errors, final ? NULL : &consumed);
+ return codec_tuple(decoded, consumed);
+}
+
+/*[clinic input]
_codecs.code_page_decode
codepage: int
data: Py_buffer
@@ -971,6 +990,21 @@ _codecs_mbcs_encode_impl(PyObject *module, PyObject *str, const char *errors)
}
/*[clinic input]
+_codecs.oem_encode
+ str: unicode
+ errors: str(accept={str, NoneType}) = NULL
+ /
+[clinic start generated code]*/
+
+static PyObject *
+_codecs_oem_encode_impl(PyObject *module, PyObject *str, const char *errors)
+/*[clinic end generated code: output=65d5982c737de649 input=3fc5f0028aad3cda]*/
+{
+ return codec_tuple(PyUnicode_EncodeCodePage(CP_OEMCP, str, errors),
+ PyUnicode_GET_LENGTH(str));
+}
+
+/*[clinic input]
_codecs.code_page_encode
code_page: int
str: unicode
@@ -1075,6 +1109,8 @@ static PyMethodDef _codecs_functions[] = {
_CODECS_READBUFFER_ENCODE_METHODDEF
_CODECS_MBCS_ENCODE_METHODDEF
_CODECS_MBCS_DECODE_METHODDEF
+ _CODECS_OEM_ENCODE_METHODDEF
+ _CODECS_OEM_DECODE_METHODDEF
_CODECS_CODE_PAGE_ENCODE_METHODDEF
_CODECS_CODE_PAGE_DECODE_METHODDEF
_CODECS_REGISTER_ERROR_METHODDEF