This type represents a 16-bit unsigned storage type which is used by
Python internally as basis for holding Unicode ordinals. On
platforms where wchar_t is available and also has 16-bits,
Py_UNICODE is a typedef alias for wchar_t to enhance
native platform compatibility. On all other platforms,
Py_UNICODE is a typedef alias for unsigned short.
Returns a pointer to the internal buffer of the object.
o has to be a PyUnicodeObject (not checked).
Unicode provides many different character properties. The most often
needed ones are available through these macros which are mapped to C
functions depending on the Python configuration.
Create a Unicode Object from the Py_UNICODE buffer u of the
given size. u may be NULL which causes the contents to be
undefined. It is the user's responsibility to fill in the needed
data. The buffer is copied into the new object. If the buffer is
not NULL, the return value might be a shared object. Therefore,
modification of the resulting Unicode object is only allowed when
u is NULL.
Coerce an encoded object obj to an Unicode object and return a
reference with incremented refcount.
Coercion is done in the following way:
Unicode objects are passed back as-is with incremented
refcount. Note:
These cannot be decoded; passing a non-NULL
value for encoding will result in a TypeError.
String and other char buffer compatible objects are decoded
according to the given encoding and using the error handling
defined by errors. Both can be NULL to have the interface
use the default values (see the next section for details).
All other objects cause an exception.
The API returns NULL if there was an error. The caller is
responsible for decref'ing the returned objects.
Shortcut for PyUnicode_FromEncodedObject(obj, NULL, "strict")
which is used throughout the interpreter whenever coercion to
Unicode is needed.
If the platform supports wchar_t and provides a header file
wchar.h, Python can interface directly to this type using the
following functions. Support is optimized if Python's own
Py_UNICODE type is identical to the system's wchar_t.
Copies the Unicode object contents into the whcar_t buffer
w. At most sizewhcar_t characters are copied.
Returns the number of whcar_t characters copied or -1 in
case of an error.