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