diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-08-13 23:59:58 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-08-13 23:59:58 (GMT) |
commit | 47fcb5b4c31eb6ed2042e2e558a640524dc0c986 (patch) | |
tree | d8c476f3feb7b820cc30b531d88f66803504bd79 /Include/unicodeobject.h | |
parent | f2e08b34f1fa50e99f8cab0a21721be2d1bb38b8 (diff) | |
download | cpython-47fcb5b4c31eb6ed2042e2e558a640524dc0c986.zip cpython-47fcb5b4c31eb6ed2042e2e558a640524dc0c986.tar.gz cpython-47fcb5b4c31eb6ed2042e2e558a640524dc0c986.tar.bz2 |
Issue #9542: Create PyUnicode_FSDecoder() function
It's a ParseTuple converter: decode bytes objects to unicode using
PyUnicode_DecodeFSDefaultAndSize(); str objects are output as-is.
* Don't specify surrogateescape error handler in the comments nor the
documentation, but PyUnicode_DecodeFSDefaultAndSize() and
PyUnicode_EncodeFSDefault() because these functions use strict error handler
for the mbcs encoding (on Windows).
* Remove PyUnicode_FSConverter() comment in unicodeobject.c to avoid
inconsistency with unicodeobject.h.
Diffstat (limited to 'Include/unicodeobject.h')
-rw-r--r-- | Include/unicodeobject.h | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/Include/unicodeobject.h b/Include/unicodeobject.h index 7f5e8fd..cee75cc 100644 --- a/Include/unicodeobject.h +++ b/Include/unicodeobject.h @@ -200,6 +200,7 @@ typedef PY_UNICODE_TYPE Py_UNICODE; # define PyUnicode_FromUnicode PyUnicodeUCS2_FromUnicode # define PyUnicode_FromWideChar PyUnicodeUCS2_FromWideChar # define PyUnicode_FSConverter PyUnicodeUCS2_FSConverter +# define PyUnicode_FSDecoder PyUnicodeUCS2_FSDecoder # define PyUnicode_GetDefaultEncoding PyUnicodeUCS2_GetDefaultEncoding # define PyUnicode_GetMax PyUnicodeUCS2_GetMax # define PyUnicode_GetSize PyUnicodeUCS2_GetSize @@ -300,6 +301,7 @@ typedef PY_UNICODE_TYPE Py_UNICODE; # define PyUnicode_FromUnicode PyUnicodeUCS4_FromUnicode # define PyUnicode_FromWideChar PyUnicodeUCS4_FromWideChar # define PyUnicode_FSConverter PyUnicodeUCS4_FSConverter +# define PyUnicode_FSDecoder PyUnicodeUCS4_FSDecoder # define PyUnicode_GetDefaultEncoding PyUnicodeUCS4_GetDefaultEncoding # define PyUnicode_GetMax PyUnicodeUCS4_GetMax # define PyUnicode_GetSize PyUnicodeUCS4_GetSize @@ -1239,12 +1241,16 @@ PyAPI_FUNC(int) PyUnicode_EncodeDecimal( /* --- File system encoding ---------------------------------------------- */ -/* ParseTuple converter which converts a Unicode object into the file - system encoding as a bytes object, using the "surrogateescape" error - handler; bytes objects are output as-is. */ +/* ParseTuple converter: encode str objects to bytes using + PyUnicode_EncodeFSDefault(); bytes objects are output as-is. */ PyAPI_FUNC(int) PyUnicode_FSConverter(PyObject*, void*); +/* ParseTuple converter: decode bytes objects to unicode using + PyUnicode_DecodeFSDefaultAndSize(); str objects are output as-is. */ + +PyAPI_FUNC(int) PyUnicode_FSDecoder(PyObject*, void*); + /* Decode a null-terminated string using Py_FileSystemDefaultEncoding and the "surrogateescape" error handler. |