Chris@87: #ifndef Py_UNICODEOBJECT_H Chris@87: #define Py_UNICODEOBJECT_H Chris@87: Chris@87: #include Chris@87: Chris@87: /* Chris@87: Chris@87: Unicode implementation based on original code by Fredrik Lundh, Chris@87: modified by Marc-Andre Lemburg (mal@lemburg.com) according to the Chris@87: Unicode Integration Proposal (see file Misc/unicode.txt). Chris@87: Chris@87: Copyright (c) Corporation for National Research Initiatives. Chris@87: Chris@87: Chris@87: Original header: Chris@87: -------------------------------------------------------------------- Chris@87: Chris@87: * Yet another Unicode string type for Python. This type supports the Chris@87: * 16-bit Basic Multilingual Plane (BMP) only. Chris@87: * Chris@87: * Written by Fredrik Lundh, January 1999. Chris@87: * Chris@87: * Copyright (c) 1999 by Secret Labs AB. Chris@87: * Copyright (c) 1999 by Fredrik Lundh. Chris@87: * Chris@87: * fredrik@pythonware.com Chris@87: * http://www.pythonware.com Chris@87: * Chris@87: * -------------------------------------------------------------------- Chris@87: * This Unicode String Type is Chris@87: * Chris@87: * Copyright (c) 1999 by Secret Labs AB Chris@87: * Copyright (c) 1999 by Fredrik Lundh Chris@87: * Chris@87: * By obtaining, using, and/or copying this software and/or its Chris@87: * associated documentation, you agree that you have read, understood, Chris@87: * and will comply with the following terms and conditions: Chris@87: * Chris@87: * Permission to use, copy, modify, and distribute this software and its Chris@87: * associated documentation for any purpose and without fee is hereby Chris@87: * granted, provided that the above copyright notice appears in all Chris@87: * copies, and that both that copyright notice and this permission notice Chris@87: * appear in supporting documentation, and that the name of Secret Labs Chris@87: * AB or the author not be used in advertising or publicity pertaining to Chris@87: * distribution of the software without specific, written prior Chris@87: * permission. Chris@87: * Chris@87: * SECRET LABS AB AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO Chris@87: * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND Chris@87: * FITNESS. IN NO EVENT SHALL SECRET LABS AB OR THE AUTHOR BE LIABLE FOR Chris@87: * ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES Chris@87: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN Chris@87: * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT Chris@87: * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. Chris@87: * -------------------------------------------------------------------- */ Chris@87: Chris@87: #include Chris@87: Chris@87: /* === Internal API ======================================================= */ Chris@87: Chris@87: /* --- Internal Unicode Format -------------------------------------------- */ Chris@87: Chris@87: #ifndef Py_USING_UNICODE Chris@87: Chris@87: #define PyUnicode_Check(op) 0 Chris@87: #define PyUnicode_CheckExact(op) 0 Chris@87: Chris@87: #else Chris@87: Chris@87: /* FIXME: MvL's new implementation assumes that Py_UNICODE_SIZE is Chris@87: properly set, but the default rules below doesn't set it. I'll Chris@87: sort this out some other day -- fredrik@pythonware.com */ Chris@87: Chris@87: #ifndef Py_UNICODE_SIZE Chris@87: #error Must define Py_UNICODE_SIZE Chris@87: #endif Chris@87: Chris@87: /* Setting Py_UNICODE_WIDE enables UCS-4 storage. Otherwise, Unicode Chris@87: strings are stored as UCS-2 (with limited support for UTF-16) */ Chris@87: Chris@87: #if Py_UNICODE_SIZE >= 4 Chris@87: #define Py_UNICODE_WIDE Chris@87: #endif Chris@87: Chris@87: /* Set these flags if the platform has "wchar.h", "wctype.h" and the Chris@87: wchar_t type is a 16-bit unsigned type */ Chris@87: /* #define HAVE_WCHAR_H */ Chris@87: /* #define HAVE_USABLE_WCHAR_T */ Chris@87: Chris@87: /* Defaults for various platforms */ Chris@87: #ifndef PY_UNICODE_TYPE Chris@87: Chris@87: /* Windows has a usable wchar_t type (unless we're using UCS-4) */ Chris@87: # if defined(MS_WIN32) && Py_UNICODE_SIZE == 2 Chris@87: # define HAVE_USABLE_WCHAR_T Chris@87: # define PY_UNICODE_TYPE wchar_t Chris@87: # endif Chris@87: Chris@87: # if defined(Py_UNICODE_WIDE) Chris@87: # define PY_UNICODE_TYPE Py_UCS4 Chris@87: # endif Chris@87: Chris@87: #endif Chris@87: Chris@87: /* If the compiler provides a wchar_t type we try to support it Chris@87: through the interface functions PyUnicode_FromWideChar() and Chris@87: PyUnicode_AsWideChar(). */ Chris@87: Chris@87: #ifdef HAVE_USABLE_WCHAR_T Chris@87: # ifndef HAVE_WCHAR_H Chris@87: # define HAVE_WCHAR_H Chris@87: # endif Chris@87: #endif Chris@87: Chris@87: #ifdef HAVE_WCHAR_H Chris@87: /* Work around a cosmetic bug in BSDI 4.x wchar.h; thanks to Thomas Wouters */ Chris@87: # ifdef _HAVE_BSDI Chris@87: # include Chris@87: # endif Chris@87: # include Chris@87: #endif Chris@87: Chris@87: /* Chris@87: * Use this typedef when you need to represent a UTF-16 surrogate pair Chris@87: * as single unsigned integer. Chris@87: */ Chris@87: #if SIZEOF_INT >= 4 Chris@87: typedef unsigned int Py_UCS4; Chris@87: #elif SIZEOF_LONG >= 4 Chris@87: typedef unsigned long Py_UCS4; Chris@87: #endif Chris@87: Chris@87: /* Py_UNICODE is the native Unicode storage format (code unit) used by Chris@87: Python and represents a single Unicode element in the Unicode Chris@87: type. */ Chris@87: Chris@87: typedef PY_UNICODE_TYPE Py_UNICODE; Chris@87: Chris@87: /* --- UCS-2/UCS-4 Name Mangling ------------------------------------------ */ Chris@87: Chris@87: /* Unicode API names are mangled to assure that UCS-2 and UCS-4 builds Chris@87: produce different external names and thus cause import errors in Chris@87: case Python interpreters and extensions with mixed compiled in Chris@87: Unicode width assumptions are combined. */ Chris@87: Chris@87: #ifndef Py_UNICODE_WIDE Chris@87: Chris@87: # define PyUnicode_AsASCIIString PyUnicodeUCS2_AsASCIIString Chris@87: # define PyUnicode_AsCharmapString PyUnicodeUCS2_AsCharmapString Chris@87: # define PyUnicode_AsEncodedObject PyUnicodeUCS2_AsEncodedObject Chris@87: # define PyUnicode_AsEncodedString PyUnicodeUCS2_AsEncodedString Chris@87: # define PyUnicode_AsLatin1String PyUnicodeUCS2_AsLatin1String Chris@87: # define PyUnicode_AsRawUnicodeEscapeString PyUnicodeUCS2_AsRawUnicodeEscapeString Chris@87: # define PyUnicode_AsUTF32String PyUnicodeUCS2_AsUTF32String Chris@87: # define PyUnicode_AsUTF16String PyUnicodeUCS2_AsUTF16String Chris@87: # define PyUnicode_AsUTF8String PyUnicodeUCS2_AsUTF8String Chris@87: # define PyUnicode_AsUnicode PyUnicodeUCS2_AsUnicode Chris@87: # define PyUnicode_AsUnicodeEscapeString PyUnicodeUCS2_AsUnicodeEscapeString Chris@87: # define PyUnicode_AsWideChar PyUnicodeUCS2_AsWideChar Chris@87: # define PyUnicode_ClearFreeList PyUnicodeUCS2_ClearFreelist Chris@87: # define PyUnicode_Compare PyUnicodeUCS2_Compare Chris@87: # define PyUnicode_Concat PyUnicodeUCS2_Concat Chris@87: # define PyUnicode_Contains PyUnicodeUCS2_Contains Chris@87: # define PyUnicode_Count PyUnicodeUCS2_Count Chris@87: # define PyUnicode_Decode PyUnicodeUCS2_Decode Chris@87: # define PyUnicode_DecodeASCII PyUnicodeUCS2_DecodeASCII Chris@87: # define PyUnicode_DecodeCharmap PyUnicodeUCS2_DecodeCharmap Chris@87: # define PyUnicode_DecodeLatin1 PyUnicodeUCS2_DecodeLatin1 Chris@87: # define PyUnicode_DecodeRawUnicodeEscape PyUnicodeUCS2_DecodeRawUnicodeEscape Chris@87: # define PyUnicode_DecodeUTF32 PyUnicodeUCS2_DecodeUTF32 Chris@87: # define PyUnicode_DecodeUTF32Stateful PyUnicodeUCS2_DecodeUTF32Stateful Chris@87: # define PyUnicode_DecodeUTF16 PyUnicodeUCS2_DecodeUTF16 Chris@87: # define PyUnicode_DecodeUTF16Stateful PyUnicodeUCS2_DecodeUTF16Stateful Chris@87: # define PyUnicode_DecodeUTF8 PyUnicodeUCS2_DecodeUTF8 Chris@87: # define PyUnicode_DecodeUTF8Stateful PyUnicodeUCS2_DecodeUTF8Stateful Chris@87: # define PyUnicode_DecodeUnicodeEscape PyUnicodeUCS2_DecodeUnicodeEscape Chris@87: # define PyUnicode_Encode PyUnicodeUCS2_Encode Chris@87: # define PyUnicode_EncodeASCII PyUnicodeUCS2_EncodeASCII Chris@87: # define PyUnicode_EncodeCharmap PyUnicodeUCS2_EncodeCharmap Chris@87: # define PyUnicode_EncodeDecimal PyUnicodeUCS2_EncodeDecimal Chris@87: # define PyUnicode_EncodeLatin1 PyUnicodeUCS2_EncodeLatin1 Chris@87: # define PyUnicode_EncodeRawUnicodeEscape PyUnicodeUCS2_EncodeRawUnicodeEscape Chris@87: # define PyUnicode_EncodeUTF32 PyUnicodeUCS2_EncodeUTF32 Chris@87: # define PyUnicode_EncodeUTF16 PyUnicodeUCS2_EncodeUTF16 Chris@87: # define PyUnicode_EncodeUTF8 PyUnicodeUCS2_EncodeUTF8 Chris@87: # define PyUnicode_EncodeUnicodeEscape PyUnicodeUCS2_EncodeUnicodeEscape Chris@87: # define PyUnicode_Find PyUnicodeUCS2_Find Chris@87: # define PyUnicode_Format PyUnicodeUCS2_Format Chris@87: # define PyUnicode_FromEncodedObject PyUnicodeUCS2_FromEncodedObject Chris@87: # define PyUnicode_FromFormat PyUnicodeUCS2_FromFormat Chris@87: # define PyUnicode_FromFormatV PyUnicodeUCS2_FromFormatV Chris@87: # define PyUnicode_FromObject PyUnicodeUCS2_FromObject Chris@87: # define PyUnicode_FromOrdinal PyUnicodeUCS2_FromOrdinal Chris@87: # define PyUnicode_FromString PyUnicodeUCS2_FromString Chris@87: # define PyUnicode_FromStringAndSize PyUnicodeUCS2_FromStringAndSize Chris@87: # define PyUnicode_FromUnicode PyUnicodeUCS2_FromUnicode Chris@87: # define PyUnicode_FromWideChar PyUnicodeUCS2_FromWideChar Chris@87: # define PyUnicode_GetDefaultEncoding PyUnicodeUCS2_GetDefaultEncoding Chris@87: # define PyUnicode_GetMax PyUnicodeUCS2_GetMax Chris@87: # define PyUnicode_GetSize PyUnicodeUCS2_GetSize Chris@87: # define PyUnicode_Join PyUnicodeUCS2_Join Chris@87: # define PyUnicode_Partition PyUnicodeUCS2_Partition Chris@87: # define PyUnicode_RPartition PyUnicodeUCS2_RPartition Chris@87: # define PyUnicode_RSplit PyUnicodeUCS2_RSplit Chris@87: # define PyUnicode_Replace PyUnicodeUCS2_Replace Chris@87: # define PyUnicode_Resize PyUnicodeUCS2_Resize Chris@87: # define PyUnicode_RichCompare PyUnicodeUCS2_RichCompare Chris@87: # define PyUnicode_SetDefaultEncoding PyUnicodeUCS2_SetDefaultEncoding Chris@87: # define PyUnicode_Split PyUnicodeUCS2_Split Chris@87: # define PyUnicode_Splitlines PyUnicodeUCS2_Splitlines Chris@87: # define PyUnicode_Tailmatch PyUnicodeUCS2_Tailmatch Chris@87: # define PyUnicode_Translate PyUnicodeUCS2_Translate Chris@87: # define PyUnicode_TranslateCharmap PyUnicodeUCS2_TranslateCharmap Chris@87: # define _PyUnicode_AsDefaultEncodedString _PyUnicodeUCS2_AsDefaultEncodedString Chris@87: # define _PyUnicode_Fini _PyUnicodeUCS2_Fini Chris@87: # define _PyUnicode_Init _PyUnicodeUCS2_Init Chris@87: # define _PyUnicode_IsAlpha _PyUnicodeUCS2_IsAlpha Chris@87: # define _PyUnicode_IsDecimalDigit _PyUnicodeUCS2_IsDecimalDigit Chris@87: # define _PyUnicode_IsDigit _PyUnicodeUCS2_IsDigit Chris@87: # define _PyUnicode_IsLinebreak _PyUnicodeUCS2_IsLinebreak Chris@87: # define _PyUnicode_IsLowercase _PyUnicodeUCS2_IsLowercase Chris@87: # define _PyUnicode_IsNumeric _PyUnicodeUCS2_IsNumeric Chris@87: # define _PyUnicode_IsTitlecase _PyUnicodeUCS2_IsTitlecase Chris@87: # define _PyUnicode_IsUppercase _PyUnicodeUCS2_IsUppercase Chris@87: # define _PyUnicode_IsWhitespace _PyUnicodeUCS2_IsWhitespace Chris@87: # define _PyUnicode_ToDecimalDigit _PyUnicodeUCS2_ToDecimalDigit Chris@87: # define _PyUnicode_ToDigit _PyUnicodeUCS2_ToDigit Chris@87: # define _PyUnicode_ToLowercase _PyUnicodeUCS2_ToLowercase Chris@87: # define _PyUnicode_ToNumeric _PyUnicodeUCS2_ToNumeric Chris@87: # define _PyUnicode_ToTitlecase _PyUnicodeUCS2_ToTitlecase Chris@87: # define _PyUnicode_ToUppercase _PyUnicodeUCS2_ToUppercase Chris@87: Chris@87: #else Chris@87: Chris@87: # define PyUnicode_AsASCIIString PyUnicodeUCS4_AsASCIIString Chris@87: # define PyUnicode_AsCharmapString PyUnicodeUCS4_AsCharmapString Chris@87: # define PyUnicode_AsEncodedObject PyUnicodeUCS4_AsEncodedObject Chris@87: # define PyUnicode_AsEncodedString PyUnicodeUCS4_AsEncodedString Chris@87: # define PyUnicode_AsLatin1String PyUnicodeUCS4_AsLatin1String Chris@87: # define PyUnicode_AsRawUnicodeEscapeString PyUnicodeUCS4_AsRawUnicodeEscapeString Chris@87: # define PyUnicode_AsUTF32String PyUnicodeUCS4_AsUTF32String Chris@87: # define PyUnicode_AsUTF16String PyUnicodeUCS4_AsUTF16String Chris@87: # define PyUnicode_AsUTF8String PyUnicodeUCS4_AsUTF8String Chris@87: # define PyUnicode_AsUnicode PyUnicodeUCS4_AsUnicode Chris@87: # define PyUnicode_AsUnicodeEscapeString PyUnicodeUCS4_AsUnicodeEscapeString Chris@87: # define PyUnicode_AsWideChar PyUnicodeUCS4_AsWideChar Chris@87: # define PyUnicode_ClearFreeList PyUnicodeUCS4_ClearFreelist Chris@87: # define PyUnicode_Compare PyUnicodeUCS4_Compare Chris@87: # define PyUnicode_Concat PyUnicodeUCS4_Concat Chris@87: # define PyUnicode_Contains PyUnicodeUCS4_Contains Chris@87: # define PyUnicode_Count PyUnicodeUCS4_Count Chris@87: # define PyUnicode_Decode PyUnicodeUCS4_Decode Chris@87: # define PyUnicode_DecodeASCII PyUnicodeUCS4_DecodeASCII Chris@87: # define PyUnicode_DecodeCharmap PyUnicodeUCS4_DecodeCharmap Chris@87: # define PyUnicode_DecodeLatin1 PyUnicodeUCS4_DecodeLatin1 Chris@87: # define PyUnicode_DecodeRawUnicodeEscape PyUnicodeUCS4_DecodeRawUnicodeEscape Chris@87: # define PyUnicode_DecodeUTF32 PyUnicodeUCS4_DecodeUTF32 Chris@87: # define PyUnicode_DecodeUTF32Stateful PyUnicodeUCS4_DecodeUTF32Stateful Chris@87: # define PyUnicode_DecodeUTF16 PyUnicodeUCS4_DecodeUTF16 Chris@87: # define PyUnicode_DecodeUTF16Stateful PyUnicodeUCS4_DecodeUTF16Stateful Chris@87: # define PyUnicode_DecodeUTF8 PyUnicodeUCS4_DecodeUTF8 Chris@87: # define PyUnicode_DecodeUTF8Stateful PyUnicodeUCS4_DecodeUTF8Stateful Chris@87: # define PyUnicode_DecodeUnicodeEscape PyUnicodeUCS4_DecodeUnicodeEscape Chris@87: # define PyUnicode_Encode PyUnicodeUCS4_Encode Chris@87: # define PyUnicode_EncodeASCII PyUnicodeUCS4_EncodeASCII Chris@87: # define PyUnicode_EncodeCharmap PyUnicodeUCS4_EncodeCharmap Chris@87: # define PyUnicode_EncodeDecimal PyUnicodeUCS4_EncodeDecimal Chris@87: # define PyUnicode_EncodeLatin1 PyUnicodeUCS4_EncodeLatin1 Chris@87: # define PyUnicode_EncodeRawUnicodeEscape PyUnicodeUCS4_EncodeRawUnicodeEscape Chris@87: # define PyUnicode_EncodeUTF32 PyUnicodeUCS4_EncodeUTF32 Chris@87: # define PyUnicode_EncodeUTF16 PyUnicodeUCS4_EncodeUTF16 Chris@87: # define PyUnicode_EncodeUTF8 PyUnicodeUCS4_EncodeUTF8 Chris@87: # define PyUnicode_EncodeUnicodeEscape PyUnicodeUCS4_EncodeUnicodeEscape Chris@87: # define PyUnicode_Find PyUnicodeUCS4_Find Chris@87: # define PyUnicode_Format PyUnicodeUCS4_Format Chris@87: # define PyUnicode_FromEncodedObject PyUnicodeUCS4_FromEncodedObject Chris@87: # define PyUnicode_FromFormat PyUnicodeUCS4_FromFormat Chris@87: # define PyUnicode_FromFormatV PyUnicodeUCS4_FromFormatV Chris@87: # define PyUnicode_FromObject PyUnicodeUCS4_FromObject Chris@87: # define PyUnicode_FromOrdinal PyUnicodeUCS4_FromOrdinal Chris@87: # define PyUnicode_FromString PyUnicodeUCS4_FromString Chris@87: # define PyUnicode_FromStringAndSize PyUnicodeUCS4_FromStringAndSize Chris@87: # define PyUnicode_FromUnicode PyUnicodeUCS4_FromUnicode Chris@87: # define PyUnicode_FromWideChar PyUnicodeUCS4_FromWideChar Chris@87: # define PyUnicode_GetDefaultEncoding PyUnicodeUCS4_GetDefaultEncoding Chris@87: # define PyUnicode_GetMax PyUnicodeUCS4_GetMax Chris@87: # define PyUnicode_GetSize PyUnicodeUCS4_GetSize Chris@87: # define PyUnicode_Join PyUnicodeUCS4_Join Chris@87: # define PyUnicode_Partition PyUnicodeUCS4_Partition Chris@87: # define PyUnicode_RPartition PyUnicodeUCS4_RPartition Chris@87: # define PyUnicode_RSplit PyUnicodeUCS4_RSplit Chris@87: # define PyUnicode_Replace PyUnicodeUCS4_Replace Chris@87: # define PyUnicode_Resize PyUnicodeUCS4_Resize Chris@87: # define PyUnicode_RichCompare PyUnicodeUCS4_RichCompare Chris@87: # define PyUnicode_SetDefaultEncoding PyUnicodeUCS4_SetDefaultEncoding Chris@87: # define PyUnicode_Split PyUnicodeUCS4_Split Chris@87: # define PyUnicode_Splitlines PyUnicodeUCS4_Splitlines Chris@87: # define PyUnicode_Tailmatch PyUnicodeUCS4_Tailmatch Chris@87: # define PyUnicode_Translate PyUnicodeUCS4_Translate Chris@87: # define PyUnicode_TranslateCharmap PyUnicodeUCS4_TranslateCharmap Chris@87: # define _PyUnicode_AsDefaultEncodedString _PyUnicodeUCS4_AsDefaultEncodedString Chris@87: # define _PyUnicode_Fini _PyUnicodeUCS4_Fini Chris@87: # define _PyUnicode_Init _PyUnicodeUCS4_Init Chris@87: # define _PyUnicode_IsAlpha _PyUnicodeUCS4_IsAlpha Chris@87: # define _PyUnicode_IsDecimalDigit _PyUnicodeUCS4_IsDecimalDigit Chris@87: # define _PyUnicode_IsDigit _PyUnicodeUCS4_IsDigit Chris@87: # define _PyUnicode_IsLinebreak _PyUnicodeUCS4_IsLinebreak Chris@87: # define _PyUnicode_IsLowercase _PyUnicodeUCS4_IsLowercase Chris@87: # define _PyUnicode_IsNumeric _PyUnicodeUCS4_IsNumeric Chris@87: # define _PyUnicode_IsTitlecase _PyUnicodeUCS4_IsTitlecase Chris@87: # define _PyUnicode_IsUppercase _PyUnicodeUCS4_IsUppercase Chris@87: # define _PyUnicode_IsWhitespace _PyUnicodeUCS4_IsWhitespace Chris@87: # define _PyUnicode_ToDecimalDigit _PyUnicodeUCS4_ToDecimalDigit Chris@87: # define _PyUnicode_ToDigit _PyUnicodeUCS4_ToDigit Chris@87: # define _PyUnicode_ToLowercase _PyUnicodeUCS4_ToLowercase Chris@87: # define _PyUnicode_ToNumeric _PyUnicodeUCS4_ToNumeric Chris@87: # define _PyUnicode_ToTitlecase _PyUnicodeUCS4_ToTitlecase Chris@87: # define _PyUnicode_ToUppercase _PyUnicodeUCS4_ToUppercase Chris@87: Chris@87: Chris@87: #endif Chris@87: Chris@87: /* --- Internal Unicode Operations ---------------------------------------- */ Chris@87: Chris@87: /* If you want Python to use the compiler's wctype.h functions instead Chris@87: of the ones supplied with Python, define WANT_WCTYPE_FUNCTIONS or Chris@87: configure Python using --with-wctype-functions. This reduces the Chris@87: interpreter's code size. */ Chris@87: Chris@87: #if defined(HAVE_USABLE_WCHAR_T) && defined(WANT_WCTYPE_FUNCTIONS) Chris@87: Chris@87: #include Chris@87: Chris@87: #define Py_UNICODE_ISSPACE(ch) iswspace(ch) Chris@87: Chris@87: #define Py_UNICODE_ISLOWER(ch) iswlower(ch) Chris@87: #define Py_UNICODE_ISUPPER(ch) iswupper(ch) Chris@87: #define Py_UNICODE_ISTITLE(ch) _PyUnicode_IsTitlecase(ch) Chris@87: #define Py_UNICODE_ISLINEBREAK(ch) _PyUnicode_IsLinebreak(ch) Chris@87: Chris@87: #define Py_UNICODE_TOLOWER(ch) towlower(ch) Chris@87: #define Py_UNICODE_TOUPPER(ch) towupper(ch) Chris@87: #define Py_UNICODE_TOTITLE(ch) _PyUnicode_ToTitlecase(ch) Chris@87: Chris@87: #define Py_UNICODE_ISDECIMAL(ch) _PyUnicode_IsDecimalDigit(ch) Chris@87: #define Py_UNICODE_ISDIGIT(ch) _PyUnicode_IsDigit(ch) Chris@87: #define Py_UNICODE_ISNUMERIC(ch) _PyUnicode_IsNumeric(ch) Chris@87: Chris@87: #define Py_UNICODE_TODECIMAL(ch) _PyUnicode_ToDecimalDigit(ch) Chris@87: #define Py_UNICODE_TODIGIT(ch) _PyUnicode_ToDigit(ch) Chris@87: #define Py_UNICODE_TONUMERIC(ch) _PyUnicode_ToNumeric(ch) Chris@87: Chris@87: #define Py_UNICODE_ISALPHA(ch) iswalpha(ch) Chris@87: Chris@87: #else Chris@87: Chris@87: /* Since splitting on whitespace is an important use case, and Chris@87: whitespace in most situations is solely ASCII whitespace, we Chris@87: optimize for the common case by using a quick look-up table Chris@87: _Py_ascii_whitespace (see below) with an inlined check. Chris@87: Chris@87: */ Chris@87: #define Py_UNICODE_ISSPACE(ch) \ Chris@87: ((ch) < 128U ? _Py_ascii_whitespace[(ch)] : _PyUnicode_IsWhitespace(ch)) Chris@87: Chris@87: #define Py_UNICODE_ISLOWER(ch) _PyUnicode_IsLowercase(ch) Chris@87: #define Py_UNICODE_ISUPPER(ch) _PyUnicode_IsUppercase(ch) Chris@87: #define Py_UNICODE_ISTITLE(ch) _PyUnicode_IsTitlecase(ch) Chris@87: #define Py_UNICODE_ISLINEBREAK(ch) _PyUnicode_IsLinebreak(ch) Chris@87: Chris@87: #define Py_UNICODE_TOLOWER(ch) _PyUnicode_ToLowercase(ch) Chris@87: #define Py_UNICODE_TOUPPER(ch) _PyUnicode_ToUppercase(ch) Chris@87: #define Py_UNICODE_TOTITLE(ch) _PyUnicode_ToTitlecase(ch) Chris@87: Chris@87: #define Py_UNICODE_ISDECIMAL(ch) _PyUnicode_IsDecimalDigit(ch) Chris@87: #define Py_UNICODE_ISDIGIT(ch) _PyUnicode_IsDigit(ch) Chris@87: #define Py_UNICODE_ISNUMERIC(ch) _PyUnicode_IsNumeric(ch) Chris@87: Chris@87: #define Py_UNICODE_TODECIMAL(ch) _PyUnicode_ToDecimalDigit(ch) Chris@87: #define Py_UNICODE_TODIGIT(ch) _PyUnicode_ToDigit(ch) Chris@87: #define Py_UNICODE_TONUMERIC(ch) _PyUnicode_ToNumeric(ch) Chris@87: Chris@87: #define Py_UNICODE_ISALPHA(ch) _PyUnicode_IsAlpha(ch) Chris@87: Chris@87: #endif Chris@87: Chris@87: #define Py_UNICODE_ISALNUM(ch) \ Chris@87: (Py_UNICODE_ISALPHA(ch) || \ Chris@87: Py_UNICODE_ISDECIMAL(ch) || \ Chris@87: Py_UNICODE_ISDIGIT(ch) || \ Chris@87: Py_UNICODE_ISNUMERIC(ch)) Chris@87: Chris@87: #define Py_UNICODE_COPY(target, source, length) \ Chris@87: Py_MEMCPY((target), (source), (length)*sizeof(Py_UNICODE)) Chris@87: Chris@87: #define Py_UNICODE_FILL(target, value, length) \ Chris@87: do {Py_ssize_t i_; Py_UNICODE *t_ = (target); Py_UNICODE v_ = (value);\ Chris@87: for (i_ = 0; i_ < (length); i_++) t_[i_] = v_;\ Chris@87: } while (0) Chris@87: Chris@87: /* Check if substring matches at given offset. the offset must be Chris@87: valid, and the substring must not be empty */ Chris@87: Chris@87: #define Py_UNICODE_MATCH(string, offset, substring) \ Chris@87: ((*((string)->str + (offset)) == *((substring)->str)) && \ Chris@87: ((*((string)->str + (offset) + (substring)->length-1) == *((substring)->str + (substring)->length-1))) && \ Chris@87: !memcmp((string)->str + (offset), (substring)->str, (substring)->length*sizeof(Py_UNICODE))) Chris@87: Chris@87: #ifdef __cplusplus Chris@87: extern "C" { Chris@87: #endif Chris@87: Chris@87: /* --- Unicode Type ------------------------------------------------------- */ Chris@87: Chris@87: typedef struct { Chris@87: PyObject_HEAD Chris@87: Py_ssize_t length; /* Length of raw Unicode data in buffer */ Chris@87: Py_UNICODE *str; /* Raw Unicode buffer */ Chris@87: long hash; /* Hash value; -1 if not set */ Chris@87: PyObject *defenc; /* (Default) Encoded version as Python Chris@87: string, or NULL; this is used for Chris@87: implementing the buffer protocol */ Chris@87: } PyUnicodeObject; Chris@87: Chris@87: PyAPI_DATA(PyTypeObject) PyUnicode_Type; Chris@87: Chris@87: #define PyUnicode_Check(op) \ Chris@87: PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_UNICODE_SUBCLASS) Chris@87: #define PyUnicode_CheckExact(op) (Py_TYPE(op) == &PyUnicode_Type) Chris@87: Chris@87: /* Fast access macros */ Chris@87: #define PyUnicode_GET_SIZE(op) \ Chris@87: (((PyUnicodeObject *)(op))->length) Chris@87: #define PyUnicode_GET_DATA_SIZE(op) \ Chris@87: (((PyUnicodeObject *)(op))->length * sizeof(Py_UNICODE)) Chris@87: #define PyUnicode_AS_UNICODE(op) \ Chris@87: (((PyUnicodeObject *)(op))->str) Chris@87: #define PyUnicode_AS_DATA(op) \ Chris@87: ((const char *)((PyUnicodeObject *)(op))->str) Chris@87: Chris@87: /* --- Constants ---------------------------------------------------------- */ Chris@87: Chris@87: /* This Unicode character will be used as replacement character during Chris@87: decoding if the errors argument is set to "replace". Note: the Chris@87: Unicode character U+FFFD is the official REPLACEMENT CHARACTER in Chris@87: Unicode 3.0. */ Chris@87: Chris@87: #define Py_UNICODE_REPLACEMENT_CHARACTER ((Py_UNICODE) 0xFFFD) Chris@87: Chris@87: /* === Public API ========================================================= */ Chris@87: Chris@87: /* --- Plain Py_UNICODE --------------------------------------------------- */ Chris@87: Chris@87: /* Create a Unicode Object from the Py_UNICODE buffer u of the given Chris@87: size. Chris@87: Chris@87: u may be NULL which causes the contents to be undefined. It is the Chris@87: user's responsibility to fill in the needed data afterwards. Note Chris@87: that modifying the Unicode object contents after construction is Chris@87: only allowed if u was set to NULL. Chris@87: Chris@87: The buffer is copied into the new object. */ Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_FromUnicode( Chris@87: const Py_UNICODE *u, /* Unicode buffer */ Chris@87: Py_ssize_t size /* size of buffer */ Chris@87: ); Chris@87: Chris@87: /* Similar to PyUnicode_FromUnicode(), but u points to Latin-1 encoded bytes */ Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_FromStringAndSize( Chris@87: const char *u, /* char buffer */ Chris@87: Py_ssize_t size /* size of buffer */ Chris@87: ); Chris@87: Chris@87: /* Similar to PyUnicode_FromUnicode(), but u points to null-terminated Chris@87: Latin-1 encoded bytes */ Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_FromString( Chris@87: const char *u /* string */ Chris@87: ); Chris@87: Chris@87: /* Return a read-only pointer to the Unicode object's internal Chris@87: Py_UNICODE buffer. */ Chris@87: Chris@87: PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode( Chris@87: PyObject *unicode /* Unicode object */ Chris@87: ); Chris@87: Chris@87: /* Get the length of the Unicode object. */ Chris@87: Chris@87: PyAPI_FUNC(Py_ssize_t) PyUnicode_GetSize( Chris@87: PyObject *unicode /* Unicode object */ Chris@87: ); Chris@87: Chris@87: /* Get the maximum ordinal for a Unicode character. */ Chris@87: PyAPI_FUNC(Py_UNICODE) PyUnicode_GetMax(void); Chris@87: Chris@87: /* Resize an already allocated Unicode object to the new size length. Chris@87: Chris@87: *unicode is modified to point to the new (resized) object and 0 Chris@87: returned on success. Chris@87: Chris@87: This API may only be called by the function which also called the Chris@87: Unicode constructor. The refcount on the object must be 1. Otherwise, Chris@87: an error is returned. Chris@87: Chris@87: Error handling is implemented as follows: an exception is set, -1 Chris@87: is returned and *unicode left untouched. Chris@87: Chris@87: */ Chris@87: Chris@87: PyAPI_FUNC(int) PyUnicode_Resize( Chris@87: PyObject **unicode, /* Pointer to the Unicode object */ Chris@87: Py_ssize_t length /* New length */ Chris@87: ); Chris@87: Chris@87: /* Coerce obj to an Unicode object and return a reference with Chris@87: *incremented* refcount. Chris@87: Chris@87: Coercion is done in the following way: Chris@87: Chris@87: 1. String and other char buffer compatible objects are decoded Chris@87: under the assumptions that they contain data using the current Chris@87: default encoding. Decoding is done in "strict" mode. Chris@87: Chris@87: 2. All other objects (including Unicode objects) raise an Chris@87: exception. Chris@87: Chris@87: The API returns NULL in case of an error. The caller is responsible Chris@87: for decref'ing the returned objects. Chris@87: Chris@87: */ Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_FromEncodedObject( Chris@87: register PyObject *obj, /* Object */ Chris@87: const char *encoding, /* encoding */ Chris@87: const char *errors /* error handling */ Chris@87: ); Chris@87: Chris@87: /* Coerce obj to an Unicode object and return a reference with Chris@87: *incremented* refcount. Chris@87: Chris@87: Unicode objects are passed back as-is (subclasses are converted to Chris@87: true Unicode objects), all other objects are delegated to Chris@87: PyUnicode_FromEncodedObject(obj, NULL, "strict") which results in Chris@87: using the default encoding as basis for decoding the object. Chris@87: Chris@87: The API returns NULL in case of an error. The caller is responsible Chris@87: for decref'ing the returned objects. Chris@87: Chris@87: */ Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_FromObject( Chris@87: register PyObject *obj /* Object */ Chris@87: ); Chris@87: Chris@87: PyAPI_FUNC(PyObject *) PyUnicode_FromFormatV(const char*, va_list); Chris@87: PyAPI_FUNC(PyObject *) PyUnicode_FromFormat(const char*, ...); Chris@87: Chris@87: /* Format the object based on the format_spec, as defined in PEP 3101 Chris@87: (Advanced String Formatting). */ Chris@87: PyAPI_FUNC(PyObject *) _PyUnicode_FormatAdvanced(PyObject *obj, Chris@87: Py_UNICODE *format_spec, Chris@87: Py_ssize_t format_spec_len); Chris@87: Chris@87: /* --- wchar_t support for platforms which support it --------------------- */ Chris@87: Chris@87: #ifdef HAVE_WCHAR_H Chris@87: Chris@87: /* Create a Unicode Object from the whcar_t buffer w of the given Chris@87: size. Chris@87: Chris@87: The buffer is copied into the new object. */ Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_FromWideChar( Chris@87: register const wchar_t *w, /* wchar_t buffer */ Chris@87: Py_ssize_t size /* size of buffer */ Chris@87: ); Chris@87: Chris@87: /* Copies the Unicode Object contents into the wchar_t buffer w. At Chris@87: most size wchar_t characters are copied. Chris@87: Chris@87: Note that the resulting wchar_t string may or may not be Chris@87: 0-terminated. It is the responsibility of the caller to make sure Chris@87: that the wchar_t string is 0-terminated in case this is required by Chris@87: the application. Chris@87: Chris@87: Returns the number of wchar_t characters copied (excluding a Chris@87: possibly trailing 0-termination character) or -1 in case of an Chris@87: error. */ Chris@87: Chris@87: PyAPI_FUNC(Py_ssize_t) PyUnicode_AsWideChar( Chris@87: PyUnicodeObject *unicode, /* Unicode object */ Chris@87: register wchar_t *w, /* wchar_t buffer */ Chris@87: Py_ssize_t size /* size of buffer */ Chris@87: ); Chris@87: Chris@87: #endif Chris@87: Chris@87: /* --- Unicode ordinals --------------------------------------------------- */ Chris@87: Chris@87: /* Create a Unicode Object from the given Unicode code point ordinal. Chris@87: Chris@87: The ordinal must be in range(0x10000) on narrow Python builds Chris@87: (UCS2), and range(0x110000) on wide builds (UCS4). A ValueError is Chris@87: raised in case it is not. Chris@87: Chris@87: */ Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_FromOrdinal(int ordinal); Chris@87: Chris@87: /* --- Free-list management ----------------------------------------------- */ Chris@87: Chris@87: /* Clear the free list used by the Unicode implementation. Chris@87: Chris@87: This can be used to release memory used for objects on the free Chris@87: list back to the Python memory allocator. Chris@87: Chris@87: */ Chris@87: Chris@87: PyAPI_FUNC(int) PyUnicode_ClearFreeList(void); Chris@87: Chris@87: /* === Builtin Codecs ===================================================== Chris@87: Chris@87: Many of these APIs take two arguments encoding and errors. These Chris@87: parameters encoding and errors have the same semantics as the ones Chris@87: of the builtin unicode() API. Chris@87: Chris@87: Setting encoding to NULL causes the default encoding to be used. Chris@87: Chris@87: Error handling is set by errors which may also be set to NULL Chris@87: meaning to use the default handling defined for the codec. Default Chris@87: error handling for all builtin codecs is "strict" (ValueErrors are Chris@87: raised). Chris@87: Chris@87: The codecs all use a similar interface. Only deviation from the Chris@87: generic ones are documented. Chris@87: Chris@87: */ Chris@87: Chris@87: /* --- Manage the default encoding ---------------------------------------- */ Chris@87: Chris@87: /* Return a Python string holding the default encoded value of the Chris@87: Unicode object. Chris@87: Chris@87: The resulting string is cached in the Unicode object for subsequent Chris@87: usage by this function. The cached version is needed to implement Chris@87: the character buffer interface and will live (at least) as long as Chris@87: the Unicode object itself. Chris@87: Chris@87: The refcount of the string is *not* incremented. Chris@87: Chris@87: *** Exported for internal use by the interpreter only !!! *** Chris@87: Chris@87: */ Chris@87: Chris@87: PyAPI_FUNC(PyObject *) _PyUnicode_AsDefaultEncodedString( Chris@87: PyObject *, const char *); Chris@87: Chris@87: /* Returns the currently active default encoding. Chris@87: Chris@87: The default encoding is currently implemented as run-time settable Chris@87: process global. This may change in future versions of the Chris@87: interpreter to become a parameter which is managed on a per-thread Chris@87: basis. Chris@87: Chris@87: */ Chris@87: Chris@87: PyAPI_FUNC(const char*) PyUnicode_GetDefaultEncoding(void); Chris@87: Chris@87: /* Sets the currently active default encoding. Chris@87: Chris@87: Returns 0 on success, -1 in case of an error. Chris@87: Chris@87: */ Chris@87: Chris@87: PyAPI_FUNC(int) PyUnicode_SetDefaultEncoding( Chris@87: const char *encoding /* Encoding name in standard form */ Chris@87: ); Chris@87: Chris@87: /* --- Generic Codecs ----------------------------------------------------- */ Chris@87: Chris@87: /* Create a Unicode object by decoding the encoded string s of the Chris@87: given size. */ Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_Decode( Chris@87: const char *s, /* encoded string */ Chris@87: Py_ssize_t size, /* size of buffer */ Chris@87: const char *encoding, /* encoding */ Chris@87: const char *errors /* error handling */ Chris@87: ); Chris@87: Chris@87: /* Encodes a Py_UNICODE buffer of the given size and returns a Chris@87: Python string object. */ Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_Encode( Chris@87: const Py_UNICODE *s, /* Unicode char buffer */ Chris@87: Py_ssize_t size, /* number of Py_UNICODE chars to encode */ Chris@87: const char *encoding, /* encoding */ Chris@87: const char *errors /* error handling */ Chris@87: ); Chris@87: Chris@87: /* Encodes a Unicode object and returns the result as Python Chris@87: object. */ Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_AsEncodedObject( Chris@87: PyObject *unicode, /* Unicode object */ Chris@87: const char *encoding, /* encoding */ Chris@87: const char *errors /* error handling */ Chris@87: ); Chris@87: Chris@87: /* Encodes a Unicode object and returns the result as Python string Chris@87: object. */ Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_AsEncodedString( Chris@87: PyObject *unicode, /* Unicode object */ Chris@87: const char *encoding, /* encoding */ Chris@87: const char *errors /* error handling */ Chris@87: ); Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_BuildEncodingMap( Chris@87: PyObject* string /* 256 character map */ Chris@87: ); Chris@87: Chris@87: Chris@87: /* --- UTF-7 Codecs ------------------------------------------------------- */ Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF7( Chris@87: const char *string, /* UTF-7 encoded string */ Chris@87: Py_ssize_t length, /* size of string */ Chris@87: const char *errors /* error handling */ Chris@87: ); Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF7Stateful( Chris@87: const char *string, /* UTF-7 encoded string */ Chris@87: Py_ssize_t length, /* size of string */ Chris@87: const char *errors, /* error handling */ Chris@87: Py_ssize_t *consumed /* bytes consumed */ Chris@87: ); Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF7( Chris@87: const Py_UNICODE *data, /* Unicode char buffer */ Chris@87: Py_ssize_t length, /* number of Py_UNICODE chars to encode */ Chris@87: int base64SetO, /* Encode RFC2152 Set O characters in base64 */ Chris@87: int base64WhiteSpace, /* Encode whitespace (sp, ht, nl, cr) in base64 */ Chris@87: const char *errors /* error handling */ Chris@87: ); Chris@87: Chris@87: /* --- UTF-8 Codecs ------------------------------------------------------- */ Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF8( Chris@87: const char *string, /* UTF-8 encoded string */ Chris@87: Py_ssize_t length, /* size of string */ Chris@87: const char *errors /* error handling */ Chris@87: ); Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF8Stateful( Chris@87: const char *string, /* UTF-8 encoded string */ Chris@87: Py_ssize_t length, /* size of string */ Chris@87: const char *errors, /* error handling */ Chris@87: Py_ssize_t *consumed /* bytes consumed */ Chris@87: ); Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_AsUTF8String( Chris@87: PyObject *unicode /* Unicode object */ Chris@87: ); Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF8( Chris@87: const Py_UNICODE *data, /* Unicode char buffer */ Chris@87: Py_ssize_t length, /* number of Py_UNICODE chars to encode */ Chris@87: const char *errors /* error handling */ Chris@87: ); Chris@87: Chris@87: /* --- UTF-32 Codecs ------------------------------------------------------ */ Chris@87: Chris@87: /* Decodes length bytes from a UTF-32 encoded buffer string and returns Chris@87: the corresponding Unicode object. Chris@87: Chris@87: errors (if non-NULL) defines the error handling. It defaults Chris@87: to "strict". Chris@87: Chris@87: If byteorder is non-NULL, the decoder starts decoding using the Chris@87: given byte order: Chris@87: Chris@87: *byteorder == -1: little endian Chris@87: *byteorder == 0: native order Chris@87: *byteorder == 1: big endian Chris@87: Chris@87: In native mode, the first four bytes of the stream are checked for a Chris@87: BOM mark. If found, the BOM mark is analysed, the byte order Chris@87: adjusted and the BOM skipped. In the other modes, no BOM mark Chris@87: interpretation is done. After completion, *byteorder is set to the Chris@87: current byte order at the end of input data. Chris@87: Chris@87: If byteorder is NULL, the codec starts in native order mode. Chris@87: Chris@87: */ Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF32( Chris@87: const char *string, /* UTF-32 encoded string */ Chris@87: Py_ssize_t length, /* size of string */ Chris@87: const char *errors, /* error handling */ Chris@87: int *byteorder /* pointer to byteorder to use Chris@87: 0=native;-1=LE,1=BE; updated on Chris@87: exit */ Chris@87: ); Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF32Stateful( Chris@87: const char *string, /* UTF-32 encoded string */ Chris@87: Py_ssize_t length, /* size of string */ Chris@87: const char *errors, /* error handling */ Chris@87: int *byteorder, /* pointer to byteorder to use Chris@87: 0=native;-1=LE,1=BE; updated on Chris@87: exit */ Chris@87: Py_ssize_t *consumed /* bytes consumed */ Chris@87: ); Chris@87: Chris@87: /* Returns a Python string using the UTF-32 encoding in native byte Chris@87: order. The string always starts with a BOM mark. */ Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_AsUTF32String( Chris@87: PyObject *unicode /* Unicode object */ Chris@87: ); Chris@87: Chris@87: /* Returns a Python string object holding the UTF-32 encoded value of Chris@87: the Unicode data. Chris@87: Chris@87: If byteorder is not 0, output is written according to the following Chris@87: byte order: Chris@87: Chris@87: byteorder == -1: little endian Chris@87: byteorder == 0: native byte order (writes a BOM mark) Chris@87: byteorder == 1: big endian Chris@87: Chris@87: If byteorder is 0, the output string will always start with the Chris@87: Unicode BOM mark (U+FEFF). In the other two modes, no BOM mark is Chris@87: prepended. Chris@87: Chris@87: */ Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF32( Chris@87: const Py_UNICODE *data, /* Unicode char buffer */ Chris@87: Py_ssize_t length, /* number of Py_UNICODE chars to encode */ Chris@87: const char *errors, /* error handling */ Chris@87: int byteorder /* byteorder to use 0=BOM+native;-1=LE,1=BE */ Chris@87: ); Chris@87: Chris@87: /* --- UTF-16 Codecs ------------------------------------------------------ */ Chris@87: Chris@87: /* Decodes length bytes from a UTF-16 encoded buffer string and returns Chris@87: the corresponding Unicode object. Chris@87: Chris@87: errors (if non-NULL) defines the error handling. It defaults Chris@87: to "strict". Chris@87: Chris@87: If byteorder is non-NULL, the decoder starts decoding using the Chris@87: given byte order: Chris@87: Chris@87: *byteorder == -1: little endian Chris@87: *byteorder == 0: native order Chris@87: *byteorder == 1: big endian Chris@87: Chris@87: In native mode, the first two bytes of the stream are checked for a Chris@87: BOM mark. If found, the BOM mark is analysed, the byte order Chris@87: adjusted and the BOM skipped. In the other modes, no BOM mark Chris@87: interpretation is done. After completion, *byteorder is set to the Chris@87: current byte order at the end of input data. Chris@87: Chris@87: If byteorder is NULL, the codec starts in native order mode. Chris@87: Chris@87: */ Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF16( Chris@87: const char *string, /* UTF-16 encoded string */ Chris@87: Py_ssize_t length, /* size of string */ Chris@87: const char *errors, /* error handling */ Chris@87: int *byteorder /* pointer to byteorder to use Chris@87: 0=native;-1=LE,1=BE; updated on Chris@87: exit */ Chris@87: ); Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF16Stateful( Chris@87: const char *string, /* UTF-16 encoded string */ Chris@87: Py_ssize_t length, /* size of string */ Chris@87: const char *errors, /* error handling */ Chris@87: int *byteorder, /* pointer to byteorder to use Chris@87: 0=native;-1=LE,1=BE; updated on Chris@87: exit */ Chris@87: Py_ssize_t *consumed /* bytes consumed */ Chris@87: ); Chris@87: Chris@87: /* Returns a Python string using the UTF-16 encoding in native byte Chris@87: order. The string always starts with a BOM mark. */ Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_AsUTF16String( Chris@87: PyObject *unicode /* Unicode object */ Chris@87: ); Chris@87: Chris@87: /* Returns a Python string object holding the UTF-16 encoded value of Chris@87: the Unicode data. Chris@87: Chris@87: If byteorder is not 0, output is written according to the following Chris@87: byte order: Chris@87: Chris@87: byteorder == -1: little endian Chris@87: byteorder == 0: native byte order (writes a BOM mark) Chris@87: byteorder == 1: big endian Chris@87: Chris@87: If byteorder is 0, the output string will always start with the Chris@87: Unicode BOM mark (U+FEFF). In the other two modes, no BOM mark is Chris@87: prepended. Chris@87: Chris@87: Note that Py_UNICODE data is being interpreted as UTF-16 reduced to Chris@87: UCS-2. This trick makes it possible to add full UTF-16 capabilities Chris@87: at a later point without compromising the APIs. Chris@87: Chris@87: */ Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF16( Chris@87: const Py_UNICODE *data, /* Unicode char buffer */ Chris@87: Py_ssize_t length, /* number of Py_UNICODE chars to encode */ Chris@87: const char *errors, /* error handling */ Chris@87: int byteorder /* byteorder to use 0=BOM+native;-1=LE,1=BE */ Chris@87: ); Chris@87: Chris@87: /* --- Unicode-Escape Codecs ---------------------------------------------- */ Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_DecodeUnicodeEscape( Chris@87: const char *string, /* Unicode-Escape encoded string */ Chris@87: Py_ssize_t length, /* size of string */ Chris@87: const char *errors /* error handling */ Chris@87: ); Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_AsUnicodeEscapeString( Chris@87: PyObject *unicode /* Unicode object */ Chris@87: ); Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_EncodeUnicodeEscape( Chris@87: const Py_UNICODE *data, /* Unicode char buffer */ Chris@87: Py_ssize_t length /* Number of Py_UNICODE chars to encode */ Chris@87: ); Chris@87: Chris@87: /* --- Raw-Unicode-Escape Codecs ------------------------------------------ */ Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_DecodeRawUnicodeEscape( Chris@87: const char *string, /* Raw-Unicode-Escape encoded string */ Chris@87: Py_ssize_t length, /* size of string */ Chris@87: const char *errors /* error handling */ Chris@87: ); Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_AsRawUnicodeEscapeString( Chris@87: PyObject *unicode /* Unicode object */ Chris@87: ); Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_EncodeRawUnicodeEscape( Chris@87: const Py_UNICODE *data, /* Unicode char buffer */ Chris@87: Py_ssize_t length /* Number of Py_UNICODE chars to encode */ Chris@87: ); Chris@87: Chris@87: /* --- Unicode Internal Codec --------------------------------------------- Chris@87: Chris@87: Only for internal use in _codecsmodule.c */ Chris@87: Chris@87: PyObject *_PyUnicode_DecodeUnicodeInternal( Chris@87: const char *string, Chris@87: Py_ssize_t length, Chris@87: const char *errors Chris@87: ); Chris@87: Chris@87: /* --- Latin-1 Codecs ----------------------------------------------------- Chris@87: Chris@87: Note: Latin-1 corresponds to the first 256 Unicode ordinals. Chris@87: Chris@87: */ Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_DecodeLatin1( Chris@87: const char *string, /* Latin-1 encoded string */ Chris@87: Py_ssize_t length, /* size of string */ Chris@87: const char *errors /* error handling */ Chris@87: ); Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_AsLatin1String( Chris@87: PyObject *unicode /* Unicode object */ Chris@87: ); Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_EncodeLatin1( Chris@87: const Py_UNICODE *data, /* Unicode char buffer */ Chris@87: Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ Chris@87: const char *errors /* error handling */ Chris@87: ); Chris@87: Chris@87: /* --- ASCII Codecs ------------------------------------------------------- Chris@87: Chris@87: Only 7-bit ASCII data is excepted. All other codes generate errors. Chris@87: Chris@87: */ Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_DecodeASCII( Chris@87: const char *string, /* ASCII encoded string */ Chris@87: Py_ssize_t length, /* size of string */ Chris@87: const char *errors /* error handling */ Chris@87: ); Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_AsASCIIString( Chris@87: PyObject *unicode /* Unicode object */ Chris@87: ); Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_EncodeASCII( Chris@87: const Py_UNICODE *data, /* Unicode char buffer */ Chris@87: Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ Chris@87: const char *errors /* error handling */ Chris@87: ); Chris@87: Chris@87: /* --- Character Map Codecs ----------------------------------------------- Chris@87: Chris@87: This codec uses mappings to encode and decode characters. Chris@87: Chris@87: Decoding mappings must map single string characters to single Chris@87: Unicode characters, integers (which are then interpreted as Unicode Chris@87: ordinals) or None (meaning "undefined mapping" and causing an Chris@87: error). Chris@87: Chris@87: Encoding mappings must map single Unicode characters to single Chris@87: string characters, integers (which are then interpreted as Latin-1 Chris@87: ordinals) or None (meaning "undefined mapping" and causing an Chris@87: error). Chris@87: Chris@87: If a character lookup fails with a LookupError, the character is Chris@87: copied as-is meaning that its ordinal value will be interpreted as Chris@87: Unicode or Latin-1 ordinal resp. Because of this mappings only need Chris@87: to contain those mappings which map characters to different code Chris@87: points. Chris@87: Chris@87: */ Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_DecodeCharmap( Chris@87: const char *string, /* Encoded string */ Chris@87: Py_ssize_t length, /* size of string */ Chris@87: PyObject *mapping, /* character mapping Chris@87: (char ordinal -> unicode ordinal) */ Chris@87: const char *errors /* error handling */ Chris@87: ); Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_AsCharmapString( Chris@87: PyObject *unicode, /* Unicode object */ Chris@87: PyObject *mapping /* character mapping Chris@87: (unicode ordinal -> char ordinal) */ Chris@87: ); Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_EncodeCharmap( Chris@87: const Py_UNICODE *data, /* Unicode char buffer */ Chris@87: Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ Chris@87: PyObject *mapping, /* character mapping Chris@87: (unicode ordinal -> char ordinal) */ Chris@87: const char *errors /* error handling */ Chris@87: ); Chris@87: Chris@87: /* Translate a Py_UNICODE buffer of the given length by applying a Chris@87: character mapping table to it and return the resulting Unicode Chris@87: object. Chris@87: Chris@87: The mapping table must map Unicode ordinal integers to Unicode Chris@87: ordinal integers or None (causing deletion of the character). Chris@87: Chris@87: Mapping tables may be dictionaries or sequences. Unmapped character Chris@87: ordinals (ones which cause a LookupError) are left untouched and Chris@87: are copied as-is. Chris@87: Chris@87: */ Chris@87: Chris@87: PyAPI_FUNC(PyObject *) PyUnicode_TranslateCharmap( Chris@87: const Py_UNICODE *data, /* Unicode char buffer */ Chris@87: Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ Chris@87: PyObject *table, /* Translate table */ Chris@87: const char *errors /* error handling */ Chris@87: ); Chris@87: Chris@87: #ifdef MS_WIN32 Chris@87: Chris@87: /* --- MBCS codecs for Windows -------------------------------------------- */ Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_DecodeMBCS( Chris@87: const char *string, /* MBCS encoded string */ Chris@87: Py_ssize_t length, /* size of string */ Chris@87: const char *errors /* error handling */ Chris@87: ); Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_DecodeMBCSStateful( Chris@87: const char *string, /* MBCS encoded string */ Chris@87: Py_ssize_t length, /* size of string */ Chris@87: const char *errors, /* error handling */ Chris@87: Py_ssize_t *consumed /* bytes consumed */ Chris@87: ); Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_AsMBCSString( Chris@87: PyObject *unicode /* Unicode object */ Chris@87: ); Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_EncodeMBCS( Chris@87: const Py_UNICODE *data, /* Unicode char buffer */ Chris@87: Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ Chris@87: const char *errors /* error handling */ Chris@87: ); Chris@87: Chris@87: #endif /* MS_WIN32 */ Chris@87: Chris@87: /* --- Decimal Encoder ---------------------------------------------------- */ Chris@87: Chris@87: /* Takes a Unicode string holding a decimal value and writes it into Chris@87: an output buffer using standard ASCII digit codes. Chris@87: Chris@87: The output buffer has to provide at least length+1 bytes of storage Chris@87: area. The output string is 0-terminated. Chris@87: Chris@87: The encoder converts whitespace to ' ', decimal characters to their Chris@87: corresponding ASCII digit and all other Latin-1 characters except Chris@87: \0 as-is. Characters outside this range (Unicode ordinals 1-256) Chris@87: are treated as errors. This includes embedded NULL bytes. Chris@87: Chris@87: Error handling is defined by the errors argument: Chris@87: Chris@87: NULL or "strict": raise a ValueError Chris@87: "ignore": ignore the wrong characters (these are not copied to the Chris@87: output buffer) Chris@87: "replace": replaces illegal characters with '?' Chris@87: Chris@87: Returns 0 on success, -1 on failure. Chris@87: Chris@87: */ Chris@87: Chris@87: PyAPI_FUNC(int) PyUnicode_EncodeDecimal( Chris@87: Py_UNICODE *s, /* Unicode buffer */ Chris@87: Py_ssize_t length, /* Number of Py_UNICODE chars to encode */ Chris@87: char *output, /* Output buffer; must have size >= length */ Chris@87: const char *errors /* error handling */ Chris@87: ); Chris@87: Chris@87: /* --- Methods & Slots ---------------------------------------------------- Chris@87: Chris@87: These are capable of handling Unicode objects and strings on input Chris@87: (we refer to them as strings in the descriptions) and return Chris@87: Unicode objects or integers as apporpriate. */ Chris@87: Chris@87: /* Concat two strings giving a new Unicode string. */ Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_Concat( Chris@87: PyObject *left, /* Left string */ Chris@87: PyObject *right /* Right string */ Chris@87: ); Chris@87: Chris@87: /* Split a string giving a list of Unicode strings. Chris@87: Chris@87: If sep is NULL, splitting will be done at all whitespace Chris@87: substrings. Otherwise, splits occur at the given separator. Chris@87: Chris@87: At most maxsplit splits will be done. If negative, no limit is set. Chris@87: Chris@87: Separators are not included in the resulting list. Chris@87: Chris@87: */ Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_Split( Chris@87: PyObject *s, /* String to split */ Chris@87: PyObject *sep, /* String separator */ Chris@87: Py_ssize_t maxsplit /* Maxsplit count */ Chris@87: ); Chris@87: Chris@87: /* Dito, but split at line breaks. Chris@87: Chris@87: CRLF is considered to be one line break. Line breaks are not Chris@87: included in the resulting list. */ Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_Splitlines( Chris@87: PyObject *s, /* String to split */ Chris@87: int keepends /* If true, line end markers are included */ Chris@87: ); Chris@87: Chris@87: /* Partition a string using a given separator. */ Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_Partition( Chris@87: PyObject *s, /* String to partition */ Chris@87: PyObject *sep /* String separator */ Chris@87: ); Chris@87: Chris@87: /* Partition a string using a given separator, searching from the end of the Chris@87: string. */ Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_RPartition( Chris@87: PyObject *s, /* String to partition */ Chris@87: PyObject *sep /* String separator */ Chris@87: ); Chris@87: Chris@87: /* Split a string giving a list of Unicode strings. Chris@87: Chris@87: If sep is NULL, splitting will be done at all whitespace Chris@87: substrings. Otherwise, splits occur at the given separator. Chris@87: Chris@87: At most maxsplit splits will be done. But unlike PyUnicode_Split Chris@87: PyUnicode_RSplit splits from the end of the string. If negative, Chris@87: no limit is set. Chris@87: Chris@87: Separators are not included in the resulting list. Chris@87: Chris@87: */ Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_RSplit( Chris@87: PyObject *s, /* String to split */ Chris@87: PyObject *sep, /* String separator */ Chris@87: Py_ssize_t maxsplit /* Maxsplit count */ Chris@87: ); Chris@87: Chris@87: /* Translate a string by applying a character mapping table to it and Chris@87: return the resulting Unicode object. Chris@87: Chris@87: The mapping table must map Unicode ordinal integers to Unicode Chris@87: ordinal integers or None (causing deletion of the character). Chris@87: Chris@87: Mapping tables may be dictionaries or sequences. Unmapped character Chris@87: ordinals (ones which cause a LookupError) are left untouched and Chris@87: are copied as-is. Chris@87: Chris@87: */ Chris@87: Chris@87: PyAPI_FUNC(PyObject *) PyUnicode_Translate( Chris@87: PyObject *str, /* String */ Chris@87: PyObject *table, /* Translate table */ Chris@87: const char *errors /* error handling */ Chris@87: ); Chris@87: Chris@87: /* Join a sequence of strings using the given separator and return Chris@87: the resulting Unicode string. */ Chris@87: Chris@87: PyAPI_FUNC(PyObject*) PyUnicode_Join( Chris@87: PyObject *separator, /* Separator string */ Chris@87: PyObject *seq /* Sequence object */ Chris@87: ); Chris@87: Chris@87: /* Return 1 if substr matches str[start:end] at the given tail end, 0 Chris@87: otherwise. */ Chris@87: Chris@87: PyAPI_FUNC(Py_ssize_t) PyUnicode_Tailmatch( Chris@87: PyObject *str, /* String */ Chris@87: PyObject *substr, /* Prefix or Suffix string */ Chris@87: Py_ssize_t start, /* Start index */ Chris@87: Py_ssize_t end, /* Stop index */ Chris@87: int direction /* Tail end: -1 prefix, +1 suffix */ Chris@87: ); Chris@87: Chris@87: /* Return the first position of substr in str[start:end] using the Chris@87: given search direction or -1 if not found. -2 is returned in case Chris@87: an error occurred and an exception is set. */ Chris@87: Chris@87: PyAPI_FUNC(Py_ssize_t) PyUnicode_Find( Chris@87: PyObject *str, /* String */ Chris@87: PyObject *substr, /* Substring to find */ Chris@87: Py_ssize_t start, /* Start index */ Chris@87: Py_ssize_t end, /* Stop index */ Chris@87: int direction /* Find direction: +1 forward, -1 backward */ Chris@87: ); Chris@87: Chris@87: /* Count the number of occurrences of substr in str[start:end]. */ Chris@87: Chris@87: PyAPI_FUNC(Py_ssize_t) PyUnicode_Count( Chris@87: PyObject *str, /* String */ Chris@87: PyObject *substr, /* Substring to count */ Chris@87: Py_ssize_t start, /* Start index */ Chris@87: Py_ssize_t end /* Stop index */ Chris@87: ); Chris@87: Chris@87: /* Replace at most maxcount occurrences of substr in str with replstr Chris@87: and return the resulting Unicode object. */ Chris@87: Chris@87: PyAPI_FUNC(PyObject *) PyUnicode_Replace( Chris@87: PyObject *str, /* String */ Chris@87: PyObject *substr, /* Substring to find */ Chris@87: PyObject *replstr, /* Substring to replace */ Chris@87: Py_ssize_t maxcount /* Max. number of replacements to apply; Chris@87: -1 = all */ Chris@87: ); Chris@87: Chris@87: /* Compare two strings and return -1, 0, 1 for less than, equal, Chris@87: greater than resp. */ Chris@87: Chris@87: PyAPI_FUNC(int) PyUnicode_Compare( Chris@87: PyObject *left, /* Left string */ Chris@87: PyObject *right /* Right string */ Chris@87: ); Chris@87: Chris@87: /* Rich compare two strings and return one of the following: Chris@87: Chris@87: - NULL in case an exception was raised Chris@87: - Py_True or Py_False for successfuly comparisons Chris@87: - Py_NotImplemented in case the type combination is unknown Chris@87: Chris@87: Note that Py_EQ and Py_NE comparisons can cause a UnicodeWarning in Chris@87: case the conversion of the arguments to Unicode fails with a Chris@87: UnicodeDecodeError. Chris@87: Chris@87: Possible values for op: Chris@87: Chris@87: Py_GT, Py_GE, Py_EQ, Py_NE, Py_LT, Py_LE Chris@87: Chris@87: */ Chris@87: Chris@87: PyAPI_FUNC(PyObject *) PyUnicode_RichCompare( Chris@87: PyObject *left, /* Left string */ Chris@87: PyObject *right, /* Right string */ Chris@87: int op /* Operation: Py_EQ, Py_NE, Py_GT, etc. */ Chris@87: ); Chris@87: Chris@87: /* Apply a argument tuple or dictionary to a format string and return Chris@87: the resulting Unicode string. */ Chris@87: Chris@87: PyAPI_FUNC(PyObject *) PyUnicode_Format( Chris@87: PyObject *format, /* Format string */ Chris@87: PyObject *args /* Argument tuple or dictionary */ Chris@87: ); Chris@87: Chris@87: /* Checks whether element is contained in container and return 1/0 Chris@87: accordingly. Chris@87: Chris@87: element has to coerce to an one element Unicode string. -1 is Chris@87: returned in case of an error. */ Chris@87: Chris@87: PyAPI_FUNC(int) PyUnicode_Contains( Chris@87: PyObject *container, /* Container string */ Chris@87: PyObject *element /* Element string */ Chris@87: ); Chris@87: Chris@87: /* Externally visible for str.strip(unicode) */ Chris@87: PyAPI_FUNC(PyObject *) _PyUnicode_XStrip( Chris@87: PyUnicodeObject *self, Chris@87: int striptype, Chris@87: PyObject *sepobj Chris@87: ); Chris@87: Chris@87: /* === Characters Type APIs =============================================== */ Chris@87: Chris@87: /* Helper array used by Py_UNICODE_ISSPACE(). */ Chris@87: Chris@87: PyAPI_DATA(const unsigned char) _Py_ascii_whitespace[]; Chris@87: Chris@87: /* These should not be used directly. Use the Py_UNICODE_IS* and Chris@87: Py_UNICODE_TO* macros instead. Chris@87: Chris@87: These APIs are implemented in Objects/unicodectype.c. Chris@87: Chris@87: */ Chris@87: Chris@87: PyAPI_FUNC(int) _PyUnicode_IsLowercase( Chris@87: Py_UNICODE ch /* Unicode character */ Chris@87: ); Chris@87: Chris@87: PyAPI_FUNC(int) _PyUnicode_IsUppercase( Chris@87: Py_UNICODE ch /* Unicode character */ Chris@87: ); Chris@87: Chris@87: PyAPI_FUNC(int) _PyUnicode_IsTitlecase( Chris@87: Py_UNICODE ch /* Unicode character */ Chris@87: ); Chris@87: Chris@87: PyAPI_FUNC(int) _PyUnicode_IsWhitespace( Chris@87: const Py_UNICODE ch /* Unicode character */ Chris@87: ); Chris@87: Chris@87: PyAPI_FUNC(int) _PyUnicode_IsLinebreak( Chris@87: const Py_UNICODE ch /* Unicode character */ Chris@87: ); Chris@87: Chris@87: PyAPI_FUNC(Py_UNICODE) _PyUnicode_ToLowercase( Chris@87: Py_UNICODE ch /* Unicode character */ Chris@87: ); Chris@87: Chris@87: PyAPI_FUNC(Py_UNICODE) _PyUnicode_ToUppercase( Chris@87: Py_UNICODE ch /* Unicode character */ Chris@87: ); Chris@87: Chris@87: PyAPI_FUNC(Py_UNICODE) _PyUnicode_ToTitlecase( Chris@87: Py_UNICODE ch /* Unicode character */ Chris@87: ); Chris@87: Chris@87: PyAPI_FUNC(int) _PyUnicode_ToDecimalDigit( Chris@87: Py_UNICODE ch /* Unicode character */ Chris@87: ); Chris@87: Chris@87: PyAPI_FUNC(int) _PyUnicode_ToDigit( Chris@87: Py_UNICODE ch /* Unicode character */ Chris@87: ); Chris@87: Chris@87: PyAPI_FUNC(double) _PyUnicode_ToNumeric( Chris@87: Py_UNICODE ch /* Unicode character */ Chris@87: ); Chris@87: Chris@87: PyAPI_FUNC(int) _PyUnicode_IsDecimalDigit( Chris@87: Py_UNICODE ch /* Unicode character */ Chris@87: ); Chris@87: Chris@87: PyAPI_FUNC(int) _PyUnicode_IsDigit( Chris@87: Py_UNICODE ch /* Unicode character */ Chris@87: ); Chris@87: Chris@87: PyAPI_FUNC(int) _PyUnicode_IsNumeric( Chris@87: Py_UNICODE ch /* Unicode character */ Chris@87: ); Chris@87: Chris@87: PyAPI_FUNC(int) _PyUnicode_IsAlpha( Chris@87: Py_UNICODE ch /* Unicode character */ Chris@87: ); Chris@87: Chris@87: #ifdef __cplusplus Chris@87: } Chris@87: #endif Chris@87: #endif /* Py_USING_UNICODE */ Chris@87: #endif /* !Py_UNICODEOBJECT_H */