[issue10542] Py_UNICODE_NEXT and other macros for surrogates

Alexander Belopolsky report at bugs.python.org
Sat Nov 27 01:31:37 CET 2010


Alexander Belopolsky <belopolsky at users.sourceforge.net> added the comment:

On Fri, Nov 26, 2010 at 7:27 PM, Eric Smith <report at bugs.python.org> wrote:
..
>
> In addition to the proposed Py_UNICODE_NEXT and Py_UNICODE_PUT_NEXT, > str.__format__ would also need a function that tells it how many Py_UNICODEs
> are needed to store a given Py_UCS4.

Yes, this functionality is currently hidden in

unicode_aswidechar(PyUnicodeObject *unicode,
                   wchar_t *w,
                   Py_ssize_t size):

/* Helper function for PyUnicode_AsWideChar() and
PyUnicode_AsWideCharString():
   convert a Unicode object to a wide character string.

   - If w is NULL: return the number of wide characters (including the
nul
     character) required to convert the unicode object. Ignore size argument.
.. */

and I believe is reimplemented in a few other places.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10542>
_______________________________________


More information about the Python-bugs-list mailing list