\item[\samp{z\#} (string or \code{None}) {[char *, int]}]
This is to \samp{s\#} as \samp{z} is to \samp{s}.
+\item[\samp{u} (Unicode string) {[Py_UNICODE *]}]
+Convert a Python Unicode object to a C pointer to a null-terminated
+buffer of Unicode (UCS-2) data. As with \samp{s}, there is no need
+to provide storage for the Unicode data buffer; a pointer to the
+existing Unicode data is stored into the Py_UNICODE pointer variable whose
+address you pass.
+
+\item[\samp{u\#} (Unicode string) {[Py_UNICODE *, int]}]
+This variant on \samp{u} stores into two C variables, the first one
+a pointer to a Unicode data buffer, the second one its length.
+
\item[\samp{b} (integer) {[char]}]
Convert a Python integer to a tiny int, stored in a C \ctype{char}.
Raises \exception{TypeError} if the object is not a string object.
The C variable may also be declared as \ctype{PyObject *}.
+\item[\samp{U} (Unicode string) {[PyUnicodeObject *]}]
+Like \samp{O} but requires that the Python object is a Unicode object.
+Raises \exception{TypeError} if the object is not a Unicode object.
+The C variable may also be declared as \ctype{PyObject *}.
+
\item[\samp{t\#} (read-only character buffer) {[char *, int]}]
Like \samp{s\#}, but accepts any object which implements the read-only
buffer interface. The \ctype{char *} variable is set to point to the
Unicode object. If the Unicode buffer pointer is \NULL, the length
is ignored and \code{None} is returned.
+\item[\samp{u} (Unicode string) {[Py_UNICODE *]}]
+Convert a null-terminated buffer of Unicode (UCS-2) data to a Python Unicode
+object. If the Unicode buffer pointer is \NULL{}, \code{None} is returned.
+
+\item[\samp{u\#} (Unicode string) {[Py_UNICODE *, int]}]
+Convert a Unicode (UCS-2) data buffer and its length to a Python Unicode
+object. If the Unicode buffer pointer is \NULL{}, the length is ignored and
+\code{None} is returned.
+
\item[\samp{i} (integer) {[int]}]
Convert a plain C \ctype{int} to a Python integer object.
\item[\samp{S} (object) {[PyObject *]}]
Same as \samp{O}.
+\item[\samp{U} (object) {[PyObject *]}]
+Same as \samp{O}.
+
\item[\samp{N} (object) {[PyObject *]}]
Same as \samp{O}, except it doesn't increment the reference count on
the object. Useful when the object is created by a call to an object
break;
}
+ case 'u': /* raw unicode buffer (Py_UNICODE *) */
+ {
+ if (*format == '#') { /* any buffer-like object */
+ void **p = (void **)va_arg(*p_va, char **);
+ PyBufferProcs *pb = arg->ob_type->tp_as_buffer;
+ int *q = va_arg(*p_va, int *);
+ int count;
+
+ if ( pb == NULL ||
+ pb->bf_getreadbuffer == NULL ||
+ pb->bf_getsegcount == NULL )
+ return "read-only buffer";
+ if ( (*pb->bf_getsegcount)(arg, NULL) != 1 )
+ return "single-segment read-only buffer";
+ if ( (count =
+ (*pb->bf_getreadbuffer)(arg, 0, p)) < 0 )
+ return "(unspecified)";
+ /* buffer interface returns bytes, we want
+ length in characters */
+ *q = count/(sizeof(Py_UNICODE));
+ format++;
+ } else {
+ Py_UNICODE **p = va_arg(*p_va, Py_UNICODE **);
+
+ if (PyUnicode_Check(arg))
+ *p = PyUnicode_AS_UNICODE(arg);
+ else
+ return "unicode";
+ }
+ break;
+ }
+
case 'S': /* string object */
{
PyObject **p = va_arg(*p_va, PyObject **);