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

Skip to content

Commit b6eba4f

Browse files
committed
encoding returns bytes objects
1 parent 8d4e505 commit b6eba4f

1 file changed

Lines changed: 40 additions & 36 deletions

File tree

Doc/c-api/unicode.rst

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -409,19 +409,19 @@ These are the generic codec APIs:
409409
.. cfunction:: PyObject* PyUnicode_Encode(const Py_UNICODE *s, Py_ssize_t size, const char *encoding, const char *errors)
410410

411411
Encode the :ctype:`Py_UNICODE` buffer of the given size and return a Python
412-
string object. *encoding* and *errors* have the same meaning as the parameters
413-
of the same name in the Unicode :meth:`encode` method. The codec to be used is
414-
looked up using the Python codec registry. Return *NULL* if an exception was
415-
raised by the codec.
412+
bytes object. *encoding* and *errors* have the same meaning as the
413+
parameters of the same name in the Unicode :meth:`encode` method. The codec
414+
to be used is looked up using the Python codec registry. Return *NULL* if an
415+
exception was raised by the codec.
416416

417417

418418
.. cfunction:: PyObject* PyUnicode_AsEncodedString(PyObject *unicode, const char *encoding, const char *errors)
419419

420-
Encode a Unicode object and return the result as Python string object.
421-
*encoding* and *errors* have the same meaning as the parameters of the same name
422-
in the Unicode :meth:`encode` method. The codec to be used is looked up using
423-
the Python codec registry. Return *NULL* if an exception was raised by the
424-
codec.
420+
Encode a Unicode object and return the result as Python bytes object.
421+
*encoding* and *errors* have the same meaning as the parameters of the same
422+
name in the Unicode :meth:`encode` method. The codec to be used is looked up
423+
using the Python codec registry. Return *NULL* if an exception was raised by
424+
the codec.
425425

426426
These are the UTF-8 codec APIs:
427427

@@ -444,15 +444,16 @@ These are the UTF-8 codec APIs:
444444

445445
.. cfunction:: PyObject* PyUnicode_EncodeUTF8(const Py_UNICODE *s, Py_ssize_t size, const char *errors)
446446

447-
Encode the :ctype:`Py_UNICODE` buffer of the given size using UTF-8 and return a
448-
Python string object. Return *NULL* if an exception was raised by the codec.
447+
Encode the :ctype:`Py_UNICODE` buffer of the given size using UTF-8 and
448+
return a Python bytes object. Return *NULL* if an exception was raised by
449+
the codec.
449450

450451

451452
.. cfunction:: PyObject* PyUnicode_AsUTF8String(PyObject *unicode)
452453

453-
Encode a Unicode object using UTF-8 and return the result as Python string
454-
object. Error handling is "strict". Return *NULL* if an exception was raised
455-
by the codec.
454+
Encode a Unicode object using UTF-8 and return the result as Python bytes
455+
object. Error handling is "strict". Return *NULL* if an exception was
456+
raised by the codec.
456457

457458
These are the UTF-32 codec APIs:
458459

@@ -514,9 +515,9 @@ These are the UTF-32 codec APIs:
514515

515516
.. cfunction:: PyObject* PyUnicode_AsUTF32String(PyObject *unicode)
516517

517-
Return a Python string using the UTF-32 encoding in native byte order. The
518-
string always starts with a BOM mark. Error handling is "strict". Return
519-
*NULL* if an exception was raised by the codec.
518+
Return a Python byte string using the UTF-32 encoding in native byte
519+
order. The string always starts with a BOM mark. Error handling is "strict".
520+
Return *NULL* if an exception was raised by the codec.
520521

521522

522523
These are the UTF-16 codec APIs:
@@ -558,7 +559,7 @@ These are the UTF-16 codec APIs:
558559

559560
.. cfunction:: PyObject* PyUnicode_EncodeUTF16(const Py_UNICODE *s, Py_ssize_t size, const char *errors, int byteorder)
560561

561-
Return a Python string object holding the UTF-16 encoded value of the Unicode
562+
Return a Python bytes object holding the UTF-16 encoded value of the Unicode
562563
data in *s*. If *byteorder* is not ``0``, output is written according to the
563564
following byte order::
564565

