diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-11-20 17:27:03 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-11-20 17:27:03 (GMT) |
commit | ac931b1e5bf86bb3ad3e2abee2cfd740df8f13bf (patch) | |
tree | 40992a6972a33e9137dc28e7f27f714161644b1e /Objects | |
parent | 22168998f5431effa9bd3942f29a155dad1a1545 (diff) | |
download | cpython-ac931b1e5bf86bb3ad3e2abee2cfd740df8f13bf.zip cpython-ac931b1e5bf86bb3ad3e2abee2cfd740df8f13bf.tar.gz cpython-ac931b1e5bf86bb3ad3e2abee2cfd740df8f13bf.tar.bz2 |
Use PyUnicode_EncodeCodePage() instead of PyUnicode_EncodeMBCS() with
PyUnicode_AsUnicodeAndSize()
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/unicodeobject.c | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index b0b9528..90a4fcb 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -3051,13 +3051,7 @@ PyObject * PyUnicode_EncodeFSDefault(PyObject *unicode) { #ifdef HAVE_MBCS - const Py_UNICODE *wstr; - Py_ssize_t wlen; - - wstr = PyUnicode_AsUnicodeAndSize(unicode, &wlen); - if (wstr == NULL) - return NULL; - return PyUnicode_EncodeMBCS(wstr, wlen, NULL); + return PyUnicode_EncodeCodePage(CP_ACP, unicode, NULL); #elif defined(__APPLE__) return _PyUnicode_AsUTF8String(unicode, "surrogateescape"); #else @@ -3141,15 +3135,8 @@ PyUnicode_AsEncodedString(PyObject *unicode, (strcmp(lower, "iso-8859-1") == 0)) return _PyUnicode_AsLatin1String(unicode, errors); #ifdef HAVE_MBCS - else if (strcmp(lower, "mbcs") == 0) { - const Py_UNICODE *wstr; - Py_ssize_t wlen; - - wstr = PyUnicode_AsUnicodeAndSize(unicode, &wlen); - if (wstr == NULL) - return NULL; - return PyUnicode_EncodeMBCS(wstr, wlen, errors); - } + else if (strcmp(lower, "mbcs") == 0) + return PyUnicode_EncodeCodePage(CP_ACP, unicode, errors); #endif else if (strcmp(lower, "ascii") == 0) return _PyUnicode_AsASCIIString(unicode, errors); |