diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2020-10-19 22:17:50 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-19 22:17:50 (GMT) |
commit | 3a8fdb28794b2f19f6c8464378fb8b46bce1f5f4 (patch) | |
tree | 860c455643cb15787c0b2c4de90dec28d96f9d2e /Include/unicodeobject.h | |
parent | 4dfb190a33a1deac60306f15d52d2fe11fb93464 (diff) | |
download | cpython-3a8fdb28794b2f19f6c8464378fb8b46bce1f5f4.zip cpython-3a8fdb28794b2f19f6c8464378fb8b46bce1f5f4.tar.gz cpython-3a8fdb28794b2f19f6c8464378fb8b46bce1f5f4.tar.bz2 |
bpo-41784: make PyUnicode_AsUTF8AndSize part of the limited API (GH-22252)
Diffstat (limited to 'Include/unicodeobject.h')
-rw-r--r-- | Include/unicodeobject.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Include/unicodeobject.h b/Include/unicodeobject.h index 90b3299..b0ac086 100644 --- a/Include/unicodeobject.h +++ b/Include/unicodeobject.h @@ -468,6 +468,23 @@ PyAPI_FUNC(PyObject*) PyUnicode_AsUTF8String( PyObject *unicode /* Unicode object */ ); +/* Returns a pointer to the default encoding (UTF-8) of the + Unicode object unicode and the size of the encoded representation + in bytes stored in *size. + + In case of an error, no *size is set. + + This function caches the UTF-8 encoded string in the unicodeobject + and subsequent calls will return the same string. The memory is released + when the unicodeobject is deallocated. +*/ + +#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030A0000 +PyAPI_FUNC(const char *) PyUnicode_AsUTF8AndSize( + PyObject *unicode, + Py_ssize_t *size); +#endif + /* --- UTF-32 Codecs ------------------------------------------------------ */ /* Decodes length bytes from a UTF-32 encoded buffer string and returns |