diff options
Diffstat (limited to 'Include/unicodeobject.h')
-rw-r--r-- | Include/unicodeobject.h | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/Include/unicodeobject.h b/Include/unicodeobject.h index 477f526..50efe72 100644 --- a/Include/unicodeobject.h +++ b/Include/unicodeobject.h @@ -109,6 +109,10 @@ Copyright (c) Corporation for National Research Initiatives. # endif #endif +#if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T) +# define HAVE_MBCS +#endif + #ifdef HAVE_WCHAR_H /* Work around a cosmetic bug in BSDI 4.x wchar.h; thanks to Thomas Wouters */ # ifdef _HAVE_BSDI @@ -358,6 +362,15 @@ typedef PY_UNICODE_TYPE Py_UNICODE; for (i_ = 0; i_ < (length); i_++) t_[i_] = v_;\ } while (0) +/* macros to work with surrogates */ +#define Py_UNICODE_IS_SURROGATE(ch) (0xD800 <= ch && ch <= 0xDFFF) +#define Py_UNICODE_IS_HIGH_SURROGATE(ch) (0xD800 <= ch && ch <= 0xDBFF) +#define Py_UNICODE_IS_LOW_SURROGATE(ch) (0xDC00 <= ch && ch <= 0xDFFF) +/* Join two surrogate characters and return a single Py_UCS4 value. */ +#define Py_UNICODE_JOIN_SURROGATES(high, low) \ + (((((Py_UCS4)(high) & 0x03FF) << 10) | \ + ((Py_UCS4)(low) & 0x03FF)) + 0x10000) + /* Check if substring matches at given offset. The offset must be valid, and the substring must not be empty. */ @@ -668,8 +681,7 @@ PyAPI_FUNC(int) PyUnicode_ClearFreeList(void); #ifndef Py_LIMITED_API PyAPI_FUNC(PyObject *) _PyUnicode_AsDefaultEncodedString( - PyObject *unicode, - const char *errors); + PyObject *unicode); #endif /* Returns a pointer to the default encoding (UTF-8) of the @@ -1163,7 +1175,7 @@ PyAPI_FUNC(PyObject *) PyUnicode_TranslateCharmap( ); #endif -#ifdef MS_WIN32 +#ifdef HAVE_MBCS /* --- MBCS codecs for Windows -------------------------------------------- */ @@ -1192,7 +1204,7 @@ PyAPI_FUNC(PyObject*) PyUnicode_EncodeMBCS( ); #endif -#endif /* MS_WIN32 */ +#endif /* HAVE_MBCS */ /* --- Decimal Encoder ---------------------------------------------------- */ |