summaryrefslogtreecommitdiffstats
path: root/Include
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-12-16 22:56:01 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-12-16 22:56:01 (GMT)
commitaf02e1c85a66009cdc645a64de7d7ee1335c8301 (patch)
tree5bc78c3a8628589cf5a4c246afc0076871d51c62 /Include
parent3607e3de278c89660f773064a94385066eebda1b (diff)
downloadcpython-af02e1c85a66009cdc645a64de7d7ee1335c8301.zip
cpython-af02e1c85a66009cdc645a64de7d7ee1335c8301.tar.gz
cpython-af02e1c85a66009cdc645a64de7d7ee1335c8301.tar.bz2
Add PyUnicode_DecodeLocaleAndSize() and PyUnicode_DecodeLocale()
* PyUnicode_DecodeLocaleAndSize() and PyUnicode_DecodeLocale() decode a string from the current locale encoding * _Py_char2wchar() writes an "error code" in the size argument to indicate if the function failed because of memory allocation failure or because of a decoding error. The function doesn't write the error message directly to stderr. * Fix time.strftime() (if wcsftime() is missing): decode strftime() result from the current locale encoding, not from the filesystem encoding.
Diffstat (limited to 'Include')
-rw-r--r--Include/unicodeobject.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/Include/unicodeobject.h b/Include/unicodeobject.h
index cd35ae6..5f073e0 100644
--- a/Include/unicodeobject.h
+++ b/Include/unicodeobject.h
@@ -1595,6 +1595,28 @@ PyAPI_FUNC(PyObject*) _PyUnicode_TransformDecimalAndSpaceToASCII(
);
#endif
+/* --- Locale encoding --------------------------------------------------- */
+
+/* Decode a string from the current locale encoding. The decoder is strict if
+ *surrogateescape* is equal to zero, otherwise it uses the 'surrogateescape'
+ error handler (PEP 383) to escape undecodable bytes. If a byte sequence can
+ be decoded as a surrogate character and *surrogateescape* is not equal to
+ zero, the byte sequence is escaped using the 'surrogateescape' error handler
+ instead of being decoded. *str* must end with a null character but cannot
+ contain embedded null character. */
+
+PyAPI_FUNC(PyObject*) PyUnicode_DecodeLocaleAndSize(
+ const char *str,
+ Py_ssize_t len,
+ int surrogateescape);
+
+/* Similar to PyUnicode_DecodeLocaleAndSize(), but compute the string
+ length using strlen(). */
+
+PyAPI_FUNC(PyObject*) PyUnicode_DecodeLocale(
+ const char *str,
+ int surrogateescape);
+
/* --- File system encoding ---------------------------------------------- */
/* ParseTuple converter: encode str objects to bytes using