diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2023-10-11 13:41:58 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-11 13:41:58 (GMT) |
commit | eb50cd37eac47dd4dc71ab42d0582dfb6eac4515 (patch) | |
tree | 410d6c0c88cb2c223cace999b490a6adce642e8f /Doc/c-api/unicode.rst | |
parent | d1f7fae424d51b0374c8204599583c4a26c1a992 (diff) | |
download | cpython-eb50cd37eac47dd4dc71ab42d0582dfb6eac4515.zip cpython-eb50cd37eac47dd4dc71ab42d0582dfb6eac4515.tar.gz cpython-eb50cd37eac47dd4dc71ab42d0582dfb6eac4515.tar.bz2 |
gh-110289: C API: Add PyUnicode_EqualToUTF8() and PyUnicode_EqualToUTF8AndSize() functions (GH-110297)
Diffstat (limited to 'Doc/c-api/unicode.rst')
-rw-r--r-- | Doc/c-api/unicode.rst | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Doc/c-api/unicode.rst b/Doc/c-api/unicode.rst index 2a2cb1b..5ab9f1c 100644 --- a/Doc/c-api/unicode.rst +++ b/Doc/c-api/unicode.rst @@ -1396,6 +1396,28 @@ They all return ``NULL`` or ``-1`` if an exception occurs. :c:func:`PyErr_Occurred` to check for errors. +.. c:function:: int PyUnicode_EqualToUTF8AndSize(PyObject *unicode, const char *string, Py_ssize_t size) + + Compare a Unicode object with a char buffer which is interpreted as + being UTF-8 or ASCII encoded and return true (``1``) if they are equal, + or false (``0``) otherwise. + If the Unicode object contains surrogate characters or + the C string is not valid UTF-8, false (``0``) is returned. + + This function does not raise exceptions. + + .. versionadded:: 3.13 + + +.. c:function:: int PyUnicode_EqualToUTF8(PyObject *unicode, const char *string) + + Similar to :c:func:`PyUnicode_EqualToUTF8AndSize`, but compute *string* + length using :c:func:`!strlen`. + If the Unicode object contains null characters, false (``0``) is returned. + + .. versionadded:: 3.13 + + .. c:function:: int PyUnicode_CompareWithASCIIString(PyObject *uni, const char *string) Compare a Unicode object, *uni*, with *string* and return ``-1``, ``0``, ``1`` for less |