summaryrefslogtreecommitdiffstats
path: root/Doc/c-api/unicode.rst
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-12-17 03:13:41 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-12-17 03:13:41 (GMT)
commitf2ea71fcc8986101512265b685d8d3dfdf7b7bdb (patch)
tree6b5e8c37d0b73993e542181584f0af7b87482220 /Doc/c-api/unicode.rst
parent9987d9351ca06dbad3b66ab6da52ab4621955f31 (diff)
downloadcpython-f2ea71fcc8986101512265b685d8d3dfdf7b7bdb.zip
cpython-f2ea71fcc8986101512265b685d8d3dfdf7b7bdb.tar.gz
cpython-f2ea71fcc8986101512265b685d8d3dfdf7b7bdb.tar.bz2
Issue #13560: Add PyUnicode_EncodeLocale()
* Use PyUnicode_EncodeLocale() in time.strftime() if wcsftime() is not available * Document my last changes in Misc/NEWS
Diffstat (limited to 'Doc/c-api/unicode.rst')
-rw-r--r--Doc/c-api/unicode.rst25
1 files changed, 24 insertions, 1 deletions
diff --git a/Doc/c-api/unicode.rst b/Doc/c-api/unicode.rst
index 0bf2eea..a6f3a69 100644
--- a/Doc/c-api/unicode.rst
+++ b/Doc/c-api/unicode.rst
@@ -713,7 +713,7 @@ system.
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.
+ must end with a null character but cannot contain embedded null characters.
.. seealso::
@@ -732,6 +732,22 @@ system.
.. versionadded:: 3.3
+.. c:function:: PyObject* PyUnicode_EncodeLocale(PyObject *unicode, int surrogateescape)
+
+ Encode a Unicode object to the current locale encoding. The encoder is
+ strict if *surrogateescape* is equal to zero, otherwise it uses the
+ ``'surrogateescape'`` error handler (:pep:`383`). Return a :class:`bytes`
+ object. *str* cannot contain embedded null characters.
+
+ .. seealso::
+
+ Use :c:func:`PyUnicode_EncodeFSDefault` to encode a string to
+ :c:data:`Py_FileSystemDefaultEncoding` (the locale encoding read at
+ Python startup).
+
+ .. versionadded:: 3.3
+
+
File System Encoding
""""""""""""""""""""
@@ -806,6 +822,13 @@ used, passing :c:func:`PyUnicode_FSDecoder` as the conversion function:
If :c:data:`Py_FileSystemDefaultEncoding` is not set, fall back to the
locale encoding.
+ .. seealso::
+
+ :c:data:`Py_FileSystemDefaultEncoding` is initialized at startup from the
+ locale encoding and cannot be modified later. If you need to encode a
+ string to the current locale encoding, use
+ :c:func:`PyUnicode_EncodeLocale`.
+
.. versionadded:: 3.2