mirror of
https://github.com/python/cpython.git
synced 2025-08-30 05:35:08 +00:00
Add PyUnicode_AsStringAndSize(), which is like PyUnicode_AsString() but
has an extra (optional) output parameter through which it returns the size. Use this in a few places where I used PyUnicode_AsString() + strlen(), and in one new place (which fixes test_pep263).
This commit is contained in:
parent
9befa93b04
commit
7d1df6c9b1
4 changed files with 31 additions and 17 deletions
|
@ -641,20 +641,25 @@ PyAPI_FUNC(PyObject*) PyUnicode_FromOrdinal(int ordinal);
|
|||
PyAPI_FUNC(PyObject *) _PyUnicode_AsDefaultEncodedString(
|
||||
PyObject *, const char *);
|
||||
|
||||
/* Return a char* holding the default encoded value of the
|
||||
Unicode object.
|
||||
/* Return a char* holding the UTF-8 encoded value of the
|
||||
Unicode object.
|
||||
|
||||
DEPRECATED: use PyUnicode_AsStringAndSize() instead.
|
||||
*/
|
||||
|
||||
PyAPI_FUNC(char *) PyUnicode_AsStringAndSize(PyObject*, Py_ssize_t *);
|
||||
|
||||
/* Returns the UTF-8 encoding, and its size.
|
||||
|
||||
If the output argument is NULL, no size is stored.
|
||||
*/
|
||||
|
||||
PyAPI_FUNC(char *) PyUnicode_AsString(PyObject*);
|
||||
|
||||
/* Returns the UTF-8 encoding.
|
||||
|
||||
/* Returns the currently active default encoding.
|
||||
This is equivalent to PyUnicode_AsStringAndSize(x, NULL).
|
||||
|
||||
The default encoding is currently implemented as run-time settable
|
||||
process global. This may change in future versions of the
|
||||
interpreter to become a parameter which is managed on a per-thread
|
||||
basis.
|
||||
|
||||
*/
|
||||
|
||||
PyAPI_FUNC(const char*) PyUnicode_GetDefaultEncoding(void);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue