This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients docs@python, ezio.melotti, georg.brandl, loewis, pitrou, vstinner
Date 2011-10-23.09:08:29
SpamBayes Score 9.416712e-07
Marked as misclassified No
Message-id <1319360910.1.0.634191736155.issue13246@psf.upfronthosting.co.za>
In-reply-to
Content
> It seems there's no reason to document these functions
> which operate on null-terminated unicode arrays.

It's the easiest way to create a new string with the new Unicode API, when it's difficult to predict the exact output length and maximum character:

Py_UCS4 *buffer = PyMem_Malloc(...);
...
str = PyUnicode_FromKindAndBuffer(buffer, PyUnicode_4BYTE_KIND);
PyMem_Free(buffer);

PyUCS4_* functions are useful in the "..." (to write characters, expecially when you manipulate multiple strings).

For examples, see Python/import.c which used char*, then Py_UNICODE* and now Py_UCS4*. It's maybe possible to avoid functions like xxx_strlen(), but it was easier to replace str*() functions by Py_UNICODE_* and then PyUCS4_* functions.

--

Py_UNICODE_* and PyUCS4_* functions are not part of the stable API.
History
Date User Action Args
2011-10-23 09:08:30vstinnersetrecipients: + vstinner, loewis, georg.brandl, pitrou, ezio.melotti, docs@python
2011-10-23 09:08:30vstinnersetmessageid: <1319360910.1.0.634191736155.issue13246@psf.upfronthosting.co.za>
2011-10-23 09:08:29vstinnerlinkissue13246 messages
2011-10-23 09:08:29vstinnercreate