Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c1f0577

Browse files
committed
#11840: Merge with 3.1.
2 parents eb22db0 + 95cd91c commit c1f0577

1 file changed

Lines changed: 31 additions & 33 deletions

File tree

Doc/c-api/unicode.rst

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ APIs:
331331
.. c:function:: PyObject* PyUnicode_TransformDecimalToASCII(Py_UNICODE *s, Py_ssize_t size)
332332
333333
Create a Unicode object by replacing all decimal digits in
334-
:c:type:`Py_UNICODE` buffer of the given size by ASCII digits 0--9
334+
:c:type:`Py_UNICODE` buffer of the given *size* by ASCII digits 0--9
335335
according to their decimal value. Return *NULL* if an exception
336336
occurs.
337337
@@ -344,7 +344,7 @@ APIs:
344344
345345
.. c:function:: Py_UNICODE* PyUnicode_AsUnicodeCopy(PyObject *unicode)
346346
347-
Create a copy of a unicode string ending with a nul character. Return *NULL*
347+
Create a copy of a Unicode string ending with a nul character. Return *NULL*
348348
and raise a :exc:`MemoryError` exception on memory allocation failure,
349349
otherwise return a new allocated buffer (use :c:func:`PyMem_Free` to free the
350350
buffer).
@@ -363,8 +363,8 @@ APIs:
363363
incremented refcount.
364364
365365
:class:`bytes`, :class:`bytearray` and other char buffer compatible objects
366-
are decoded according to the given encoding and using the error handling
367-
defined by errors. Both can be *NULL* to have the interface use the default
366+
are decoded according to the given *encoding* and using the error handling
367+
defined by *errors*. Both can be *NULL* to have the interface use the default
368368
values (see the next section for details).
369369
370370
All other objects, including Unicode objects, cause a :exc:`TypeError` to be
@@ -458,12 +458,12 @@ used, passing :c:func:`PyUnicode_FSDecoder` as the conversion function:
458458
wchar_t Support
459459
"""""""""""""""
460460
461-
wchar_t support for platforms which support it:
461+
:c:type:`wchar_t` support for platforms which support it:
462462
463463
.. c:function:: PyObject* PyUnicode_FromWideChar(const wchar_t *w, Py_ssize_t size)
464464
465-
Create a Unicode object from the :c:type:`wchar_t` buffer *w* of the given size.
466-
Passing -1 as the size indicates that the function must itself compute the length,
465+
Create a Unicode object from the :c:type:`wchar_t` buffer *w* of the given *size*.
466+
Passing -1 as the *size* indicates that the function must itself compute the length,
467467
using wcslen.
468468
Return *NULL* on failure.
469469
@@ -501,15 +501,15 @@ Built-in Codecs
501501
Python provides a set of built-in codecs which are written in C for speed. All of
502502
these codecs are directly usable via the following functions.
503503
504-
Many of the following APIs take two arguments encoding and errors. These
505-
parameters encoding and errors have the same semantics as the ones of the
506-
built-in :func:`str` string object constructor.
504+
Many of the following APIs take two arguments encoding and errors, and they
505+
have the same semantics as the ones of the built-in :func:`str` string object
506+
constructor.
507507
508508
Setting encoding to *NULL* causes the default encoding to be used
509509
which is ASCII. The file system calls should use
510510
:c:func:`PyUnicode_FSConverter` for encoding file names. This uses the
511511
variable :c:data:`Py_FileSystemDefaultEncoding` internally. This
512-
variable should be treated as read-only: On some systems, it will be a
512+
variable should be treated as read-only: on some systems, it will be a
513513
pointer to a static string, on others, it will change at run-time
514514
(such as when the application invokes setlocale).
515515
@@ -538,7 +538,7 @@ These are the generic codec APIs:
538538
539539
.. c:function:: PyObject* PyUnicode_Encode(const Py_UNICODE *s, Py_ssize_t size, const char *encoding, const char *errors)
540540
541-
Encode the :c:type:`Py_UNICODE` buffer of the given size and return a Python
541+
Encode the :c:type:`Py_UNICODE` buffer *s* of the given *size* and return a Python
542542
bytes object. *encoding* and *errors* have the same meaning as the
543543
parameters of the same name in the Unicode :meth:`encode` method. The codec
544544
to be used is looked up using the Python codec registry. Return *NULL* if an
@@ -576,7 +576,7 @@ These are the UTF-8 codec APIs:
576576
577577
.. c:function:: PyObject* PyUnicode_EncodeUTF8(const Py_UNICODE *s, Py_ssize_t size, const char *errors)
578578
579-
Encode the :c:type:`Py_UNICODE` buffer of the given size using UTF-8 and
579+
Encode the :c:type:`Py_UNICODE` buffer *s* of the given *size* using UTF-8 and
580580
return a Python bytes object. Return *NULL* if an exception was raised by
581581
the codec.
582582
@@ -596,7 +596,7 @@ These are the UTF-32 codec APIs:
596596
597597
.. c:function:: PyObject* PyUnicode_DecodeUTF32(const char *s, Py_ssize_t size, const char *errors, int *byteorder)
598598
599-
Decode *length* bytes from a UTF-32 encoded buffer string and return the
599+
Decode *size* bytes from a UTF-32 encoded buffer string and return the
600600
corresponding Unicode object. *errors* (if non-*NULL*) defines the error
601601
handling. It defaults to "strict".
602602
@@ -664,7 +664,7 @@ These are the UTF-16 codec APIs:
664664
665665
.. c:function:: PyObject* PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors, int *byteorder)
666666
667-
Decode *length* bytes from a UTF-16 encoded buffer string and return the
667+
Decode *size* bytes from a UTF-16 encoded buffer string and return the
668668
corresponding Unicode object. *errors* (if non-*NULL*) defines the error
669669
handling. It defaults to "strict".
670670
@@ -770,7 +770,7 @@ These are the "Unicode Escape" codec APIs:
770770
771771
.. c:function:: PyObject* PyUnicode_EncodeUnicodeEscape(const Py_UNICODE *s, Py_ssize_t size)
772772
773-
Encode the :c:type:`Py_UNICODE` buffer of the given size using Unicode-Escape and
773+
Encode the :c:type:`Py_UNICODE` buffer of the given *size* using Unicode-Escape and
774774
return a Python string object. Return *NULL* if an exception was raised by the
775775
codec.
776776
@@ -796,7 +796,7 @@ These are the "Raw Unicode Escape" codec APIs:
796796
797797
.. c:function:: PyObject* PyUnicode_EncodeRawUnicodeEscape(const Py_UNICODE *s, Py_ssize_t size, const char *errors)
798798
799-
Encode the :c:type:`Py_UNICODE` buffer of the given size using Raw-Unicode-Escape
799+
Encode the :c:type:`Py_UNICODE` buffer of the given *size* using Raw-Unicode-Escape
800800
and return a Python string object. Return *NULL* if an exception was raised by
801801
the codec.
802802
@@ -823,7 +823,7 @@ ordinals and only these are accepted by the codecs during encoding.
823823
824824
.. c:function:: PyObject* PyUnicode_EncodeLatin1(const Py_UNICODE *s, Py_ssize_t size, const char *errors)
825825
826-
Encode the :c:type:`Py_UNICODE` buffer of the given size using Latin-1 and
826+
Encode the :c:type:`Py_UNICODE` buffer of the given *size* using Latin-1 and
827827
return a Python bytes object. Return *NULL* if an exception was raised by
828828
the codec.
829829
@@ -850,7 +850,7 @@ codes generate errors.
850850
851851
.. c:function:: PyObject* PyUnicode_EncodeASCII(const Py_UNICODE *s, Py_ssize_t size, const char *errors)
852852
853-
Encode the :c:type:`Py_UNICODE` buffer of the given size using ASCII and
853+
Encode the :c:type:`Py_UNICODE` buffer of the given *size* using ASCII and
854854
return a Python bytes object. Return *NULL* if an exception was raised by
855855
the codec.
856856
@@ -865,8 +865,6 @@ codes generate errors.
865865
Character Map Codecs
866866
""""""""""""""""""""
867867
868-
These are the mapping codec APIs:
869-
870868
This codec is special in that it can be used to implement many different codecs
871869
(and this is in fact what was done to obtain most of the standard codecs
872870
included in the :mod:`encodings` package). The codec uses mapping to encode and
@@ -888,6 +886,7 @@ meaning that its ordinal value will be interpreted as Unicode or Latin-1 ordinal
888886
resp. Because of this, mappings only need to contain those mappings which map
889887
characters to different code points.
890888
889+
These are the mapping codec APIs:
891890
892891
.. c:function:: PyObject* PyUnicode_DecodeCharmap(const char *s, Py_ssize_t size, PyObject *mapping, const char *errors)
893892
@@ -901,7 +900,7 @@ characters to different code points.
901900
902901
.. c:function:: PyObject* PyUnicode_EncodeCharmap(const Py_UNICODE *s, Py_ssize_t size, PyObject *mapping, const char *errors)
903902
904-
Encode the :c:type:`Py_UNICODE` buffer of the given size using the given
903+
Encode the :c:type:`Py_UNICODE` buffer of the given *size* using the given
905904
*mapping* object and return a Python string object. Return *NULL* if an
906905
exception was raised by the codec.
907906
@@ -917,7 +916,7 @@ The following codec API is special in that maps Unicode to Unicode.
917916
918917
.. c:function:: PyObject* PyUnicode_TranslateCharmap(const Py_UNICODE *s, Py_ssize_t size, PyObject *table, const char *errors)
919918
920-
Translate a :c:type:`Py_UNICODE` buffer of the given length by applying a
919+
Translate a :c:type:`Py_UNICODE` buffer of the given *size* by applying a
921920
character mapping *table* to it and return the resulting Unicode object. Return
922921
*NULL* when an exception was raised by the codec.
923922
@@ -929,15 +928,14 @@ The following codec API is special in that maps Unicode to Unicode.
929928
:exc:`LookupError`) are left untouched and are copied as-is.
930929
931930
932-
These are the MBCS codec APIs. They are currently only available on Windows and
933-
use the Win32 MBCS converters to implement the conversions. Note that MBCS (or
934-
DBCS) is a class of encodings, not just one. The target encoding is defined by
935-
the user settings on the machine running the codec.
936-
937931
938932
MBCS codecs for Windows
939933
"""""""""""""""""""""""
940934
935+
These are the MBCS codec APIs. They are currently only available on Windows and
936+
use the Win32 MBCS converters to implement the conversions. Note that MBCS (or
937+
DBCS) is a class of encodings, not just one. The target encoding is defined by
938+
the user settings on the machine running the codec.
941939
942940
.. c:function:: PyObject* PyUnicode_DecodeMBCS(const char *s, Py_ssize_t size, const char *errors)
943941
@@ -955,7 +953,7 @@ MBCS codecs for Windows
955953
956954
.. c:function:: PyObject* PyUnicode_EncodeMBCS(const Py_UNICODE *s, Py_ssize_t size, const char *errors)
957955
958-
Encode the :c:type:`Py_UNICODE` buffer of the given size using MBCS and return
956+
Encode the :c:type:`Py_UNICODE` buffer of the given *size* using MBCS and return
959957
a Python bytes object. Return *NULL* if an exception was raised by the
960958
codec.
961959
@@ -990,7 +988,7 @@ They all return *NULL* or ``-1`` if an exception occurs.
990988
991989
.. c:function:: PyObject* PyUnicode_Split(PyObject *s, PyObject *sep, Py_ssize_t maxsplit)
992990
993-
Split a string giving a list of Unicode strings. If sep is *NULL*, splitting
991+
Split a string giving a list of Unicode strings. If *sep* is *NULL*, splitting
994992
will be done at all whitespace substrings. Otherwise, splits occur at the given
995993
separator. At most *maxsplit* splits will be done. If negative, no limit is
996994
set. Separators are not included in the resulting list.
@@ -1021,20 +1019,20 @@ They all return *NULL* or ``-1`` if an exception occurs.
10211019
10221020
.. c:function:: PyObject* PyUnicode_Join(PyObject *separator, PyObject *seq)
10231021
1024-
Join a sequence of strings using the given separator and return the resulting
1022+
Join a sequence of strings using the given *separator* and return the resulting
10251023
Unicode string.
10261024
10271025
10281026
.. c:function:: int PyUnicode_Tailmatch(PyObject *str, PyObject *substr, Py_ssize_t start, Py_ssize_t end, int direction)
10291027
1030-
Return 1 if *substr* matches *str*[*start*:*end*] at the given tail end
1028+
Return 1 if *substr* matches ``str[start:end]`` at the given tail end
10311029
(*direction* == -1 means to do a prefix match, *direction* == 1 a suffix match),
10321030
0 otherwise. Return ``-1`` if an error occurred.
10331031
10341032
10351033
.. c:function:: Py_ssize_t PyUnicode_Find(PyObject *str, PyObject *substr, Py_ssize_t start, Py_ssize_t end, int direction)
10361034
1037-
Return the first position of *substr* in *str*[*start*:*end*] using the given
1035+
Return the first position of *substr* in ``str[start:end]`` using the given
10381036
*direction* (*direction* == 1 means to do a forward search, *direction* == -1 a
10391037
backward search). The return value is the index of the first match; a value of
10401038
``-1`` indicates that no match was found, and ``-2`` indicates that an error

0 commit comments

Comments
 (0)