PyUnicode_EncodeUTF16

Returns a Python string object holding the UTF-16 encoded value of the Unicode data.

If byteorder is not 0, output is written according to the following byte order:

byteorder == -1: little endian byteorder == 0: native byte order (writes a BOM mark) byteorder == 1: big endian

If byteorder is 0, the output string will always start with the Unicode BOM mark (U+FEFF). In the other two modes, no BOM mark is prepended.

Note that Py_UNICODE data is being interpreted as UTF-16 reduced to UCS-2. This trick makes it possible to add full UTF-16 capabilities at a later point without compromising the APIs.

  1. PyObject* PyUnicode_EncodeUTF16(Py_UNICODE* data, Py_ssize_t length, const(char)* errors, int byteorder)
  2. alias PyUnicode_EncodeUTF16 = PyUnicodeUCS2_EncodeUTF16
    version(!Python_3_3_Or_Later && Python_Unicode_UCS2)
    extern (C)
    alias PyUnicode_EncodeUTF16 = PyUnicodeUCS2_EncodeUTF16
  3. alias PyUnicode_EncodeUTF16 = PyUnicodeUCS4_EncodeUTF16

Meta