Skip to content

Commit

Permalink
Docs C API: Clarify what happens when null bytes are passed to `PyUni…
Browse files Browse the repository at this point in the history
…code_AsUTF8` (python#127458)

Co-authored-by: Stan U. <[email protected]>
Co-authored-by: Tomas R. <[email protected]>
Co-authored-by: Victor Stinner <[email protected]>
  • Loading branch information
4 people authored Jan 20, 2025
1 parent f0f7b97 commit e792f4b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Doc/c-api/unicode.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,15 @@ These are the UTF-8 codec APIs:
As :c:func:`PyUnicode_AsUTF8AndSize`, but does not store the size.
.. warning::
This function does not have any special behavior for
`null characters <https://en.wikipedia.org/wiki/Null_character>`_ embedded within
*unicode*. As a result, strings containing null characters will remain in the returned
string, which some C functions might interpret as the end of the string, leading to
truncation. If truncation is an issue, it is recommended to use :c:func:`PyUnicode_AsUTF8AndSize`
instead.
.. versionadded:: 3.3
.. versionchanged:: 3.7
Expand Down

0 comments on commit e792f4b

Please sign in to comment.