@@ -578,9 +579,9 @@ These are the UTF-16 codec APIs:
578579

579580
.. cfunction:: PyObject* PyUnicode_AsUTF16String(PyObject *unicode)
580581

581-
Return a Python string using the UTF-16 encoding in native byte order. The
582-
string always starts with a BOM mark. Error handling is "strict". Return
583-
*NULL* if an exception was raised by the codec.
582+
Return a Python byte string using the UTF-16 encoding in native byte
583+
order. The string always starts with a BOM mark. Error handling is "strict".
584+
Return *NULL* if an exception was raised by the codec.
584585

585586
These are the "Unicode Escape" codec APIs:
586587

@@ -644,15 +645,16 @@ ordinals and only these are accepted by the codecs during encoding.
644645

645646
.. cfunction:: PyObject* PyUnicode_EncodeLatin1(const Py_UNICODE *s, Py_ssize_t size, const char *errors)
646647

647-
Encode the :ctype:`Py_UNICODE` buffer of the given size using Latin-1 and return
648-
a Python string object. Return *NULL* if an exception was raised by the codec.
648+
Encode the :ctype:`Py_UNICODE` buffer of the given size using Latin-1 and
649+
return a Python bytes object. Return *NULL* if an exception was raised by
650+
the codec.
649651

650652

651653
.. cfunction:: PyObject* PyUnicode_AsLatin1String(PyObject *unicode)
652654

653-
Encode a Unicode object using Latin-1 and return the result as Python string
654-
object. Error handling is "strict". Return *NULL* if an exception was raised
655-
by the codec.
655+
Encode a Unicode object using Latin-1 and return the result as Python bytes
656+
object. Error handling is "strict". Return *NULL* if an exception was
657+
raised by the codec.
656658

657659
These are the ASCII codec APIs. Only 7-bit ASCII data is accepted. All other
658660
codes generate errors.
@@ -668,15 +670,16 @@ codes generate errors.
668670

669671
.. cfunction:: PyObject* PyUnicode_EncodeASCII(const Py_UNICODE *s, Py_ssize_t size, const char *errors)
670672

671-
Encode the :ctype:`Py_UNICODE` buffer of the given size using ASCII and return a
672-
Python string object. Return *NULL* if an exception was raised by the codec.
673+
Encode the :ctype:`Py_UNICODE` buffer of the given size using ASCII and
674+
return a Python bytes object. Return *NULL* if an exception was raised by
675+
the codec.
673676

674677

675678
.. cfunction:: PyObject* PyUnicode_AsASCIIString(PyObject *unicode)
676679

677-
Encode a Unicode object using ASCII and return the result as Python string
678-
object. Error handling is "strict". Return *NULL* if an exception was raised
679-
by the codec.
680+
Encode a Unicode object using ASCII and return the result as Python bytes
681+
object. Error handling is "strict". Return *NULL* if an exception was
682+
raised by the codec.
680683

681684
These are the mapping codec APIs:
682685

@@ -767,15 +770,16 @@ the user settings on the machine running the codec.
767770

768771
.. cfunction:: PyObject* PyUnicode_EncodeMBCS(const Py_UNICODE *s, Py_ssize_t size, const char *errors)
769772

770-
Encode the :ctype:`Py_UNICODE` buffer of the given size using MBCS and return a
771-
Python string object. Return *NULL* if an exception was raised by the codec.
773+
Encode the :ctype:`Py_UNICODE` buffer of the given size using MBCS and return
774+
a Python bytes object. Return *NULL* if an exception was raised by the
775+
codec.
772776

773777

774778
.. cfunction:: PyObject* PyUnicode_AsMBCSString(PyObject *unicode)
775779

776-
Encode a Unicode object using MBCS and return the result as Python string
777-
object. Error handling is "strict". Return *NULL* if an exception was raised
778-
by the codec.
780+
Encode a Unicode object using MBCS and return the result as Python bytes
781+
object. Error handling is "strict". Return *NULL* if an exception was
782+
raised by the codec.
779783

780784
.. % --- Methods & Slots ----------------------------------------------------
781785

0 commit comments

Comments
 (0)