Address GvR's comments.
This commit is contained in:
parent
1e71d17be4
commit
522efc8efa
63
pep-0393.txt
63
pep-0393.txt
|
@ -19,7 +19,8 @@ ordinal (1, 2, or 4 bytes). This will allow a space-efficient
|
|||
representation in common cases, but give access to full UCS-4 on all
|
||||
systems. For compatibility with existing APIs, several representations
|
||||
may exist in parallel; over time, this compatibility should be phased
|
||||
out.
|
||||
out. The distinction between narrow and wide Unicode builds is
|
||||
dropped. An implementation of this PEP is available at [1]_.
|
||||
|
||||
Rationale
|
||||
=========
|
||||
|
@ -206,10 +207,62 @@ should use the existing PyUnicode_AsUTF8String where possible
|
|||
converts a string to a char* (such as the ParseTuple functions) will
|
||||
use PyUnicode_AsUTF8 to compute a conversion.
|
||||
|
||||
New API
|
||||
-------
|
||||
|
||||
This section summarizes the API additions.
|
||||
|
||||
Macros to access the internal representation of a Unicode object
|
||||
(read-only):
|
||||
|
||||
- PyUnicode_IS_COMPACT_ASCII(o), PyUnicode_IS_COMPACT(o),
|
||||
PyUnicode_IS_READY(o)
|
||||
- PyUnicode_GET_LENGTH(o)
|
||||
- PyUnicode_KIND(o), PyUnicode_CHARACTER_SIZE(o),
|
||||
PyUnicode_MAX_CHAR_VALUE(o)
|
||||
- PyUnicode_DATA(o), PyUnicode_1BYTE_DATA(o), PyUnicode_2BYTE_DATA(o),
|
||||
PyUnicode_4BYTE_DATA(o)
|
||||
|
||||
Character access macros:
|
||||
|
||||
- PyUnicode_READ(kind, data, index), PyUnicode_READ_CHAR(o, index)
|
||||
- PyUnicode_WRITE(kind, data, index, value)
|
||||
|
||||
Other macros:
|
||||
|
||||
- PyUnicode_READY(o)
|
||||
- PyUnicode_CONVERT_BYTES(from_type, tp_type, begin, end, to)
|
||||
|
||||
String creation functions:
|
||||
|
||||
- PyUnicode_New(size, maxchar)
|
||||
- PyUnicode_FromKindAndData(kind, data, size)
|
||||
- PyUnicode_Substring(o, start, end)
|
||||
- PyUnicode_Chr(ch)
|
||||
|
||||
Character access utility functions:
|
||||
|
||||
- PyUnicode_CopyCharacters(to, to_start, from, from_start, how_many)
|
||||
- PyUnicode_FindChar(str, ch, start, end, direction)
|
||||
|
||||
Representation conversion:
|
||||
|
||||
- PyUnicode_AsUCS4(o, buffer, buflen)
|
||||
- PyUnicode_AsUCS4Copy(o)
|
||||
- PyUnicode_AsUnicodeAndSize(o, size_out)
|
||||
- PyUnicode_AsUTF8(o)
|
||||
- PyUnicode_AsUTF8AndSize(o, size_out)
|
||||
|
||||
UCS4 utility functions:
|
||||
|
||||
- Py_UCS4_{strlen, strcpy, strcat, strncpy, strcmp, strncpy, strcmp,
|
||||
strncmp, strchr, strrchr}
|
||||
|
||||
Stable ABI
|
||||
----------
|
||||
|
||||
None of the functions in this PEP become part of the stable ABI.
|
||||
None of the functions in this PEP become part of the stable ABI
|
||||
(PEP 384).
|
||||
|
||||
GDB Debugging Hooks
|
||||
-------------------
|
||||
|
@ -363,6 +416,12 @@ be necessary: PyUnicode_Find, PyUnicode_FindChar, PyUnicode_Ord, and
|
|||
PyUnicode_CopyCharacters help in analyzing and creating string
|
||||
objects, operating on indices instead of data pointers.
|
||||
|
||||
References
|
||||
==========
|
||||
|
||||
.. [1] PEP 393 branch
|
||||
https://bitbucket.org/t0rsten/pep-393
|
||||
|
||||
Copyright
|
||||
=========
|
||||
|
||||
|
|
Loading…
Reference in New Issue