Teks sumber — English
Terjemahan — Bahasa Indonesia
Requires that the Python object is a :class:`bytes` object, without attempting any conversion. Raises :exc:`TypeError` if the object is not a bytes object. The C variable may also be declared as :c:expr:`PyObject*`.
Mengharuskan objek Python adalah objek :class:`bytes`, tanpa mencoba melakukan perubahan apa pun. Memunculkan :exc:`TypeError` jika objek tersebut bukan objek byte. Variabel C juga dapat dideklarasikan sebagai :c:expr:`PyObject*`.
Requires that the Python object is a :class:`bytearray` object, without attempting any conversion. Raises :exc:`TypeError` if the object is not a :class:`bytearray` object. The C variable may also be declared as :c:expr:`PyObject*`.
Memerlukan bahwa objek Python adalah objek :class:`bytearray`, tanpa mencoba melakukan konversi apa pun. Memunculkan :exc:`TypeError` jika objek tersebut bukan merupakan objek :class:`bytearray`. Variabel C juga dapat dideklarasikan sebagai :c:expr:`PyObject*`.
Requires that the Python object is a Unicode object, without attempting any conversion. Raises :exc:`TypeError` if the object is not a Unicode object. The C variable may also be declared as :c:expr:`PyObject*`.
Memerlukan bahwa objek Python adalah objek Unicode, tanpa mencoba melakukan konversi apa pun. Memunculkan :exc:`TypeError` jika objek bukan objek Unicode. Variabel C juga dapat dideklarasikan sebagai :c:expr:`PyObject*`.
This format requires two arguments. The first is only used as input, and must be a :c:expr:`const char*` which points to the name of an encoding as a NUL-terminated string, or ``NULL``, in which case ``'utf-8'`` encoding is used. An exception is raised if the named encoding is not known to Python. The second argument must be a :c:expr:`char**`; the value of the pointer it references will be set to a buffer with the contents of the argument text. The text will be encoded in the encoding specified by the first argument.
Format ini membutuhkan dua argumen. Yang pertama hanya digunakan sebagai masukan, dan harus berupa :c:expr:`const char*` yang menunjuk pada nama pengkodean sebagai string yang diakhiri dengan NUL, atau ``NULL``, dalam hal ini pengkodean ``'utf-8'`` yang digunakan. Pengecualian akan muncul jika pengkodean yang disebutkan tidak dikenal oleh Python. Argumen kedua harus berupa :c:expr:`char**`; nilai pointer yang direferensikan akan diset ke buffer dengan isi teks argumen. Teks akan dikodekan dalam pengkodean yang ditentukan oleh argumen pertama.
It requires three arguments. The first is only used as input, and must be a :c:expr:`const char*` which points to the name of an encoding as a NUL-terminated string, or ``NULL``, in which case ``'utf-8'`` encoding is used. An exception is raised if the named encoding is not known to Python. The second argument must be a :c:expr:`char**`; the value of the pointer it references will be set to a buffer with the contents of the argument text. The text will be encoded in the encoding specified by the first argument. The third argument must be a pointer to an integer; the referenced integer will be set to the number of bytes in the output buffer.
Ini membutuhkan tiga argumen. Yang pertama hanya digunakan sebagai masukan, dan harus berupa :c:expr:`const char*` yang menunjuk pada nama pengkodean sebagai string yang diakhiri dengan NUL, atau ``NULL``, dalam hal ini pengkodean ``'utf-8'`` yang digunakan. Pengecualian akan muncul jika pengkodean yang disebutkan tidak dikenal oleh Python. Argumen kedua harus berupa :c:expr:`char**`; nilai pointer yang direferensikan akan disetel ke buffer dengan isi teks argumen. Teks akan dikodekan dalam pengkodean yang ditentukan oleh argumen pertama. Argumen ketiga harus berupa penunjuk ke sebuah bilangan bulat; bilangan bulat yang direferensikan akan diset ke jumlah byte dalam buffer keluaran.
Be aware that this format requires an ``int`` argument. Unlike most other contexts in C, variadic arguments are not coerced to a suitable type automatically. You can convert another type (for example, a pointer or a float) to a suitable ``int`` value using ``(x) ? 1 : 0`` or ``!!x``.
Perlu diketahui bahwa format ini membutuhkan argumen ``int``. Tidak seperti kebanyakan konteks lain dalam C, argumen variadic tidak dipaksa ke tipe yang sesuai secara otomatis. Anda dapat mengkonversi tipe lain (misalnya, pointer atau float) ke nilai ``int`` yang sesuai dengan menggunakan ``(x) ? 1 : 0`` atau ``!!x``.