Skip to content

Commit e792f4b

Browse files
ZeroIntensityStanFromIrelandtomasr8vstinner
authored
Docs C API: Clarify what happens when null bytes are passed to PyUnicode_AsUTF8 (#127458)
Co-authored-by: Stan U. <[email protected]> Co-authored-by: Tomas R. <[email protected]> Co-authored-by: Victor Stinner <[email protected]>
1 parent f0f7b97 commit e792f4b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Doc/c-api/unicode.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,6 +1054,15 @@ These are the UTF-8 codec APIs:
10541054
10551055
As :c:func:`PyUnicode_AsUTF8AndSize`, but does not store the size.
10561056
1057+
.. warning::
1058+
1059+
This function does not have any special behavior for
1060+
`null characters <https://en.wikipedia.org/wiki/Null_character>`_ embedded within
1061+
*unicode*. As a result, strings containing null characters will remain in the returned
1062+
string, which some C functions might interpret as the end of the string, leading to
1063+
truncation. If truncation is an issue, it is recommended to use :c:func:`PyUnicode_AsUTF8AndSize`
1064+
instead.
1065+
10571066
.. versionadded:: 3.3
10581067
10591068
.. versionchanged:: 3.7

0 commit comments

Comments
 (0)