@@ -99,8 +99,8 @@ Copyright (c) Corporation for National Research Initiatives.
9999#endif
100100
101101/* If the compiler provides a wchar_t type we try to support it
102- through the interface functions PyUnicode_FromWideChar() and
103- PyUnicode_AsWideChar(). */
102+ through the interface functions PyUnicode_FromWideChar(),
103+ PyUnicode_AsWideChar() and PyUnicode_AsWideCharString() . */
104104
105105#ifdef HAVE_USABLE_WCHAR_T
106106# ifndef HAVE_WCHAR_H
@@ -156,6 +156,7 @@ typedef PY_UNICODE_TYPE Py_UNICODE;
156156# define PyUnicode_AsUnicode PyUnicodeUCS2_AsUnicode
157157# define PyUnicode_AsUnicodeEscapeString PyUnicodeUCS2_AsUnicodeEscapeString
158158# define PyUnicode_AsWideChar PyUnicodeUCS2_AsWideChar
159+ # define PyUnicode_AsWideCharString PyUnicodeUCS2_AsWideCharString
159160# define PyUnicode_ClearFreeList PyUnicodeUCS2_ClearFreelist
160161# define PyUnicode_Compare PyUnicodeUCS2_Compare
161162# define PyUnicode_CompareWithASCII PyUnicodeUCS2_CompareASCII
@@ -239,6 +240,7 @@ typedef PY_UNICODE_TYPE Py_UNICODE;
239240# define PyUnicode_AsUnicode PyUnicodeUCS4_AsUnicode
240241# define PyUnicode_AsUnicodeEscapeString PyUnicodeUCS4_AsUnicodeEscapeString
241242# define PyUnicode_AsWideChar PyUnicodeUCS4_AsWideChar
243+ # define PyUnicode_AsWideCharString PyUnicodeUCS4_AsWideCharString
242244# define PyUnicode_ClearFreeList PyUnicodeUCS4_ClearFreelist
243245# define PyUnicode_Compare PyUnicodeUCS4_Compare
244246# define PyUnicode_CompareWithASCII PyUnicodeUCS4_CompareWithASCII
@@ -570,6 +572,19 @@ PyAPI_FUNC(Py_ssize_t) PyUnicode_AsWideChar(
570572 Py_ssize_t size /* size of buffer */
571573 );
572574
575+ /* Convert the Unicode object to a wide character string. The output string
576+ always ends with a nul character. If size is not NULL, write the number of
577+ wide characters (including the nul character) into *size.
578+
579+ Returns a buffer allocated by PyMem_Alloc() (use PyMem_Free() to free it)
580+ on success. On error, returns NULL, *size is undefined and raises a
581+ MemoryError. */
582+
583+ PyAPI_FUNC (wchar_t * ) PyUnicode_AsWideCharString (
584+ PyUnicodeObject * unicode , /* Unicode object */
585+ Py_ssize_t * size /* number of characters of the result */
586+ );
587+
573588#endif
574589
575590/* --- Unicode ordinals --------------------------------------------------- */
0 commit comments