diff options
author | Marc-André Lemburg <mal@egenix.com> | 2008-06-06 12:18:17 (GMT) |
---|---|---|
committer | Marc-André Lemburg <mal@egenix.com> | 2008-06-06 12:18:17 (GMT) |
commit | b2750b5d334e9c8d262009069bce41c15803eca0 (patch) | |
tree | 2c501adf96b37d3afbc32e6fdc344fade85cf3d5 /Include | |
parent | 4efb518185d32d573ff65f11b94c6031340a018a (diff) | |
download | cpython-b2750b5d334e9c8d262009069bce41c15803eca0.zip cpython-b2750b5d334e9c8d262009069bce41c15803eca0.tar.gz cpython-b2750b5d334e9c8d262009069bce41c15803eca0.tar.bz2 |
Move the codec decode type checks to bytes/bytearray.decode().
Use faster PyUnicode_FromEncodedObject() for bytes/bytearray.decode().
Add new PyCodec_KnownEncoding() API.
Add new PyUnicode_AsDecodedUnicode() and PyUnicode_AsEncodedUnicode() APIs.
Add missing PyUnicode_AsDecodedObject() to unicodeobject.h
Fix punicode codec to also work on memoryviews.
Diffstat (limited to 'Include')
-rw-r--r-- | Include/codecs.h | 13 | ||||
-rw-r--r-- | Include/unicodeobject.h | 36 |
2 files changed, 47 insertions, 2 deletions
diff --git a/Include/codecs.h b/Include/codecs.h index 0d76241..c979e86 100644 --- a/Include/codecs.h +++ b/Include/codecs.h @@ -27,7 +27,7 @@ PyAPI_FUNC(int) PyCodec_Register( PyObject *search_function ); -/* Codec register lookup API. +/* Codec registry lookup API. Looks up the given encoding and returns a CodecInfo object with function attributes which implement the different aspects of @@ -49,6 +49,17 @@ PyAPI_FUNC(PyObject *) _PyCodec_Lookup( const char *encoding ); +/* Codec registry encoding check API. + + Returns 1/0 depending on whether there is a registered codec for + the given encoding. + +*/ + +PyAPI_FUNC(int) PyCodec_KnownEncoding( + const char *encoding + ); + /* Generic codec based encoding API. object is passed through the encoder function found for the given diff --git a/Include/unicodeobject.h b/Include/unicodeobject.h index 384cd55..7af2eba 100644 --- a/Include/unicodeobject.h +++ b/Include/unicodeobject.h @@ -139,8 +139,11 @@ typedef PY_UNICODE_TYPE Py_UNICODE; # define PyUnicode_AsASCIIString PyUnicodeUCS2_AsASCIIString # define PyUnicode_AsCharmapString PyUnicodeUCS2_AsCharmapString +# define PyUnicode_AsDecodedObject PyUnicodeUCS2_AsDecodedObject +# define PyUnicode_AsDecodedUnicode PyUnicodeUCS2_AsDecodedUnicode # define PyUnicode_AsEncodedObject PyUnicodeUCS2_AsEncodedObject # define PyUnicode_AsEncodedString PyUnicodeUCS2_AsEncodedString +# define PyUnicode_AsEncodedUnicode PyUnicodeUCS2_AsEncodedUnicode # define PyUnicode_AsLatin1String PyUnicodeUCS2_AsLatin1String # define PyUnicode_AsRawUnicodeEscapeString PyUnicodeUCS2_AsRawUnicodeEscapeString # define PyUnicode_AsUTF32String PyUnicodeUCS2_AsUTF32String @@ -233,8 +236,11 @@ typedef PY_UNICODE_TYPE Py_UNICODE; # define PyUnicode_AsASCIIString PyUnicodeUCS4_AsASCIIString # define PyUnicode_AsCharmapString PyUnicodeUCS4_AsCharmapString +# define PyUnicode_AsDecodedObject PyUnicodeUCS4_AsDecodedObject +# define PyUnicode_AsDecodedUnicode PyUnicodeUCS4_AsDecodedUnicode # define PyUnicode_AsEncodedObject PyUnicodeUCS4_AsEncodedObject # define PyUnicode_AsEncodedString PyUnicodeUCS4_AsEncodedString +# define PyUnicode_AsEncodedUnicode PyUnicodeUCS4_AsEncodedUnicode # define PyUnicode_AsLatin1String PyUnicodeUCS4_AsLatin1String # define PyUnicode_AsRawUnicodeEscapeString PyUnicodeUCS4_AsRawUnicodeEscapeString # define PyUnicode_AsUTF32String PyUnicodeUCS4_AsUTF32String @@ -744,6 +750,24 @@ PyAPI_FUNC(PyObject*) PyUnicode_Decode( const char *errors /* error handling */ ); +/* Decode a Unicode object unicode and return the result as Python + object. */ + +PyAPI_FUNC(PyObject*) PyUnicode_AsDecodedObject( + PyObject *unicode, /* Unicode object */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + +/* Decode a Unicode object unicode and return the result as Unicode + object. */ + +PyAPI_FUNC(PyObject*) PyUnicode_AsDecodedUnicode( + PyObject *unicode, /* Unicode object */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + /* Encodes a Py_UNICODE buffer of the given size and returns a Python string object. */ @@ -772,11 +796,21 @@ PyAPI_FUNC(PyObject*) PyUnicode_AsEncodedString( const char *errors /* error handling */ ); +/* Encodes a Unicode object and returns the result as Unicode + object. */ + +PyAPI_FUNC(PyObject*) PyUnicode_AsEncodedUnicode( + PyObject *unicode, /* Unicode object */ + const char *encoding, /* encoding */ + const char *errors /* error handling */ + ); + +/* Build an encoding map. */ + PyAPI_FUNC(PyObject*) PyUnicode_BuildEncodingMap( PyObject* string /* 256 character map */ ); - /* --- UTF-7 Codecs ------------------------------------------------------- */ PyAPI_FUNC(PyObject*) PyUnicode_DecodeUTF7( |