8000 doc: PyUnicode_AsUTF8String() fails if string contains surrogates by vstinner · Pull Request #124605 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

doc: PyUnicode_AsUTF8String() fails if string contains surrogates #124605

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 27, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
doc: PyUnicode_AsUTF8String() fails if string contains surrogates
  • Loading branch information
vstinner committed Sep 26, 2024
commit 770362ca09284a9b208930515efdb417798b80f9
4 changes: 4 additions & 0 deletions Doc/c-api/unicode.rst
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,8 @@ These are the UTF-8 codec APIs:
object. Error handling is "strict". Return ``NULL`` if an exception was
raised by the codec.

The function fails if the string contains surrogate characters.


.. c:function:: const char* PyUnicode_AsUTF8AndSize(PyObject *unicode, Py_ssize_t *size)

Expand All @@ -1002,6 +1004,8 @@ These are the UTF-8 codec APIs:
On error, set an exception, set *size* to ``-1`` (if it's not NULL) and
return ``NULL``.

The function fails if the string contains surrogate characters.

This caches the UTF-8 representation of the string in the Unicode object, and
subsequent calls will return a pointer to the same buffer. The caller is not
responsible for deallocating the buffer. The buffer is deallocated and
Expand Down
Loading
0