jpayne@69: #ifndef Py_UNICODEOBJECT_H jpayne@69: #define Py_UNICODEOBJECT_H jpayne@69: jpayne@69: #include jpayne@69: jpayne@69: /* jpayne@69: jpayne@69: Unicode implementation based on original code by Fredrik Lundh, jpayne@69: modified by Marc-Andre Lemburg (mal@lemburg.com) according to the jpayne@69: Unicode Integration Proposal. (See jpayne@69: http://www.egenix.com/files/python/unicode-proposal.txt). jpayne@69: jpayne@69: Copyright (c) Corporation for National Research Initiatives. jpayne@69: jpayne@69: jpayne@69: Original header: jpayne@69: -------------------------------------------------------------------- jpayne@69: jpayne@69: * Yet another Unicode string type for Python. This type supports the jpayne@69: * 16-bit Basic Multilingual Plane (BMP) only. jpayne@69: * jpayne@69: * Written by Fredrik Lundh, January 1999. jpayne@69: * jpayne@69: * Copyright (c) 1999 by Secret Labs AB. jpayne@69: * Copyright (c) 1999 by Fredrik Lundh. jpayne@69: * jpayne@69: * fredrik@pythonware.com jpayne@69: * http://www.pythonware.com jpayne@69: * jpayne@69: * -------------------------------------------------------------------- jpayne@69: * This Unicode String Type is jpayne@69: * jpayne@69: * Copyright (c) 1999 by Secret Labs AB jpayne@69: * Copyright (c) 1999 by Fredrik Lundh jpayne@69: * jpayne@69: * By obtaining, using, and/or copying this software and/or its jpayne@69: * associated documentation, you agree that you have read, understood, jpayne@69: * and will comply with the following terms and conditions: jpayne@69: * jpayne@69: * Permission to use, copy, modify, and distribute this software and its jpayne@69: * associated documentation for any purpose and without fee is hereby jpayne@69: * granted, provided that the above copyright notice appears in all jpayne@69: * copies, and that both that copyright notice and this permission notice jpayne@69: * appear in supporting documentation, and that the name of Secret Labs jpayne@69: * AB or the author not be used in advertising or publicity pertaining to jpayne@69: * distribution of the software without specific, written prior jpayne@69: * permission. jpayne@69: * jpayne@69: * SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO jpayne@69: * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND jpayne@69: * FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR BE LIABLE FOR jpayne@69: * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES jpayne@69: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN jpayne@69: * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT jpayne@69: * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. jpayne@69: * -------------------------------------------------------------------- */ jpayne@69: jpayne@69: #include jpayne@69: jpayne@69: /* === Internal API ======================================================= */ jpayne@69: jpayne@69: /* --- Internal Unicode Format -------------------------------------------- */ jpayne@69: jpayne@69: /* Python 3.x requires unicode */ jpayne@69: #define Py_USING_UNICODE jpayne@69: jpayne@69: #ifndef SIZEOF_WCHAR_T jpayne@69: #error Must define SIZEOF_WCHAR_T jpayne@69: #endif jpayne@69: jpayne@69: #define Py_UNICODE_SIZE SIZEOF_WCHAR_T jpayne@69: jpayne@69: /* If wchar_t can be used for UCS-4 storage, set Py_UNICODE_WIDE. jpayne@69: Otherwise, Unicode strings are stored as UCS-2 (with limited support jpayne@69: for UTF-16) */ jpayne@69: jpayne@69: #if Py_UNICODE_SIZE >= 4 jpayne@69: #define Py_UNICODE_WIDE jpayne@69: #endif jpayne@69: jpayne@69: /* Set these flags if the platform has "wchar.h" and the jpayne@69: wchar_t type is a 16-bit unsigned type */ jpayne@69: /* #define HAVE_WCHAR_H */ jpayne@69: /* #define HAVE_USABLE_WCHAR_T */ jpayne@69: jpayne@69: /* If the compiler provides a wchar_t type we try to support it jpayne@69: through the interface functions PyUnicode_FromWideChar(), jpayne@69: PyUnicode_AsWideChar() and PyUnicode_AsWideCharString(). */ jpayne@69: jpayne@69: #ifdef HAVE_USABLE_WCHAR_T jpayne@69: # ifndef HAVE_WCHAR_H jpayne@69: # define HAVE_WCHAR_H jpayne@69: # endif jpayne@69: #endif jpayne@69: jpayne@69: #ifdef HAVE_WCHAR_H jpayne@69: # include jpayne@69: #endif jpayne@69: jpayne@69: /* Py_UCS4 and Py_UCS2 are typedefs for the respective jpayne@69: unicode representations. */ jpayne@69: typedef uint32_t Py_UCS4; jpayne@69: typedef uint16_t Py_UCS2; jpayne@69: typedef uint8_t Py_UCS1; jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: jpayne@69: jpayne@69: PyAPI_DATA(PyTypeObject) PyUnicode_Type; jpayne@69: PyAPI_DATA(PyTypeObject) PyUnicodeIter_Type; jpayne@69: jpayne@69: #define PyUnicode_Check(op) \ jpayne@69: PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_UNICODE_SUBCLASS) jpayne@69: #define PyUnicode_CheckExact(op) (Py_TYPE(op) == &PyUnicode_Type) jpayne@69: jpayne@69: /* --- Constants ---------------------------------------------------------- */ jpayne@69: jpayne@69: /* This Unicode character will be used as replacement character during jpayne@69: decoding if the errors argument is set to "replace". Note: the jpayne@69: Unicode character U+FFFD is the official REPLACEMENT CHARACTER in jpayne@69: Unicode 3.0. */ jpayne@69: jpayne@69: #define Py_UNICODE_REPLACEMENT_CHARACTER ((Py_UCS4) 0xFFFD) jpayne@69: jpayne@69: /* === Public API ========================================================= */ jpayne@69: jpayne@69: /* Similar to PyUnicode_FromUnicode(), but u points to UTF-8 encoded bytes */ jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_FromStringAndSize( jpayne@69: const char *u, /* UTF-8 encoded string */ jpayne@69: Py_ssize_t size /* size of buffer */ jpayne@69: ); jpayne@69: jpayne@69: /* Similar to PyUnicode_FromUnicode(), but u points to null-terminated jpayne@69: UTF-8 encoded bytes. The size is determined with strlen(). */ jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_FromString( jpayne@69: const char *u /* UTF-8 encoded string */ jpayne@69: ); jpayne@69: jpayne@69: #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_Substring( jpayne@69: PyObject *str, jpayne@69: Py_ssize_t start, jpayne@69: Py_ssize_t end); jpayne@69: #endif jpayne@69: jpayne@69: #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 jpayne@69: /* Copy the string into a UCS4 buffer including the null character if copy_null jpayne@69: is set. Return NULL and raise an exception on error. Raise a SystemError if jpayne@69: the buffer is smaller than the string. Return buffer on success. jpayne@69: jpayne@69: buflen is the length of the buffer in (Py_UCS4) characters. */ jpayne@69: PyAPI_FUNC(Py_UCS4*) PyUnicode_AsUCS4( jpayne@69: PyObject *unicode, jpayne@69: Py_UCS4* buffer, jpayne@69: Py_ssize_t buflen, jpayne@69: int copy_null); jpayne@69: jpayne@69: /* Copy the string into a UCS4 buffer. A new buffer is allocated using jpayne@69: * PyMem_Malloc; if this fails, NULL is returned with a memory error jpayne@69: exception set. */ jpayne@69: PyAPI_FUNC(Py_UCS4*) PyUnicode_AsUCS4Copy(PyObject *unicode); jpayne@69: #endif jpayne@69: jpayne@69: #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 jpayne@69: /* Get the length of the Unicode object. */ jpayne@69: jpayne@69: PyAPI_FUNC(Py_ssize_t) PyUnicode_GetLength( jpayne@69: PyObject *unicode jpayne@69: ); jpayne@69: #endif jpayne@69: jpayne@69: /* Get the number of Py_UNICODE units in the jpayne@69: string representation. */ jpayne@69: jpayne@69: Py_DEPRECATED(3.3) PyAPI_FUNC(Py_ssize_t) PyUnicode_GetSize( jpayne@69: PyObject *unicode /* Unicode object */ jpayne@69: ); jpayne@69: jpayne@69: #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 jpayne@69: /* Read a character from the string. */ jpayne@69: jpayne@69: PyAPI_FUNC(Py_UCS4) PyUnicode_ReadChar( jpayne@69: PyObject *unicode, jpayne@69: Py_ssize_t index jpayne@69: ); jpayne@69: jpayne@69: /* Write a character to the string. The string must have been created through jpayne@69: PyUnicode_New, must not be shared, and must not have been hashed yet. jpayne@69: jpayne@69: Return 0 on success, -1 on error. */ jpayne@69: jpayne@69: PyAPI_FUNC(int) PyUnicode_WriteChar( jpayne@69: PyObject *unicode, jpayne@69: Py_ssize_t index, jpayne@69: Py_UCS4 character jpayne@69: ); jpayne@69: #endif jpayne@69: jpayne@69: /* Resize a Unicode object. The length is the number of characters, except jpayne@69: if the kind of the string is PyUnicode_WCHAR_KIND: in this case, the length jpayne@69: is the number of Py_UNICODE characters. jpayne@69: jpayne@69: *unicode is modified to point to the new (resized) object and 0 jpayne@69: returned on success. jpayne@69: jpayne@69: Try to resize the string in place (which is usually faster than allocating jpayne@69: a new string and copy characters), or create a new string. jpayne@69: jpayne@69: Error handling is implemented as follows: an exception is set, -1 jpayne@69: is returned and *unicode left untouched. jpayne@69: jpayne@69: WARNING: The function doesn't check string content, the result may not be a jpayne@69: string in canonical representation. */ jpayne@69: jpayne@69: PyAPI_FUNC(int) PyUnicode_Resize( jpayne@69: PyObject **unicode, /* Pointer to the Unicode object */ jpayne@69: Py_ssize_t length /* New length */ jpayne@69: ); jpayne@69: jpayne@69: /* Decode obj to a Unicode object. jpayne@69: jpayne@69: bytes, bytearray and other bytes-like objects are decoded according to the jpayne@69: given encoding and error handler. The encoding and error handler can be jpayne@69: NULL to have the interface use UTF-8 and "strict". jpayne@69: jpayne@69: All other objects (including Unicode objects) raise an exception. jpayne@69: jpayne@69: The API returns NULL in case of an error. The caller is responsible jpayne@69: for decref'ing the returned objects. jpayne@69: jpayne@69: */ jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_FromEncodedObject( jpayne@69: PyObject *obj, /* Object */ jpayne@69: const char *encoding, /* encoding */ jpayne@69: const char *errors /* error handling */ jpayne@69: ); jpayne@69: jpayne@69: /* Copy an instance of a Unicode subtype to a new true Unicode object if jpayne@69: necessary. If obj is already a true Unicode object (not a subtype), return jpayne@69: the reference with *incremented* refcount. jpayne@69: jpayne@69: The API returns NULL in case of an error. The caller is responsible jpayne@69: for decref'ing the returned objects. jpayne@69: jpayne@69: */ jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_FromObject( jpayne@69: PyObject *obj /* Object */ jpayne@69: ); jpayne@69: jpayne@69: PyAPI_FUNC(PyObject *) PyUnicode_FromFormatV( jpayne@69: const char *format, /* ASCII-encoded string */ jpayne@69: va_list vargs jpayne@69: ); jpayne@69: PyAPI_FUNC(PyObject *) PyUnicode_FromFormat( jpayne@69: const char *format, /* ASCII-encoded string */ jpayne@69: ... jpayne@69: ); jpayne@69: jpayne@69: PyAPI_FUNC(void) PyUnicode_InternInPlace(PyObject **); jpayne@69: PyAPI_FUNC(void) PyUnicode_InternImmortal(PyObject **); jpayne@69: PyAPI_FUNC(PyObject *) PyUnicode_InternFromString( jpayne@69: const char *u /* UTF-8 encoded string */ jpayne@69: ); jpayne@69: jpayne@69: /* Use only if you know it's a string */ jpayne@69: #define PyUnicode_CHECK_INTERNED(op) \ jpayne@69: (((PyASCIIObject *)(op))->state.interned) jpayne@69: jpayne@69: /* --- wchar_t support for platforms which support it --------------------- */ jpayne@69: jpayne@69: #ifdef HAVE_WCHAR_H jpayne@69: jpayne@69: /* Create a Unicode Object from the wchar_t buffer w of the given jpayne@69: size. jpayne@69: jpayne@69: The buffer is copied into the new object. */ jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_FromWideChar( jpayne@69: const wchar_t *w, /* wchar_t buffer */ jpayne@69: Py_ssize_t size /* size of buffer */ jpayne@69: ); jpayne@69: jpayne@69: /* Copies the Unicode Object contents into the wchar_t buffer w. At jpayne@69: most size wchar_t characters are copied. jpayne@69: jpayne@69: Note that the resulting wchar_t string may or may not be jpayne@69: 0-terminated. It is the responsibility of the caller to make sure jpayne@69: that the wchar_t string is 0-terminated in case this is required by jpayne@69: the application. jpayne@69: jpayne@69: Returns the number of wchar_t characters copied (excluding a jpayne@69: possibly trailing 0-termination character) or -1 in case of an jpayne@69: error. */ jpayne@69: jpayne@69: PyAPI_FUNC(Py_ssize_t) PyUnicode_AsWideChar( jpayne@69: PyObject *unicode, /* Unicode object */ jpayne@69: wchar_t *w, /* wchar_t buffer */ jpayne@69: Py_ssize_t size /* size of buffer */ jpayne@69: ); jpayne@69: jpayne@69: /* Convert the Unicode object to a wide character string. The output string jpayne@69: always ends with a nul character. If size is not NULL, write the number of jpayne@69: wide characters (excluding the null character) into *size. jpayne@69: jpayne@69: Returns a buffer allocated by PyMem_Malloc() (use PyMem_Free() to free it) jpayne@69: on success. On error, returns NULL, *size is undefined and raises a jpayne@69: MemoryError. */ jpayne@69: jpayne@69: PyAPI_FUNC(wchar_t*) PyUnicode_AsWideCharString( jpayne@69: PyObject *unicode, /* Unicode object */ jpayne@69: Py_ssize_t *size /* number of characters of the result */ jpayne@69: ); jpayne@69: jpayne@69: #endif jpayne@69: jpayne@69: /* --- Unicode ordinals --------------------------------------------------- */ jpayne@69: jpayne@69: /* Create a Unicode Object from the given Unicode code point ordinal. jpayne@69: jpayne@69: The ordinal must be in range(0x110000). A ValueError is jpayne@69: raised in case it is not. jpayne@69: jpayne@69: */ jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_FromOrdinal(int ordinal); jpayne@69: jpayne@69: /* --- Free-list management ----------------------------------------------- */ jpayne@69: jpayne@69: /* Clear the free list used by the Unicode implementation. jpayne@69: jpayne@69: This can be used to release memory used for objects on the free jpayne@69: list back to the Python memory allocator. jpayne@69: jpayne@69: */ jpayne@69: jpayne@69: PyAPI_FUNC(int) PyUnicode_ClearFreeList(void); jpayne@69: jpayne@69: /* === Builtin Codecs ===================================================== jpayne@69: jpayne@69: Many of these APIs take two arguments encoding and errors. These jpayne@69: parameters encoding and errors have the same semantics as the ones jpayne@69: of the builtin str() API. jpayne@69: jpayne@69: Setting encoding to NULL causes the default encoding (UTF-8) to be used. jpayne@69: jpayne@69: Error handling is set by errors which may also be set to NULL jpayne@69: meaning to use the default handling defined for the codec. Default jpayne@69: error handling for all builtin codecs is "strict" (ValueErrors are jpayne@69: raised). jpayne@69: jpayne@69: The codecs all use a similar interface. Only deviation from the jpayne@69: generic ones are documented. jpayne@69: jpayne@69: */ jpayne@69: jpayne@69: /* --- Manage the default encoding ---------------------------------------- */ jpayne@69: jpayne@69: /* Returns "utf-8". */ jpayne@69: PyAPI_FUNC(const char*) PyUnicode_GetDefaultEncoding(void); jpayne@69: jpayne@69: /* --- Generic Codecs ----------------------------------------------------- */ jpayne@69: jpayne@69: /* Create a Unicode object by decoding the encoded string s of the jpayne@69: given size. */ jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_Decode( jpayne@69: const char *s, /* encoded string */ jpayne@69: Py_ssize_t size, /* size of buffer */ jpayne@69: const char *encoding, /* encoding */ jpayne@69: const char *errors /* error handling */ jpayne@69: ); jpayne@69: jpayne@69: /* Decode a Unicode object unicode and return the result as Python jpayne@69: object. jpayne@69: jpayne@69: This API is DEPRECATED. The only supported standard encoding is rot13. jpayne@69: Use PyCodec_Decode() to decode with rot13 and non-standard codecs jpayne@69: that decode from str. */ jpayne@69: jpayne@69: Py_DEPRECATED(3.6) PyAPI_FUNC(PyObject*) PyUnicode_AsDecodedObject( jpayne@69: PyObject *unicode, /* Unicode object */ jpayne@69: const char *encoding, /* encoding */ jpayne@69: const char *errors /* error handling */ jpayne@69: ); jpayne@69: jpayne@69: /* Decode a Unicode object unicode and return the result as Unicode jpayne@69: object. jpayne@69: jpayne@69: This API is DEPRECATED. The only supported standard encoding is rot13. jpayne@69: Use PyCodec_Decode() to decode with rot13 and non-standard codecs jpayne@69: that decode from str to str. */ jpayne@69: jpayne@69: Py_DEPRECATED(3.6) PyAPI_FUNC(PyObject*) PyUnicode_AsDecodedUnicode( jpayne@69: PyObject *unicode, /* Unicode object */ jpayne@69: const char *encoding, /* encoding */ jpayne@69: const char *errors /* error handling */ jpayne@69: ); jpayne@69: jpayne@69: /* Encodes a Unicode object and returns the result as Python jpayne@69: object. jpayne@69: jpayne@69: This API is DEPRECATED. It is superseded by PyUnicode_AsEncodedString() jpayne@69: since all standard encodings (except rot13) encode str to bytes. jpayne@69: Use PyCodec_Encode() for encoding with rot13 and non-standard codecs jpayne@69: that encode form str to non-bytes. */ jpayne@69: jpayne@69: Py_DEPRECATED(3.6) PyAPI_FUNC(PyObject*) PyUnicode_AsEncodedObject( jpayne@69: PyObject *unicode, /* Unicode object */ jpayne@69: const char *encoding, /* encoding */ jpayne@69: const char *errors /* error handling */ jpayne@69: ); jpayne@69: jpayne@69: /* Encodes a Unicode object and returns the result as Python string jpayne@69: object. */ jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_AsEncodedString( jpayne@69: PyObject *unicode, /* Unicode object */ jpayne@69: const char *encoding, /* encoding */ jpayne@69: const char *errors /* error handling */ jpayne@69: ); jpayne@69: jpayne@69: /* Encodes a Unicode object and returns the result as Unicode jpayne@69: object. jpayne@69: jpayne@69: This API is DEPRECATED. The only supported standard encodings is rot13. jpayne@69: Use PyCodec_Encode() to encode with rot13 and non-standard codecs jpayne@69: that encode from str to str. */ jpayne@69: jpayne@69: Py_DEPRECATED(3.6) PyAPI_FUNC(PyObject*) PyUnicode_AsEncodedUnicode( jpayne@69: PyObject *unicode, /* Unicode object */ jpayne@69: const char *encoding, /* encoding */ jpayne@69: const char *errors /* error handling */ jpayne@69: ); jpayne@69: jpayne@69: /* Build an encoding map. */ jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_BuildEncodingMap( jpayne@69: PyObject* string /* 256 character map */ jpayne@69: ); jpayne@69: jpayne@69: /* --- UTF-7 Codecs ------------------------------------------------------- */ jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF7( jpayne@69: const char *string, /* UTF-7 encoded string */ jpayne@69: Py_ssize_t length, /* size of string */ jpayne@69: const char *errors /* error handling */ jpayne@69: ); jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF7Stateful( jpayne@69: const char *string, /* UTF-7 encoded string */ jpayne@69: Py_ssize_t length, /* size of string */ jpayne@69: const char *errors, /* error handling */ jpayne@69: Py_ssize_t *consumed /* bytes consumed */ jpayne@69: ); jpayne@69: jpayne@69: /* --- UTF-8 Codecs ------------------------------------------------------- */ jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF8( jpayne@69: const char *string, /* UTF-8 encoded string */ jpayne@69: Py_ssize_t length, /* size of string */ jpayne@69: const char *errors /* error handling */ jpayne@69: ); jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF8Stateful( jpayne@69: const char *string, /* UTF-8 encoded string */ jpayne@69: Py_ssize_t length, /* size of string */ jpayne@69: const char *errors, /* error handling */ jpayne@69: Py_ssize_t *consumed /* bytes consumed */ jpayne@69: ); jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_AsUTF8String( jpayne@69: PyObject *unicode /* Unicode object */ jpayne@69: ); jpayne@69: jpayne@69: /* --- UTF-32 Codecs ------------------------------------------------------ */ jpayne@69: jpayne@69: /* Decodes length bytes from a UTF-32 encoded buffer string and returns jpayne@69: the corresponding Unicode object. jpayne@69: jpayne@69: errors (if non-NULL) defines the error handling. It defaults jpayne@69: to "strict". jpayne@69: jpayne@69: If byteorder is non-NULL, the decoder starts decoding using the jpayne@69: given byte order: jpayne@69: jpayne@69: *byteorder == -1: little endian jpayne@69: *byteorder == 0: native order jpayne@69: *byteorder == 1: big endian jpayne@69: jpayne@69: In native mode, the first four bytes of the stream are checked for a jpayne@69: BOM mark. If found, the BOM mark is analysed, the byte order jpayne@69: adjusted and the BOM skipped. In the other modes, no BOM mark jpayne@69: interpretation is done. After completion, *byteorder is set to the jpayne@69: current byte order at the end of input data. jpayne@69: jpayne@69: If byteorder is NULL, the codec starts in native order mode. jpayne@69: jpayne@69: */ jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF32( jpayne@69: const char *string, /* UTF-32 encoded string */ jpayne@69: Py_ssize_t length, /* size of string */ jpayne@69: const char *errors, /* error handling */ jpayne@69: int *byteorder /* pointer to byteorder to use jpayne@69: 0=native;-1=LE,1=BE; updated on jpayne@69: exit */ jpayne@69: ); jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF32Stateful( jpayne@69: const char *string, /* UTF-32 encoded string */ jpayne@69: Py_ssize_t length, /* size of string */ jpayne@69: const char *errors, /* error handling */ jpayne@69: int *byteorder, /* pointer to byteorder to use jpayne@69: 0=native;-1=LE,1=BE; updated on jpayne@69: exit */ jpayne@69: Py_ssize_t *consumed /* bytes consumed */ jpayne@69: ); jpayne@69: jpayne@69: /* Returns a Python string using the UTF-32 encoding in native byte jpayne@69: order. The string always starts with a BOM mark. */ jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_AsUTF32String( jpayne@69: PyObject *unicode /* Unicode object */ jpayne@69: ); jpayne@69: jpayne@69: /* Returns a Python string object holding the UTF-32 encoded value of jpayne@69: the Unicode data. jpayne@69: jpayne@69: If byteorder is not 0, output is written according to the following jpayne@69: byte order: jpayne@69: jpayne@69: byteorder == -1: little endian jpayne@69: byteorder == 0: native byte order (writes a BOM mark) jpayne@69: byteorder == 1: big endian jpayne@69: jpayne@69: If byteorder is 0, the output string will always start with the jpayne@69: Unicode BOM mark (U+FEFF). In the other two modes, no BOM mark is jpayne@69: prepended. jpayne@69: jpayne@69: */ jpayne@69: jpayne@69: /* --- UTF-16 Codecs ------------------------------------------------------ */ jpayne@69: jpayne@69: /* Decodes length bytes from a UTF-16 encoded buffer string and returns jpayne@69: the corresponding Unicode object. jpayne@69: jpayne@69: errors (if non-NULL) defines the error handling. It defaults jpayne@69: to "strict". jpayne@69: jpayne@69: If byteorder is non-NULL, the decoder starts decoding using the jpayne@69: given byte order: jpayne@69: jpayne@69: *byteorder == -1: little endian jpayne@69: *byteorder == 0: native order jpayne@69: *byteorder == 1: big endian jpayne@69: jpayne@69: In native mode, the first two bytes of the stream are checked for a jpayne@69: BOM mark. If found, the BOM mark is analysed, the byte order jpayne@69: adjusted and the BOM skipped. In the other modes, no BOM mark jpayne@69: interpretation is done. After completion, *byteorder is set to the jpayne@69: current byte order at the end of input data. jpayne@69: jpayne@69: If byteorder is NULL, the codec starts in native order mode. jpayne@69: jpayne@69: */ jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF16( jpayne@69: const char *string, /* UTF-16 encoded string */ jpayne@69: Py_ssize_t length, /* size of string */ jpayne@69: const char *errors, /* error handling */ jpayne@69: int *byteorder /* pointer to byteorder to use jpayne@69: 0=native;-1=LE,1=BE; updated on jpayne@69: exit */ jpayne@69: ); jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF16Stateful( jpayne@69: const char *string, /* UTF-16 encoded string */ jpayne@69: Py_ssize_t length, /* size of string */ jpayne@69: const char *errors, /* error handling */ jpayne@69: int *byteorder, /* pointer to byteorder to use jpayne@69: 0=native;-1=LE,1=BE; updated on jpayne@69: exit */ jpayne@69: Py_ssize_t *consumed /* bytes consumed */ jpayne@69: ); jpayne@69: jpayne@69: /* Returns a Python string using the UTF-16 encoding in native byte jpayne@69: order. The string always starts with a BOM mark. */ jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_AsUTF16String( jpayne@69: PyObject *unicode /* Unicode object */ jpayne@69: ); jpayne@69: jpayne@69: /* --- Unicode-Escape Codecs ---------------------------------------------- */ jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_DecodeUnicodeEscape( jpayne@69: const char *string, /* Unicode-Escape encoded string */ jpayne@69: Py_ssize_t length, /* size of string */ jpayne@69: const char *errors /* error handling */ jpayne@69: ); jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_AsUnicodeEscapeString( jpayne@69: PyObject *unicode /* Unicode object */ jpayne@69: ); jpayne@69: jpayne@69: /* --- Raw-Unicode-Escape Codecs ------------------------------------------ */ jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_DecodeRawUnicodeEscape( jpayne@69: const char *string, /* Raw-Unicode-Escape encoded string */ jpayne@69: Py_ssize_t length, /* size of string */ jpayne@69: const char *errors /* error handling */ jpayne@69: ); jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_AsRawUnicodeEscapeString( jpayne@69: PyObject *unicode /* Unicode object */ jpayne@69: ); jpayne@69: jpayne@69: /* --- Latin-1 Codecs ----------------------------------------------------- jpayne@69: jpayne@69: Note: Latin-1 corresponds to the first 256 Unicode ordinals. */ jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_DecodeLatin1( jpayne@69: const char *string, /* Latin-1 encoded string */ jpayne@69: Py_ssize_t length, /* size of string */ jpayne@69: const char *errors /* error handling */ jpayne@69: ); jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_AsLatin1String( jpayne@69: PyObject *unicode /* Unicode object */ jpayne@69: ); jpayne@69: jpayne@69: /* --- ASCII Codecs ------------------------------------------------------- jpayne@69: jpayne@69: Only 7-bit ASCII data is excepted. All other codes generate errors. jpayne@69: jpayne@69: */ jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_DecodeASCII( jpayne@69: const char *string, /* ASCII encoded string */ jpayne@69: Py_ssize_t length, /* size of string */ jpayne@69: const char *errors /* error handling */ jpayne@69: ); jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_AsASCIIString( jpayne@69: PyObject *unicode /* Unicode object */ jpayne@69: ); jpayne@69: jpayne@69: /* --- Character Map Codecs ----------------------------------------------- jpayne@69: jpayne@69: This codec uses mappings to encode and decode characters. jpayne@69: jpayne@69: Decoding mappings must map byte ordinals (integers in the range from 0 to jpayne@69: 255) to Unicode strings, integers (which are then interpreted as Unicode jpayne@69: ordinals) or None. Unmapped data bytes (ones which cause a LookupError) jpayne@69: as well as mapped to None, 0xFFFE or '\ufffe' are treated as "undefined jpayne@69: mapping" and cause an error. jpayne@69: jpayne@69: Encoding mappings must map Unicode ordinal integers to bytes objects, jpayne@69: integers in the range from 0 to 255 or None. Unmapped character jpayne@69: ordinals (ones which cause a LookupError) as well as mapped to jpayne@69: None are treated as "undefined mapping" and cause an error. jpayne@69: jpayne@69: */ jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_DecodeCharmap( jpayne@69: const char *string, /* Encoded string */ jpayne@69: Py_ssize_t length, /* size of string */ jpayne@69: PyObject *mapping, /* decoding mapping */ jpayne@69: const char *errors /* error handling */ jpayne@69: ); jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_AsCharmapString( jpayne@69: PyObject *unicode, /* Unicode object */ jpayne@69: PyObject *mapping /* encoding mapping */ jpayne@69: ); jpayne@69: jpayne@69: /* --- MBCS codecs for Windows -------------------------------------------- */ jpayne@69: jpayne@69: #ifdef MS_WINDOWS jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_DecodeMBCS( jpayne@69: const char *string, /* MBCS encoded string */ jpayne@69: Py_ssize_t length, /* size of string */ jpayne@69: const char *errors /* error handling */ jpayne@69: ); jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_DecodeMBCSStateful( jpayne@69: const char *string, /* MBCS encoded string */ jpayne@69: Py_ssize_t length, /* size of string */ jpayne@69: const char *errors, /* error handling */ jpayne@69: Py_ssize_t *consumed /* bytes consumed */ jpayne@69: ); jpayne@69: jpayne@69: #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_DecodeCodePageStateful( jpayne@69: int code_page, /* code page number */ jpayne@69: const char *string, /* encoded string */ jpayne@69: Py_ssize_t length, /* size of string */ jpayne@69: const char *errors, /* error handling */ jpayne@69: Py_ssize_t *consumed /* bytes consumed */ jpayne@69: ); jpayne@69: #endif jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_AsMBCSString( jpayne@69: PyObject *unicode /* Unicode object */ jpayne@69: ); jpayne@69: jpayne@69: #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_EncodeCodePage( jpayne@69: int code_page, /* code page number */ jpayne@69: PyObject *unicode, /* Unicode object */ jpayne@69: const char *errors /* error handling */ jpayne@69: ); jpayne@69: #endif jpayne@69: jpayne@69: #endif /* MS_WINDOWS */ jpayne@69: jpayne@69: /* --- Locale encoding --------------------------------------------------- */ jpayne@69: jpayne@69: #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 jpayne@69: /* Decode a string from the current locale encoding. The decoder is strict if jpayne@69: *surrogateescape* is equal to zero, otherwise it uses the 'surrogateescape' jpayne@69: error handler (PEP 383) to escape undecodable bytes. If a byte sequence can jpayne@69: be decoded as a surrogate character and *surrogateescape* is not equal to jpayne@69: zero, the byte sequence is escaped using the 'surrogateescape' error handler jpayne@69: instead of being decoded. *str* must end with a null character but cannot jpayne@69: contain embedded null characters. */ jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_DecodeLocaleAndSize( jpayne@69: const char *str, jpayne@69: Py_ssize_t len, jpayne@69: const char *errors); jpayne@69: jpayne@69: /* Similar to PyUnicode_DecodeLocaleAndSize(), but compute the string jpayne@69: length using strlen(). */ jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_DecodeLocale( jpayne@69: const char *str, jpayne@69: const char *errors); jpayne@69: jpayne@69: /* Encode a Unicode object to the current locale encoding. The encoder is jpayne@69: strict is *surrogateescape* is equal to zero, otherwise the jpayne@69: "surrogateescape" error handler is used. Return a bytes object. The string jpayne@69: cannot contain embedded null characters. */ jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_EncodeLocale( jpayne@69: PyObject *unicode, jpayne@69: const char *errors jpayne@69: ); jpayne@69: #endif jpayne@69: jpayne@69: /* --- File system encoding ---------------------------------------------- */ jpayne@69: jpayne@69: /* ParseTuple converter: encode str objects to bytes using jpayne@69: PyUnicode_EncodeFSDefault(); bytes objects are output as-is. */ jpayne@69: jpayne@69: PyAPI_FUNC(int) PyUnicode_FSConverter(PyObject*, void*); jpayne@69: jpayne@69: /* ParseTuple converter: decode bytes objects to unicode using jpayne@69: PyUnicode_DecodeFSDefaultAndSize(); str objects are output as-is. */ jpayne@69: jpayne@69: PyAPI_FUNC(int) PyUnicode_FSDecoder(PyObject*, void*); jpayne@69: jpayne@69: /* Decode a null-terminated string using Py_FileSystemDefaultEncoding jpayne@69: and the "surrogateescape" error handler. jpayne@69: jpayne@69: If Py_FileSystemDefaultEncoding is not set, fall back to the locale jpayne@69: encoding. jpayne@69: jpayne@69: Use PyUnicode_DecodeFSDefaultAndSize() if the string length is known. jpayne@69: */ jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_DecodeFSDefault( jpayne@69: const char *s /* encoded string */ jpayne@69: ); jpayne@69: jpayne@69: /* Decode a string using Py_FileSystemDefaultEncoding jpayne@69: and the "surrogateescape" error handler. jpayne@69: jpayne@69: If Py_FileSystemDefaultEncoding is not set, fall back to the locale jpayne@69: encoding. jpayne@69: */ jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_DecodeFSDefaultAndSize( jpayne@69: const char *s, /* encoded string */ jpayne@69: Py_ssize_t size /* size */ jpayne@69: ); jpayne@69: jpayne@69: /* Encode a Unicode object to Py_FileSystemDefaultEncoding with the jpayne@69: "surrogateescape" error handler, and return bytes. jpayne@69: jpayne@69: If Py_FileSystemDefaultEncoding is not set, fall back to the locale jpayne@69: encoding. jpayne@69: */ jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_EncodeFSDefault( jpayne@69: PyObject *unicode jpayne@69: ); jpayne@69: jpayne@69: /* --- Methods & Slots ---------------------------------------------------- jpayne@69: jpayne@69: These are capable of handling Unicode objects and strings on input jpayne@69: (we refer to them as strings in the descriptions) and return jpayne@69: Unicode objects or integers as appropriate. */ jpayne@69: jpayne@69: /* Concat two strings giving a new Unicode string. */ jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_Concat( jpayne@69: PyObject *left, /* Left string */ jpayne@69: PyObject *right /* Right string */ jpayne@69: ); jpayne@69: jpayne@69: /* Concat two strings and put the result in *pleft jpayne@69: (sets *pleft to NULL on error) */ jpayne@69: jpayne@69: PyAPI_FUNC(void) PyUnicode_Append( jpayne@69: PyObject **pleft, /* Pointer to left string */ jpayne@69: PyObject *right /* Right string */ jpayne@69: ); jpayne@69: jpayne@69: /* Concat two strings, put the result in *pleft and drop the right object jpayne@69: (sets *pleft to NULL on error) */ jpayne@69: jpayne@69: PyAPI_FUNC(void) PyUnicode_AppendAndDel( jpayne@69: PyObject **pleft, /* Pointer to left string */ jpayne@69: PyObject *right /* Right string */ jpayne@69: ); jpayne@69: jpayne@69: /* Split a string giving a list of Unicode strings. jpayne@69: jpayne@69: If sep is NULL, splitting will be done at all whitespace jpayne@69: substrings. Otherwise, splits occur at the given separator. jpayne@69: jpayne@69: At most maxsplit splits will be done. If negative, no limit is set. jpayne@69: jpayne@69: Separators are not included in the resulting list. jpayne@69: jpayne@69: */ jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_Split( jpayne@69: PyObject *s, /* String to split */ jpayne@69: PyObject *sep, /* String separator */ jpayne@69: Py_ssize_t maxsplit /* Maxsplit count */ jpayne@69: ); jpayne@69: jpayne@69: /* Dito, but split at line breaks. jpayne@69: jpayne@69: CRLF is considered to be one line break. Line breaks are not jpayne@69: included in the resulting list. */ jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_Splitlines( jpayne@69: PyObject *s, /* String to split */ jpayne@69: int keepends /* If true, line end markers are included */ jpayne@69: ); jpayne@69: jpayne@69: /* Partition a string using a given separator. */ jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_Partition( jpayne@69: PyObject *s, /* String to partition */ jpayne@69: PyObject *sep /* String separator */ jpayne@69: ); jpayne@69: jpayne@69: /* Partition a string using a given separator, searching from the end of the jpayne@69: string. */ jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_RPartition( jpayne@69: PyObject *s, /* String to partition */ jpayne@69: PyObject *sep /* String separator */ jpayne@69: ); jpayne@69: jpayne@69: /* Split a string giving a list of Unicode strings. jpayne@69: jpayne@69: If sep is NULL, splitting will be done at all whitespace jpayne@69: substrings. Otherwise, splits occur at the given separator. jpayne@69: jpayne@69: At most maxsplit splits will be done. But unlike PyUnicode_Split jpayne@69: PyUnicode_RSplit splits from the end of the string. If negative, jpayne@69: no limit is set. jpayne@69: jpayne@69: Separators are not included in the resulting list. jpayne@69: jpayne@69: */ jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_RSplit( jpayne@69: PyObject *s, /* String to split */ jpayne@69: PyObject *sep, /* String separator */ jpayne@69: Py_ssize_t maxsplit /* Maxsplit count */ jpayne@69: ); jpayne@69: jpayne@69: /* Translate a string by applying a character mapping table to it and jpayne@69: return the resulting Unicode object. jpayne@69: jpayne@69: The mapping table must map Unicode ordinal integers to Unicode strings, jpayne@69: Unicode ordinal integers or None (causing deletion of the character). jpayne@69: jpayne@69: Mapping tables may be dictionaries or sequences. Unmapped character jpayne@69: ordinals (ones which cause a LookupError) are left untouched and jpayne@69: are copied as-is. jpayne@69: jpayne@69: */ jpayne@69: jpayne@69: PyAPI_FUNC(PyObject *) PyUnicode_Translate( jpayne@69: PyObject *str, /* String */ jpayne@69: PyObject *table, /* Translate table */ jpayne@69: const char *errors /* error handling */ jpayne@69: ); jpayne@69: jpayne@69: /* Join a sequence of strings using the given separator and return jpayne@69: the resulting Unicode string. */ jpayne@69: jpayne@69: PyAPI_FUNC(PyObject*) PyUnicode_Join( jpayne@69: PyObject *separator, /* Separator string */ jpayne@69: PyObject *seq /* Sequence object */ jpayne@69: ); jpayne@69: jpayne@69: /* Return 1 if substr matches str[start:end] at the given tail end, 0 jpayne@69: otherwise. */ jpayne@69: jpayne@69: PyAPI_FUNC(Py_ssize_t) PyUnicode_Tailmatch( jpayne@69: PyObject *str, /* String */ jpayne@69: PyObject *substr, /* Prefix or Suffix string */ jpayne@69: Py_ssize_t start, /* Start index */ jpayne@69: Py_ssize_t end, /* Stop index */ jpayne@69: int direction /* Tail end: -1 prefix, +1 suffix */ jpayne@69: ); jpayne@69: jpayne@69: /* Return the first position of substr in str[start:end] using the jpayne@69: given search direction or -1 if not found. -2 is returned in case jpayne@69: an error occurred and an exception is set. */ jpayne@69: jpayne@69: PyAPI_FUNC(Py_ssize_t) PyUnicode_Find( jpayne@69: PyObject *str, /* String */ jpayne@69: PyObject *substr, /* Substring to find */ jpayne@69: Py_ssize_t start, /* Start index */ jpayne@69: Py_ssize_t end, /* Stop index */ jpayne@69: int direction /* Find direction: +1 forward, -1 backward */ jpayne@69: ); jpayne@69: jpayne@69: #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000 jpayne@69: /* Like PyUnicode_Find, but search for single character only. */ jpayne@69: PyAPI_FUNC(Py_ssize_t) PyUnicode_FindChar( jpayne@69: PyObject *str, jpayne@69: Py_UCS4 ch, jpayne@69: Py_ssize_t start, jpayne@69: Py_ssize_t end, jpayne@69: int direction jpayne@69: ); jpayne@69: #endif jpayne@69: jpayne@69: /* Count the number of occurrences of substr in str[start:end]. */ jpayne@69: jpayne@69: PyAPI_FUNC(Py_ssize_t) PyUnicode_Count( jpayne@69: PyObject *str, /* String */ jpayne@69: PyObject *substr, /* Substring to count */ jpayne@69: Py_ssize_t start, /* Start index */ jpayne@69: Py_ssize_t end /* Stop index */ jpayne@69: ); jpayne@69: jpayne@69: /* Replace at most maxcount occurrences of substr in str with replstr jpayne@69: and return the resulting Unicode object. */ jpayne@69: jpayne@69: PyAPI_FUNC(PyObject *) PyUnicode_Replace( jpayne@69: PyObject *str, /* String */ jpayne@69: PyObject *substr, /* Substring to find */ jpayne@69: PyObject *replstr, /* Substring to replace */ jpayne@69: Py_ssize_t maxcount /* Max. number of replacements to apply; jpayne@69: -1 = all */ jpayne@69: ); jpayne@69: jpayne@69: /* Compare two strings and return -1, 0, 1 for less than, equal, jpayne@69: greater than resp. jpayne@69: Raise an exception and return -1 on error. */ jpayne@69: jpayne@69: PyAPI_FUNC(int) PyUnicode_Compare( jpayne@69: PyObject *left, /* Left string */ jpayne@69: PyObject *right /* Right string */ jpayne@69: ); jpayne@69: jpayne@69: /* Compare a Unicode object with C string and return -1, 0, 1 for less than, jpayne@69: equal, and greater than, respectively. It is best to pass only jpayne@69: ASCII-encoded strings, but the function interprets the input string as jpayne@69: ISO-8859-1 if it contains non-ASCII characters. jpayne@69: This function does not raise exceptions. */ jpayne@69: jpayne@69: PyAPI_FUNC(int) PyUnicode_CompareWithASCIIString( jpayne@69: PyObject *left, jpayne@69: const char *right /* ASCII-encoded string */ jpayne@69: ); jpayne@69: jpayne@69: /* Rich compare two strings and return one of the following: jpayne@69: jpayne@69: - NULL in case an exception was raised jpayne@69: - Py_True or Py_False for successful comparisons jpayne@69: - Py_NotImplemented in case the type combination is unknown jpayne@69: jpayne@69: Possible values for op: jpayne@69: jpayne@69: Py_GT, Py_GE, Py_EQ, Py_NE, Py_LT, Py_LE jpayne@69: jpayne@69: */ jpayne@69: jpayne@69: PyAPI_FUNC(PyObject *) PyUnicode_RichCompare( jpayne@69: PyObject *left, /* Left string */ jpayne@69: PyObject *right, /* Right string */ jpayne@69: int op /* Operation: Py_EQ, Py_NE, Py_GT, etc. */ jpayne@69: ); jpayne@69: jpayne@69: /* Apply an argument tuple or dictionary to a format string and return jpayne@69: the resulting Unicode string. */ jpayne@69: jpayne@69: PyAPI_FUNC(PyObject *) PyUnicode_Format( jpayne@69: PyObject *format, /* Format string */ jpayne@69: PyObject *args /* Argument tuple or dictionary */ jpayne@69: ); jpayne@69: jpayne@69: /* Checks whether element is contained in container and return 1/0 jpayne@69: accordingly. jpayne@69: jpayne@69: element has to coerce to a one element Unicode string. -1 is jpayne@69: returned in case of an error. */ jpayne@69: jpayne@69: PyAPI_FUNC(int) PyUnicode_Contains( jpayne@69: PyObject *container, /* Container string */ jpayne@69: PyObject *element /* Element string */ jpayne@69: ); jpayne@69: jpayne@69: /* Checks whether argument is a valid identifier. */ jpayne@69: jpayne@69: PyAPI_FUNC(int) PyUnicode_IsIdentifier(PyObject *s); jpayne@69: jpayne@69: /* === Characters Type APIs =============================================== */ jpayne@69: jpayne@69: #ifndef Py_LIMITED_API jpayne@69: # define Py_CPYTHON_UNICODEOBJECT_H jpayne@69: # include "cpython/unicodeobject.h" jpayne@69: # undef Py_CPYTHON_UNICODEOBJECT_H jpayne@69: #endif jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: #endif /* !Py_UNICODEOBJECT_H */