Skip to content

Commit

Permalink
Add PyUnicode_AsUTF8AndSize to cpython imports [0.29.x] (#5164)
Browse files Browse the repository at this point in the history
Backport of #5163
  • Loading branch information
matusvalo committed Dec 8, 2022
1 parent 011c198 commit 3b1597c
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion Cython/Includes/cpython/unicode.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,25 @@ cdef extern from *:
# raised by the codec.
bytes PyUnicode_EncodeUTF8(Py_UNICODE *s, Py_ssize_t size, char *errors)

# Encode a Unicode objects using UTF-8 and return the result as Python string object. Error handling is ``strict''. Return NULL if an exception was raised by the codec.
# Encode a Unicode objects using UTF-8 and return the result as Python bytes object. Error handling is ``strict''. Return NULL if an exception was raised by the codec.
bytes PyUnicode_AsUTF8String(object unicode)


# Return a pointer to the UTF-8 encoding of the Unicode object,
# and store the size of the encoded representation (in bytes) in size.
# The size argument can be NULL; in this case no size will be stored.
# The returned buffer always has an extra null byte appended
# (not included in size), regardless of whether there are any
# other null code points.

# In the case of an error, NULL is returned with an exception set and
# no size is stored.

# 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
const char* PyUnicode_AsUTF8AndSize(object unicode, Py_ssize_t *size)

# These are the UTF-16 codec APIs:

# Decode length bytes from a UTF-16 encoded buffer string and
Expand Down

0 comments on commit 3b1597c

Please sign in to comment.