Unicode オブジェクトと codec
****************************


Unicode オブジェクト
====================

Python3.3 の **PEP 393** 実装から、メモリ効率を維持しながらUnicode文字
の完全な範囲を扱えるように、Unicodeオブジェクトは内部的に多様な表現形
式を用いています。すべてのコードポイントが128、256または65536以下の文
字列に対して特別なケースが存在しますが、それ以外ではコードポイントは
1114112以下 (これはすべてのUnicode範囲です) でなければなりません。

UTF-8 representation is created on demand and cached in the Unicode
object.

注釈:

  The "Py_UNICODE" representation has been removed since Python 3.12
  with deprecated APIs. See **PEP 623** for more information.


Unicode 型
----------

以下は Python の Unicode 実装に用いられている基本 Unicode オブジェクト
型です:

PyTypeObject PyUnicode_Type
    * 次に属します: Stable ABI.*

   This instance of "PyTypeObject" represents the Python Unicode type.
   It is exposed to Python code as "str".

PyTypeObject PyUnicodeIter_Type
    * 次に属します: Stable ABI.*

   This instance of "PyTypeObject" represents the Python Unicode
   iterator type. It is used to iterate over Unicode string objects.

type Py_UCS4
type Py_UCS2
type Py_UCS1
    * 次に属します: Stable ABI.*

   これらの型は、それぞれ、32ビット、16ビット、そして8ビットの文字を保
   持するのに充分な幅を持つ符号なしの整数型のtypedefです。単一の
   Unicode文字を扱う場合は、 "Py_UCS4" を用いてください。

   Added in version 3.3.

type PyASCIIObject
type PyCompactUnicodeObject
type PyUnicodeObject

   これらの "PyObject" のサブタイプは Python Unicode オブジェクトを表
   現します。 Unicode オブジェクトを扱う全ての API 関数は "PyObject"
   へのポインタを受け取って PyObject へのポインタを返すので、ほとんど
   の場合、これらの型を直接使うべきではありません。

   Added in version 3.3.

   The structure of a particular object can be determined using the
   following macros. The macros cannot fail; their behavior is
   undefined if their argument is not a Python Unicode object.

   PyUnicode_IS_COMPACT(o)

      True if *o* uses the "PyCompactUnicodeObject" structure.

      Added in version 3.3.

   PyUnicode_IS_COMPACT_ASCII(o)

      True if *o* uses the "PyASCIIObject" structure.

      Added in version 3.3.

The following APIs are C macros and static inlined functions for fast
checks and access to internal read-only data of Unicode objects:

int PyUnicode_Check(PyObject *obj)

   オブジェクト *obj* が Unicode オブジェクトか Unicode 型のサブタイプ
   のインスタンスである場合に真を返します。この関数は常に成功します。

int PyUnicode_CheckExact(PyObject *obj)

   オブジェクト *obj* が Unicode オブジェクトだがサブタイプのインスタ
   ンスでない場合に真を返します。この関数は常に成功します。

Py_ssize_t PyUnicode_GET_LENGTH(PyObject *unicode)

   Unicode 文字列のコードポイントでの長さを返します。 *unicode* は "正
   統な" 表現形式の Unicode オブジェクトでなければなりません (ただしチ
   ェックはしません)。

   Added in version 3.3.

Py_UCS1 *PyUnicode_1BYTE_DATA(PyObject *unicode)
Py_UCS2 *PyUnicode_2BYTE_DATA(PyObject *unicode)
Py_UCS4 *PyUnicode_4BYTE_DATA(PyObject *unicode)

   文字に直接アクセスするために、 UCS1, UCS2, UCS4 のいずれかの整数型
   にキャストされた正統な表現形式へのポインタを返します。 正統な表現が
   適正な文字サイズになっているかどうかのチェックはしません;
   "PyUnicode_KIND()" を使って正しい関数を選んでください。

   Added in version 3.3.

PyUnicode_1BYTE_KIND
PyUnicode_2BYTE_KIND
PyUnicode_4BYTE_KIND

   "PyUnicode_KIND()" マクロの返り値です。

   Added in version 3.3.

   バージョン 3.12 で変更: "PyUnicode_WCHAR_KIND" は削除されました。

int PyUnicode_KIND(PyObject *unicode)

   この Unicode がデータを保存するのに1文字あたり何バイト使っているか
   を示す PyUnicode 種別の定数 (上を読んでください) のうち1つを返しま
   す。 *unicode* は "正統な" 表現形式の Unicode オブジェクトでなけれ
   ばなりません (ただしチェックはしません)。

   Added in version 3.3.

void *PyUnicode_DATA(PyObject *unicode)

   生の Unicode バッファへの void ポインタを返します。 *unicode* は "
   正統な" 表現形式の Unicode オブジェクトでなければなりません (ただし
   チェックはしません)。

   Added in version 3.3.

void PyUnicode_WRITE(int kind, void *data, Py_ssize_t index, Py_UCS4 value)

   Write the code point *value* to the given zero-based *index* in a
   string.

   The *kind* value and *data* pointer must have been obtained from a
   string using "PyUnicode_KIND()" and "PyUnicode_DATA()"
   respectively. You must hold a reference to that string while
   calling "PyUnicode_WRITE()". All requirements of
   "PyUnicode_WriteChar()" also apply.

   The function performs no checks for any of its requirements, and is
   intended for usage in loops.

   Added in version 3.3.

Py_UCS4 PyUnicode_READ(int kind, void *data, Py_ssize_t index)

   正統な表現形式となっている ("PyUnicode_DATA()" で取得した) *data*
   からコードポイントを読み取ります。 チェックや事前確認のマクロ呼び出
   しは一切行われません。

   Added in version 3.3.

Py_UCS4 PyUnicode_READ_CHAR(PyObject *unicode, Py_ssize_t index)

   Unicode オブジェクト *unicode* から文字を読み取ります。 この
   Unicode オブジェクトは "正統な" 表現形式でなければなりません。 何度
   も連続して読み取る場合には、このマクロは "PyUnicode_READ()" よりも
   非効率的です。

   Added in version 3.3.

Py_UCS4 PyUnicode_MAX_CHAR_VALUE(PyObject *unicode)

   *unicode* に基づいて他の文字列を作るのに適した最大のコードポイント
   を返します。 この Unicode オブジェクトは "正統な" 表現形式でなけれ
   ばなりません。 この値は常に概算値ですが、文字列全体を調べるよりも効
   率的です。

   Added in version 3.3.

int PyUnicode_IsIdentifier(PyObject *unicode)
    * 次に属します: Stable ABI.*

   文字列が、 Names (identifiers and keywords) 節の言語定義における有
   効な識別子であれば "1" を返します。それ以外の場合は "0" を返します
   。

   バージョン 3.9 で変更: The function does not call "Py_FatalError()"
   anymore if the string is not ready.

unsigned int PyUnicode_IS_ASCII(PyObject *unicode)

   Return true if the string only contains ASCII characters.
   Equivalent to "str.isascii()".

   Added in version 3.2.


Unicode 文字プロパティ
----------------------

Unicode は数多くの異なる文字プロパティ (character property) を提供して
います。よく使われる文字プロパティは、以下のマクロで利用できます。これ
らのマクロは Python の設定に応じて、各々 C の関数に対応付けられていま
す。

int Py_UNICODE_ISSPACE(Py_UCS4 ch)

   *ch* が空白文字かどうかに応じて "1" または "0" を返します。

int Py_UNICODE_ISLOWER(Py_UCS4 ch)

   *ch* が小文字かどうかに応じて "1" または "0" を返します。

int Py_UNICODE_ISUPPER(Py_UCS4 ch)

   *ch* が大文字かどうかに応じて "1" または "0" を返します。

int Py_UNICODE_ISTITLE(Py_UCS4 ch)

   *ch* がタイトルケース文字 (titlecase character) かどうかに応じて
   "1" または "0" を返します。

int Py_UNICODE_ISLINEBREAK(Py_UCS4 ch)

   *ch* が改行文字かどうかに応じて "1" または "0" を返します。

int Py_UNICODE_ISDECIMAL(Py_UCS4 ch)

   *ch* が decimal 文字かどうかに応じて "1" または "0" を返します。

int Py_UNICODE_ISDIGIT(Py_UCS4 ch)

   *ch* が digit 文字かどうかに応じて "1" または "0" を返します。

int Py_UNICODE_ISNUMERIC(Py_UCS4 ch)

   *ch* が数字 (numeric) 文字かどうかに応じて "1" または "0" を返しま
   す。

int Py_UNICODE_ISALPHA(Py_UCS4 ch)

   *ch* がアルファベット文字かどうかに応じて "1" または "0" を返します
   。

int Py_UNICODE_ISALNUM(Py_UCS4 ch)

   *ch* が英数文字かどうかに応じて "1" または "0" を返します。

int Py_UNICODE_ISPRINTABLE(Py_UCS4 ch)

   Return "1" or "0" depending on whether *ch* is a printable
   character, in the sense of "str.isprintable()".

以下の API は、高速に直接文字変換を行うために使われます:

Py_UCS4 Py_UNICODE_TOLOWER(Py_UCS4 ch)

   *ch* を小文字に変換したものを返します。

Py_UCS4 Py_UNICODE_TOUPPER(Py_UCS4 ch)

   *ch* を大文字に変換したものを返します。

Py_UCS4 Py_UNICODE_TOTITLE(Py_UCS4 ch)

   *ch* をタイトルケース文字に変換したものを返します。

int Py_UNICODE_TODECIMAL(Py_UCS4 ch)

   Return the character *ch* converted to a decimal positive integer.
   Return "-1" if this is not possible.  This function does not raise
   exceptions.

int Py_UNICODE_TODIGIT(Py_UCS4 ch)

   Return the character *ch* converted to a single digit integer.
   Return "-1" if this is not possible.  This function does not raise
   exceptions.

double Py_UNICODE_TONUMERIC(Py_UCS4 ch)

   *ch* を double に変換したものを返します。不可能ならば "-1.0" を返し
   ます。この関数は例外を送出しません。

これらの API はサロゲートにも使えます:

int Py_UNICODE_IS_SURROGATE(Py_UCS4 ch)

   *ch* がサロゲートかどうか ("0xD800 <= ch <= 0xDFFF") をチェックしま
   す。

int Py_UNICODE_IS_HIGH_SURROGATE(Py_UCS4 ch)

   *ch* が上位サロゲートかどうか ("0xD800 <= ch <= 0xDBFF") をチェック
   します。

int Py_UNICODE_IS_LOW_SURROGATE(Py_UCS4 ch)

   *ch* が下位サロゲートかどうか ("0xDC00 <= ch <= 0xDFFF") をチェック
   します。

Py_UCS4 Py_UNICODE_HIGH_SURROGATE(Py_UCS4 ch)

   Return the high UTF-16 surrogate ("0xD800" to "0xDBFF") for a
   Unicode code point in the range "[0x10000; 0x10FFFF]".

Py_UCS4 Py_UNICODE_LOW_SURROGATE(Py_UCS4 ch)

   Return the low UTF-16 surrogate ("0xDC00" to "0xDFFF") for a
   Unicode code point in the range "[0x10000; 0x10FFFF]".

Py_UCS4 Py_UNICODE_JOIN_SURROGATES(Py_UCS4 high, Py_UCS4 low)

   Join two surrogate code points and return a single "Py_UCS4" value.
   *high* and *low* are respectively the leading and trailing
   surrogates in a surrogate pair. *high* must be in the range
   "[0xD800; 0xDBFF]" and *low* must be in the range "[0xDC00;
   0xDFFF]".


Unicode 文字列の生成とアクセス
------------------------------

Unicode オブジェクトを生成したり、Unicode のシーケンスとしての基本的な
プロパティにアクセスしたりするには、以下の API を使ってください:

PyObject *PyUnicode_New(Py_ssize_t size, Py_UCS4 maxchar)
    *戻り値: 新しい参照。*

   新しい Unicode オブジェクトを生成します。 *maxchar* は文字列に並べ
   るコードポイントの正しい最大値にすべきです。 その値は概算値として
   127, 255, 65535, 1114111 の一番近い値に切り上げられます。

   On error, set an exception and return "NULL".

   After creation, the string can be filled by
   "PyUnicode_WriteChar()", "PyUnicode_CopyCharacters()",
   "PyUnicode_Fill()", "PyUnicode_WRITE()" or similar. Since strings
   are supposed to be immutable, take care to not “use” the result
   while it is being modified. In particular, before it's filled with
   its final contents, a string:

   * must not be hashed,

   * must not be "converted to UTF-8", or another non-"canonical"
     representation,

   * must not have its reference count changed,

   * must not be shared with code that might do one of the above.

   This list is not exhaustive. Avoiding these uses is your
   responsibility; Python does not always check these requirements.

   To avoid accidentally exposing a partially-written string object,
   prefer using the "PyUnicodeWriter" API, or one of the
   "PyUnicode_From*" functions below.

   Added in version 3.3.

PyObject *PyUnicode_FromKindAndData(int kind, const void *buffer, Py_ssize_t size)
    *戻り値: 新しい参照。*

   与えられた *kind* (取り得る値は "PyUnicode_1BYTE_KIND" などの
   "PyUnicode_KIND()" が返す値です) の Unicode オブジェクトを生成しま
   す。 *buffer* は、与えられた kind に従って1文字あたり 1, 2, 4 バイ
   トのいずれかを単位として、長さ *size* の配列へのポインタでなければ
   なりません。

   If necessary, the input *buffer* is copied and transformed into the
   canonical representation.  For example, if the *buffer* is a UCS4
   string ("PyUnicode_4BYTE_KIND") and it consists only of codepoints
   in the UCS1 range, it will be transformed into UCS1
   ("PyUnicode_1BYTE_KIND").

   Added in version 3.3.

PyObject *PyUnicode_FromStringAndSize(const char *str, Py_ssize_t size)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   Create a Unicode object from the char buffer *str*.  The bytes will
   be interpreted as being UTF-8 encoded.  The buffer is copied into
   the new object. The return value might be a shared object, i.e.
   modification of the data is not allowed.

   This function raises "SystemError" when:

   * *size* < 0,

   * *str* is "NULL" and *size* > 0

   バージョン 3.12 で変更: *str* == "NULL" with *size* > 0 is not
   allowed anymore.

PyObject *PyUnicode_FromString(const char *str)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   UTF-8 エンコードされたnull終端のchar 型バッファ *str* から Unicode
   オブジェクトを生成します。

PyObject *PyUnicode_FromFormat(const char *format, ...)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   Take a C "printf()"-style *format* string and a variable number of
   arguments, calculate the size of the resulting Python Unicode
   string and return a string with the values formatted into it.  The
   variable arguments must be C types and must correspond exactly to
   the format characters in the *format* ASCII-encoded string.

   一つの変換指定子は 2 またはそれ以上の文字を含み、その構成要素は以下
   からなりますが、示した順に出現しなければなりません:

   1. 指定子の開始を示す文字 "'%'" 。

   2. 変換フラグ (オプション)。一部の変換型の結果に影響します。

   3. Minimum field width (optional). If specified as an "'*'"
      (asterisk), the actual width is given in the next argument,
      which must be of type int, and the object to convert comes after
      the minimum field width and optional precision.

   4. Precision (optional), given as a "'.'" (dot) followed by the
      precision. If specified as "'*'" (an asterisk), the actual
      precision is given in the next argument, which must be of type
      int, and the value to convert comes after the precision.

   5. 精度長変換子 (オプション)。

   6. 変換型。

   変換フラグ文字を以下に示します:

   +---------+---------------------------------------------------------------+
   | Flag    | 意味                                                          |
   |=========|===============================================================|
   | "0"     | 数値型に対してゼロによるパディングを行います。                |
   +---------+---------------------------------------------------------------+
   | "-"     | The converted value is left adjusted (overrides the "0" flag  |
   |         | if both are given).                                           |
   +---------+---------------------------------------------------------------+

   The length modifiers for following integer conversions ("d", "i",
   "o", "u", "x", or "X") specify the type of the argument (int by
   default):

   +------------+-------------------------------------------------------+
   | 修飾子     | 型                                                    |
   |============|=======================================================|
   | "l"        | long または unsigned long                             |
   +------------+-------------------------------------------------------+
   | "ll"       | long long または unsigned long long                   |
   +------------+-------------------------------------------------------+
   | "j"        | "intmax_t" or "uintmax_t"                             |
   +------------+-------------------------------------------------------+
   | "z"        | "size_t" or "ssize_t"                                 |
   +------------+-------------------------------------------------------+
   | "t"        | "ptrdiff_t"                                           |
   +------------+-------------------------------------------------------+

   The length modifier "l" for following conversions "s" or "V"
   specify that the type of the argument is const wchar_t*.

   The conversion specifiers are:

   +-----------------------------------+-----------------------------------+-----------------------------------+
   | Conversion Specifier              | 型                                | 備考                              |
   |===================================|===================================|===================================|
   | "%"                               | *n/a*                             | The literal "%" character.        |
   +-----------------------------------+-----------------------------------+-----------------------------------+
   | "d", "i"                          | Specified by the length modifier  | The decimal representation of a   |
   |                                   |                                   | signed C integer.                 |
   +-----------------------------------+-----------------------------------+-----------------------------------+
   | "u"                               | Specified by the length modifier  | The decimal representation of an  |
   |                                   |                                   | unsigned C integer.               |
   +-----------------------------------+-----------------------------------+-----------------------------------+
   | "o"                               | Specified by the length modifier  | The octal representation of an    |
   |                                   |                                   | unsigned C integer.               |
   +-----------------------------------+-----------------------------------+-----------------------------------+
   | "x"                               | Specified by the length modifier  | The hexadecimal representation of |
   |                                   |                                   | an unsigned C integer             |
   |                                   |                                   | (lowercase).                      |
   +-----------------------------------+-----------------------------------+-----------------------------------+
   | "X"                               | Specified by the length modifier  | The hexadecimal representation of |
   |                                   |                                   | an unsigned C integer             |
   |                                   |                                   | (uppercase).                      |
   +-----------------------------------+-----------------------------------+-----------------------------------+
   | "c"                               | int                               | A single character.               |
   +-----------------------------------+-----------------------------------+-----------------------------------+
   | "s"                               | const char* または const wchar_t* | null で終端された C の文字列。    |
   +-----------------------------------+-----------------------------------+-----------------------------------+
   | "p"                               | const void*                       | C ポインタの 16 進表記。          |
   |                                   |                                   | "printf("%p")" とほとんど同じです |
   |                                   |                                   | が、プラッ トフォームにおける     |
   |                                   |                                   | "printf" の定義に関わりなく先頭に |
   |                                   |                                   | リテラル "0x" が付きます。        |
   +-----------------------------------+-----------------------------------+-----------------------------------+
   | "A"                               | PyObject*                         | "ascii()" の戻り値。              |
   +-----------------------------------+-----------------------------------+-----------------------------------+
   | "U"                               | PyObject*                         | Unicode オブジェクト。            |
   +-----------------------------------+-----------------------------------+-----------------------------------+
   | "V"                               | PyObject*, const char* or const   | A Unicode object (which may be    |
   |                                   | wchar_t*                          | "NULL") and a null-terminated C   |
   |                                   |                                   | character array as a second       |
   |                                   |                                   | parameter (which will be used, if |
   |                                   |                                   | the first parameter is "NULL").   |
   +-----------------------------------+-----------------------------------+-----------------------------------+
   | "S"                               | PyObject*                         | "PyObject_Str()" の戻り値。       |
   +-----------------------------------+-----------------------------------+-----------------------------------+
   | "R"                               | PyObject*                         | "PyObject_Repr()" の戻り値。      |
   +-----------------------------------+-----------------------------------+-----------------------------------+
   | "T"                               | PyObject*                         | Get the fully qualified name of   |
   |                                   |                                   | an object type; call              |
   |                                   |                                   | "PyType_GetFullyQualifiedName()". |
   +-----------------------------------+-----------------------------------+-----------------------------------+
   | "#T"                              | PyObject*                         | Similar to "T" format, but use a  |
   |                                   |                                   | colon (":") as separator between  |
   |                                   |                                   | the module name and the qualified |
   |                                   |                                   | name.                             |
   +-----------------------------------+-----------------------------------+-----------------------------------+
   | "N"                               | PyTypeObject*                     | Get the fully qualified name of a |
   |                                   |                                   | type; call                        |
   |                                   |                                   | "PyType_GetFullyQualifiedName()". |
   +-----------------------------------+-----------------------------------+-----------------------------------+
   | "#N"                              | PyTypeObject*                     | Similar to "N" format, but use a  |
   |                                   |                                   | colon (":") as separator between  |
   |                                   |                                   | the module name and the qualified |
   |                                   |                                   | name.                             |
   +-----------------------------------+-----------------------------------+-----------------------------------+

   注釈:

     The width formatter unit is number of characters rather than
     bytes. The precision formatter unit is number of bytes or
     "wchar_t" items (if the length modifier "l" is used) for ""%s""
     and ""%V"" (if the "PyObject*" argument is "NULL"), and a number
     of characters for ""%A"", ""%U"", ""%S"", ""%R"" and ""%V"" (if
     the "PyObject*" argument is not "NULL").

   注釈:

     Unlike to C "printf()" the "0" flag has effect even when a
     precision is given for integer conversions ("d", "i", "u", "o",
     "x", or "X").

   バージョン 3.2 で変更: ""%lld"", ""%llu"" のサポートが追加されまし
   た。

   バージョン 3.3 で変更: ""%li"", ""%lli"", ""%zi"" のサポートが追加
   されました。

   バージョン 3.4 で変更: ""%s"", ""%A"", ""%U"", ""%V"", ""%S"",
   ""%R"" での幅フォーマッタおよび精度フォーマッタのサポートが追加され
   ました。

   バージョン 3.12 で変更: Support for conversion specifiers "o" and
   "X". Support for length modifiers "j" and "t". Length modifiers are
   now applied to all integer conversions. Length modifier "l" is now
   applied to conversion specifiers "s" and "V". Support for variable
   width and precision "*". Support for flag "-".An unrecognized
   format character now sets a "SystemError". In previous versions it
   caused all the rest of the format string to be copied as-is to the
   result string, and any extra arguments discarded.

   バージョン 3.13 で変更: Support for "%T", "%#T", "%N" and "%#N"
   formats added.

PyObject *PyUnicode_FromFormatV(const char *format, va_list vargs)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   ちょうど２つの引数を取ることを除いて、 "PyUnicode_FromFormat()" と
   同じです。

PyObject *PyUnicode_FromObject(PyObject *obj)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   Copy an instance of a Unicode subtype to a new true Unicode object
   if necessary. If *obj* is already a true Unicode object (not a
   subtype), return a new *strong reference* to the object.

   Unicode やそのサブタイプ以外のオブジェクトでは "TypeError" が引き起
   こされます。

PyObject *PyUnicode_FromOrdinal(int ordinal)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   Create a Unicode Object from the given Unicode code point
   *ordinal*.

   The ordinal must be in "range(0x110000)". A "ValueError" is raised
   in the case it is not.

PyObject *PyUnicode_FromEncodedObject(PyObject *obj, const char *encoding, const char *errors)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   エンコードされている *obj* を Unicode オブジェクトにデコードします
   。

   "bytes" や "bytearray" や他の *bytes-like objects* は、与えられた
   *encoding* に従ってデコードされ、 *errors* で定義されたエラーハンド
   リングが使われます。 これらの引数は両方とも "NULL" にでき、その場合
   この API はデフォルト値を使います (詳しことは 組み込み codec
   (built-in codec) を参照してください)。

   その他のUnicodeオブジェクトを含むオブジェクトは "TypeError" 例外を
   引き起こします。

   この API は、エラーが生じたときには "NULL" を返します。呼び出し側は
   返されたオブジェクトに対し参照カウンタを 1 つ減らす (decref) する責
   任があります。

void PyUnicode_Append(PyObject **p_left, PyObject *right)
    * 次に属します: Stable ABI.*

   Append the string *right* to the end of *p_left*. *p_left* must
   point to a *strong reference* to a Unicode object;
   "PyUnicode_Append()" releases ("steals") this reference.

   On error, set **p_left* to "NULL" and set an exception.

   On success, set **p_left* to a new strong reference to the result.

void PyUnicode_AppendAndDel(PyObject **p_left, PyObject *right)
    * 次に属します: Stable ABI.*

   The function is similar to "PyUnicode_Append()", with the only
   difference being that it decrements the reference count of *right*
   by one.

PyObject *PyUnicode_BuildEncodingMap(PyObject *string)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   Return a mapping suitable for decoding a custom single-byte
   encoding. Given a Unicode string *string* of up to 256 characters
   representing an encoding table, returns either a compact internal
   mapping object or a dictionary mapping character ordinals to byte
   values. Raises a "TypeError" and return "NULL" on invalid input.

   Added in version 3.2.

const char *PyUnicode_GetDefaultEncoding(void)
    * 次に属します: Stable ABI.*

   Return the name of the default string encoding, ""utf-8"". See
   "sys.getdefaultencoding()".

   The returned string does not need to be freed, and is valid until
   interpreter shutdown.

Py_ssize_t PyUnicode_GetLength(PyObject *unicode)
    * 次に属します: Stable ABI (バージョン 3.7 より).*

   Unicode オブジェクトの長さをコードポイントで返します。

   On error, set an exception and return "-1".

   Added in version 3.3.

Py_ssize_t PyUnicode_CopyCharacters(PyObject *to, Py_ssize_t to_start, PyObject *from, Py_ssize_t from_start, Py_ssize_t how_many)

   ある Unicode オブジェクトから他へ文字をコピーします。 この関数は必
   要なときに文字変換を行い、可能な場合は "memcpy()" へ差し戻します。
   失敗のときには "-1" を返し、例外を設定します。そうでない場合は、コ
   ピーした文字数を返します。

   The string must not have been “used” yet. See "PyUnicode_New()" for
   details.

   Added in version 3.3.

int PyUnicode_Resize(PyObject **unicode, Py_ssize_t length);
    * 次に属します: Stable ABI.*

   Resize a Unicode object **unicode* to the new *length* in code
   points.

   Try to resize the string in place (which is usually faster than
   allocating a new string and copying characters), or create a new
   string.

   **unicode* is modified to point to the new (resized) object and "0"
   is returned on success. Otherwise, "-1" is returned and an
   exception is set, and **unicode* is left untouched.

   The function doesn't check string content, the result may not be a
   string in canonical representation.

Py_ssize_t PyUnicode_Fill(PyObject *unicode, Py_ssize_t start, Py_ssize_t length, Py_UCS4 fill_char)

   文字列を文字で埋めます: "unicode[start:start+length]" で
   *fill_char* を埋めることになります。

   *fill_char* が文字列の最大文字よりも大きい場合や、文字列2つ以上の参
   照を持ってた場合は失敗します。

   The string must not have been “used” yet. See "PyUnicode_New()" for
   details.

   書き込んだ文字数を返すか、失敗のときには "-1" を返し例外を送出しま
   す。

   Added in version 3.3.

int PyUnicode_WriteChar(PyObject *unicode, Py_ssize_t index, Py_UCS4 character)
    * 次に属します: Stable ABI (バージョン 3.7 より).*

   Write a *character* to the string *unicode* at the zero-based
   *index*. Return "0" on success, "-1" on error with an exception
   set.

   This function checks that *unicode* is a Unicode object, that the
   index is not out of bounds, and that the object's reference count
   is one. See "PyUnicode_WRITE()" for a version that skips these
   checks, making them your responsibility.

   The string must not have been “used” yet. See "PyUnicode_New()" for
   details.

   Added in version 3.3.

Py_UCS4 PyUnicode_ReadChar(PyObject *unicode, Py_ssize_t index)
    * 次に属します: Stable ABI (バージョン 3.7 より).*

   文字列から文字を読み取ります。 エラーチェックを行わない
   "PyUnicode_READ_CHAR()" とは対照的に、この関数は *unicode* が
   Unicode オブジェクトであること、インデックスが範囲内であることをチ
   ェックします。

   Return character on success, "-1" on error with an exception set.

   Added in version 3.3.

PyObject *PyUnicode_Substring(PyObject *unicode, Py_ssize_t start, Py_ssize_t end)
    *戻り値: 新しい参照。** 次に属します: Stable ABI (バージョン 3.7
   より).*

   Return a substring of *unicode*, from character index *start*
   (included) to character index *end* (excluded).  Negative indices
   are not supported. On error, set an exception and return "NULL".

   Added in version 3.3.

Py_UCS4 *PyUnicode_AsUCS4(PyObject *unicode, Py_UCS4 *buffer, Py_ssize_t buflen, int copy_null)
    * 次に属します: Stable ABI (バージョン 3.7 より).*

   Copy the string *unicode* into a UCS4 buffer, including a null
   character, if *copy_null* is set.  Returns "NULL" and sets an
   exception on error (in particular, a "SystemError" if *buflen* is
   smaller than the length of *unicode*).  *buffer* is returned on
   success.

   Added in version 3.3.

Py_UCS4 *PyUnicode_AsUCS4Copy(PyObject *unicode)
    * 次に属します: Stable ABI (バージョン 3.7 より).*

   文字列 *unicode* を "PyMem_Malloc()" でメモリ確保された新しい UCS4
   型のバッファにコピーします。 これが失敗した場合は、 "NULL" を返し
   "MemoryError" をセットします。 返されたバッファは必ず null コードポ
   イントが追加されています。

   Added in version 3.3.


ロケールエンコーディング
------------------------

現在のロケールエンコーディングはオペレーティングシステムのテキストをデ
コードするのに使えます。

PyObject *PyUnicode_DecodeLocaleAndSize(const char *str, Py_ssize_t length, const char *errors)
    *戻り値: 新しい参照。** 次に属します: Stable ABI (バージョン 3.7
   より).*

   Decode a string from UTF-8 on Android and VxWorks, or from the
   current locale encoding on other platforms. The supported error
   handlers are ""strict"" and ""surrogateescape"" (**PEP 383**). The
   decoder uses ""strict"" error handler if *errors* is "NULL".  *str*
   must end with a null character but cannot contain embedded null
   characters.

   Use "PyUnicode_DecodeFSDefaultAndSize()" to decode a string from
   the *filesystem encoding and error handler*.

   This function ignores the Python UTF-8 Mode.

   参考: "Py_DecodeLocale()" 関数。

   Added in version 3.3.

   バージョン 3.7 で変更: この関数は、 Android 以外では現在のロケール
   エンコーディングを "surrogateescape" エラーハンドラで使うようになり
   ました。 以前は、 "Py_DecodeLocale()" が "surrogateescape" で使われ
   、現在のロケールエンコーディングは "strict" で使われていました。

PyObject *PyUnicode_DecodeLocale(const char *str, const char *errors)
    *戻り値: 新しい参照。** 次に属します: Stable ABI (バージョン 3.7
   より).*

   Similar to "PyUnicode_DecodeLocaleAndSize()", but compute the
   string length using "strlen()".

   Added in version 3.3.

PyObject *PyUnicode_EncodeLocale(PyObject *unicode, const char *errors)
    *戻り値: 新しい参照。** 次に属します: Stable ABI (バージョン 3.7
   より).*

   Encode a Unicode object to UTF-8 on Android and VxWorks, or to the
   current locale encoding on other platforms. The supported error
   handlers are ""strict"" and ""surrogateescape"" (**PEP 383**). The
   encoder uses ""strict"" error handler if *errors* is "NULL". Return
   a "bytes" object. *unicode* cannot contain embedded null
   characters.

   Use "PyUnicode_EncodeFSDefault()" to encode a string to the
   *filesystem encoding and error handler*.

   This function ignores the Python UTF-8 Mode.

   参考: "Py_EncodeLocale()" 関数。

   Added in version 3.3.

   バージョン 3.7 で変更: この関数は、 Android 以外では現在のロケール
   エンコーディングを "surrogateescape" エラーハンドラで使うようになり
   ました。 以前は、 "Py_EncodeLocale()" が "surrogateescape" で使われ
   、現在のロケールエンコーディングは "strict" で使われていました。


ファイルシステムエンコーディング
--------------------------------

Functions encoding to and decoding from the *filesystem encoding and
error handler* (**PEP 383** and **PEP 529**).

To encode file names to "bytes" during argument parsing, the ""O&""
converter should be used, passing "PyUnicode_FSConverter()" as the
conversion function:

int PyUnicode_FSConverter(PyObject *obj, void *result)
    * 次に属します: Stable ABI.*

   PyArg_Parse* converter: encode "str" objects -- obtained directly
   or through the "os.PathLike" interface -- to "bytes" using
   "PyUnicode_EncodeFSDefault()"; "bytes" objects are output as-is.
   *result* must be an address of a C variable of type PyObject* (or
   PyBytesObject*). On success, set the variable to a new *strong
   reference* to a bytes object which must be released when it is no
   longer used and return a non-zero value ("Py_CLEANUP_SUPPORTED").
   Embedded null bytes are not allowed in the result. On failure,
   return "0" with an exception set.

   If *obj* is "NULL", the function releases a strong reference stored
   in the variable referred by *result* and returns "1".

   Added in version 3.1.

   バージョン 3.6 で変更: *path-like object* を受け入れるようになりま
   した。

To decode file names to "str" during argument parsing, the ""O&""
converter should be used, passing "PyUnicode_FSDecoder()" as the
conversion function:

int PyUnicode_FSDecoder(PyObject *obj, void *result)
    * 次に属します: Stable ABI.*

   PyArg_Parse* converter: decode "bytes" objects -- obtained either
   directly or indirectly through the "os.PathLike" interface -- to
   "str" using "PyUnicode_DecodeFSDefaultAndSize()"; "str" objects are
   output as-is. *result* must be an address of a C variable of type
   PyObject* (or PyUnicodeObject*). On success, set the variable to a
   new *strong reference* to a Unicode object which must be released
   when it is no longer used and return a non-zero value
   ("Py_CLEANUP_SUPPORTED"). Embedded null characters are not allowed
   in the result. On failure, return "0" with an exception set.

   If *obj* is "NULL", release the strong reference to the object
   referred to by *result* and return "1".

   Added in version 3.2.

   バージョン 3.6 で変更: *path-like object* を受け入れるようになりま
   した。

PyObject *PyUnicode_DecodeFSDefaultAndSize(const char *str, Py_ssize_t size)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   Decode a string from the *filesystem encoding and error handler*.

   If you need to decode a string from the current locale encoding,
   use "PyUnicode_DecodeLocaleAndSize()".

   参考: "Py_DecodeLocale()" 関数。

   バージョン 3.6 で変更: The *filesystem error handler* is now used.

PyObject *PyUnicode_DecodeFSDefault(const char *str)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   Decode a null-terminated string from the *filesystem encoding and
   error handler*.

   If the string length is known, use
   "PyUnicode_DecodeFSDefaultAndSize()".

   バージョン 3.6 で変更: The *filesystem error handler* is now used.

PyObject *PyUnicode_EncodeFSDefault(PyObject *unicode)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   Encode a Unicode object to the *filesystem encoding and error
   handler*, and return "bytes". Note that the resulting "bytes"
   object can contain null bytes.

   If you need to encode a string to the current locale encoding, use
   "PyUnicode_EncodeLocale()".

   参考: "Py_EncodeLocale()" 関数。

   Added in version 3.2.

   バージョン 3.6 で変更: The *filesystem error handler* is now used.


wchar_t サポート
----------------

"wchar_t" をサポートするプラットフォームでの wchar_t サポート:

PyObject *PyUnicode_FromWideChar(const wchar_t *wstr, Py_ssize_t size)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   Create a Unicode object from the "wchar_t" buffer *wstr* of the
   given *size*. Passing "-1" as the *size* indicates that the
   function must itself compute the length, using "wcslen()". Return
   "NULL" on failure.

Py_ssize_t PyUnicode_AsWideChar(PyObject *unicode, wchar_t *wstr, Py_ssize_t size)
    * 次に属します: Stable ABI.*

   Copy the Unicode object contents into the "wchar_t" buffer *wstr*.
   At most *size* "wchar_t" characters are copied (excluding a
   possibly trailing null termination character).  Return the number
   of "wchar_t" characters copied or "-1" in case of an error.

   When *wstr* is "NULL", instead return the *size* that would be
   required to store all of *unicode* including a terminating null.

   Note that the resulting wchar_t* string may or may not be null-
   terminated.  It is the responsibility of the caller to make sure
   that the wchar_t* string is null-terminated in case this is
   required by the application. Also, note that the wchar_t* string
   might contain null characters, which would cause the string to be
   truncated when used with most C functions.

wchar_t *PyUnicode_AsWideCharString(PyObject *unicode, Py_ssize_t *size)
    * 次に属します: Stable ABI (バージョン 3.7 より).*

   Convert the Unicode object to a wide character string. The output
   string always ends with a null character. If *size* is not "NULL",
   write the number of wide characters (excluding the trailing null
   termination character) into **size*. Note that the resulting
   "wchar_t" string might contain null characters, which would cause
   the string to be truncated when used with most C functions. If
   *size* is "NULL" and the wchar_t* string contains null characters a
   "ValueError" is raised.

   Returns a buffer allocated by "PyMem_New" (use "PyMem_Free()" to
   free it) on success. On error, returns "NULL" and **size* is
   undefined. Raises a "MemoryError" if memory allocation is failed.

   Added in version 3.2.

   バージョン 3.7 で変更: Raises a "ValueError" if *size* is "NULL"
   and the wchar_t* string contains null characters.


組み込み codec (built-in codec)
===============================

Python には、処理速度を高めるために C で書かれた codec が揃えてありま
す。これら全ての codec は以下の関数を介して直接利用できます。

以下の API の多くが、 *encoding* と *errors* という二つの引数をとりま
す。これらのパラメータは、組み込みの文字列コンストラクタである "str()"
における同名のパラメータと同じ意味を持ちます。

Setting encoding to "NULL" causes the default encoding to be used
which is UTF-8.  The file system calls should use
"PyUnicode_FSConverter()" for encoding file names. This uses the
*filesystem encoding and error handler* internally.

*errors* で指定するエラー処理もまた、 "NULL" を指定できます。 "NULL"
を指定すると、codec で定義されているデフォルト処理の使用を意味します。
全ての組み込み codec で、デフォルトのエラー処理は "strict"
("ValueError" を送出する) になっています。

個々の codec は全て同様のインターフェースを使っています。個別の codec
の説明では、説明を簡単にするために以下の汎用のインターフェースとの違い
だけを説明しています。


汎用 codec
----------

The following macro is provided:

Py_UNICODE_REPLACEMENT_CHARACTER

   The Unicode code point "U+FFFD" (replacement character).

   This Unicode character is used as the replacement character during
   decoding if the *errors* argument is set to "replace".

以下は汎用 codec の API です:

PyObject *PyUnicode_Decode(const char *str, Py_ssize_t size, const char *encoding, const char *errors)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   Create a Unicode object by decoding *size* bytes of the encoded
   string *str*. *encoding* and *errors* have the same meaning as the
   parameters of the same name in the "str()" built-in function.  The
   codec to be used is looked up using the Python codec registry.
   Return "NULL" if an exception was raised by the codec.

PyObject *PyUnicode_AsEncodedString(PyObject *unicode, const char *encoding, const char *errors)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   Unicode オブジェクトをエンコードし、その結果を Python の bytes オブ
   ジェクトとして返します。 *encoding* および *errors* は Unicode 型の
   "encode()" メソッドに与える同名のパラメータと同じ意味を持ちます。
   使用する codec の検索は、 Python の codec レジストリを使って行いま
   す。 codec が例外を送出した場合には "NULL" を返します。


UTF-8 Codecs
------------

以下は UTF-8 codec の APIです:

PyObject *PyUnicode_DecodeUTF8(const char *str, Py_ssize_t size, const char *errors)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   UTF-8 でエンコードされた *size* バイトの文字列 *str* から Unicode
   オブジェクトを生成します。codec が例外を送出した場合には "NULL" を
   返します。

PyObject *PyUnicode_DecodeUTF8Stateful(const char *str, Py_ssize_t size, const char *errors, Py_ssize_t *consumed)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   *consumed* が "NULL" の場合、 "PyUnicode_DecodeUTF8()" と同じように
   動作します。 *consumed* が "NULL" でない場合、末尾の不完全な UTF-8
   バイト列はエラーとみなされません。これらのバイト列はデコードされず
   、デコードされたバイト数は *consumed* に格納されます。

PyObject *PyUnicode_AsUTF8String(PyObject *unicode)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   UTF-8 で Unicode オブジェクトをエンコードし、結果を Python バイト列
   オブジェクトとして返します。エラー処理は "strict" です。 codec が例
   外を送出した場合には "NULL" を返します。

   The function fails if the string contains surrogate code points
   ("U+D800" - "U+DFFF").

const char *PyUnicode_AsUTF8AndSize(PyObject *unicode, Py_ssize_t *size)
    * 次に属します: Stable ABI (バージョン 3.10 より).*

   Unicode オブジェクトを UTF-8 でエンコードしたものへのポインタを返し
   、エンコードされた表現形式でのサイズ (バイト単位) を *size* に格納
   します。 *size* 引数は "NULL" でも構いません; その場合はサイズは格
   納されません。 返されるバッファには、 null コードポイントがあるかど
   うかに関わらず、常に null バイトが終端に付加されています (これは
   *size* には勘定されません)。

   On error, set an exception, set *size* to "-1" (if it's not NULL)
   and return "NULL".

   The function fails if the string contains surrogate code points
   ("U+D800" - "U+DFFF").

   This caches the UTF-8 representation of the string in the Unicode
   object, and subsequent calls will return a pointer to the same
   buffer.  The caller is not responsible for deallocating the buffer.
   The buffer is deallocated and pointers to it become invalid when
   the Unicode object is garbage collected.

   Added in version 3.3.

   バージョン 3.7 で変更: 返り値の型が "char *" ではなく "const char
   *" になりました。

   バージョン 3.10 で変更: This function is a part of the limited API.

const char *PyUnicode_AsUTF8(PyObject *unicode)

   "PyUnicode_AsUTF8AndSize()" とほぼ同じですが、サイズを格納しません
   。

   警告:

     This function does not have any special behavior for null
     characters embedded within *unicode*. As a result, strings
     containing null characters will remain in the returned string,
     which some C functions might interpret as the end of the string,
     leading to truncation. If truncation is an issue, it is
     recommended to use "PyUnicode_AsUTF8AndSize()" instead.

   Added in version 3.3.

   バージョン 3.7 で変更: 返り値の型が "char *" ではなく "const char
   *" になりました。


UTF-32 Codecs
-------------

以下は UTF-32 codec API です:

PyObject *PyUnicode_DecodeUTF32(const char *str, Py_ssize_t size, const char *errors, int *byteorder)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   UTF-32 でエンコードされたバッファ文字列から *size* バイトをデコード
   し、 Unicodeオブジェクトとして返します。 *errors* は ("NULL" でない
   なら) エラーハンドラを指定します。デフォルトは "strict" です。

   *byteorder* が "NULL" でない時、デコーダは与えられたバイトオーダー
   でデコードを開始します。

      *byteorder == -1: little endian
      *byteorder == 0:  native order
      *byteorder == 1:  big endian

   "*byteorder" が 0 で、入力データの最初の 4 バイトが byte order mark
   (BOM) ならば、デコーダはこのバイトオーダーに切り替え、BOM は結果の
   Unicode 文字列にコピーされません。 "*byteorder" が "-1" または "1"
   ならば、全ての byte order mark は出力にコピーされます。

   デコードが完了した後、入力データの終端に来た時点でのバイトオーダー
   を **byteorder* にセットします。

   *byteorder* が "NULL" のとき、 codec は native order モードで開始し
   ます。

   codec が例外を発生させたときは "NULL" を返します。

PyObject *PyUnicode_DecodeUTF32Stateful(const char *str, Py_ssize_t size, const char *errors, int *byteorder, Py_ssize_t *consumed)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   *consumed* が "NULL" のとき、 "PyUnicode_DecodeUTF32()" と同じよう
   に振る舞います。 *consumed* が "NULL" でないとき、
   "PyUnicode_DecodeUTF32Stateful()" は末尾の不完全な (4 で割り切れな
   い長さのバイト列などの) UTF-32 バイト列をエラーとして扱いません。末
   尾の不完全なバイト列はデコードされず、デコードされたバイト数が
   *consumed* に格納されます。

PyObject *PyUnicode_AsUTF32String(PyObject *unicode)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   ネイティブバイトオーダーで UTF-32 エンコーディングされた Python バ
   イト文字列を返します。 文字列は常に BOM マークで始まります。 エラー
   ハンドラは "strict" です。 codec が例外を発生させたときは "NULL" を
   返します。


UTF-16 Codecs
-------------

以下は UTF-16 codec の APIです:

PyObject *PyUnicode_DecodeUTF16(const char *str, Py_ssize_t size, const char *errors, int *byteorder)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   UTF-16 でエンコードされたバッファ *s* から *size* バイトだけデコー
   ドして、結果を Unicode オブジェクトで返します。 *errors* は ("NULL"
   でない場合) エラー処理方法を定義します。デフォルト値は "strict" で
   す。

   *byteorder* が "NULL" でない時、デコーダは与えられたバイトオーダー
   でデコードを開始します。

      *byteorder == -1: little endian
      *byteorder == 0:  native order
      *byteorder == 1:  big endian

   "*byteorder" が 0 で、入力データの先頭2バイトがバイトオーダーマーク
   (BOM) だった場合、デコーダは BOM が示すバイトオーダーに切り替え、そ
   のBOMを結果の Unicode 文字列にコピーしません。 "*byteorder" が "-1"
   か "1" だった場合、すべてのBOMは出力へコピーされます (出力では
   "\ufeff" か "\ufffe" のどちらかになるでしょう)。

   デコードが完了した後、入力データの終端に来た時点でのバイトオーダー
   を "*byteorder" にセットします。

   *byteorder* が "NULL" のとき、 codec は native order モードで開始し
   ます。

   codec が例外を発生させたときは "NULL" を返します。

PyObject *PyUnicode_DecodeUTF16Stateful(const char *str, Py_ssize_t size, const char *errors, int *byteorder, Py_ssize_t *consumed)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   *consumed* が "NULL" の場合、 "PyUnicode_DecodeUTF16()" と同じよう
   に動作します。 *consumed* が "NULL" でない場合、
   "PyUnicode_DecodeUTF16Stateful()" は末尾の不完全な UTF-16 バイト列
   (奇数長のバイト列や分割されたサロゲートペア) をエラーとみなしません
   。これらのバイト列はデコードされず、デコードされたバイト数を
   *consumed* に返します。

PyObject *PyUnicode_AsUTF16String(PyObject *unicode)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   ネイティブバイトオーダーで UTF-16 エンコーディングされた Python バ
   イト文字列を返します。 文字列は常に BOM マークで始まります。 エラー
   ハンドラは "strict" です。 codec が例外を発生させたときは "NULL" を
   返します。


UTF-7 Codecs
------------

以下は UTF-7 codec の API です:

PyObject *PyUnicode_DecodeUTF7(const char *str, Py_ssize_t size, const char *errors)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   Create a Unicode object by decoding *size* bytes of the UTF-7
   encoded string *str*.  Return "NULL" if an exception was raised by
   the codec.

PyObject *PyUnicode_DecodeUTF7Stateful(const char *str, Py_ssize_t size, const char *errors, Py_ssize_t *consumed)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   *consumed* が "NULL" のとき、 "PyUnicode_DecodeUTF7()" と同じように
   動作します。 *consumed* が "NULL" でないとき、末尾の不完全な UTF-7
   base-64 部分をエラーとしません。不完全な部分のバイト列はデコードせ
   ずに、デコードしたバイト数を *consumed* に格納します。


Unicode-Escape Codecs
---------------------

以下は "Unicode Escape" codec の API です:

PyObject *PyUnicode_DecodeUnicodeEscape(const char *str, Py_ssize_t size, const char *errors)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   Create a Unicode object by decoding *size* bytes of the Unicode-
   Escape encoded string *str*.  Return "NULL" if an exception was
   raised by the codec.

PyObject *PyUnicode_AsUnicodeEscapeString(PyObject *unicode)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   Unicode-Escape を使い Unicode オブジェクトをエンコードし、結果を
   bytes オブジェクトとして返します。 エラー処理は "strict" です。
   codec が例外を送出した場合には "NULL" を返します。


Raw-Unicode-Escape Codecs
-------------------------

以下は "Raw Unicode Escape" codec の APIです:

PyObject *PyUnicode_DecodeRawUnicodeEscape(const char *str, Py_ssize_t size, const char *errors)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   Create a Unicode object by decoding *size* bytes of the Raw-
   Unicode-Escape encoded string *str*.  Return "NULL" if an exception
   was raised by the codec.

PyObject *PyUnicode_AsRawUnicodeEscapeString(PyObject *unicode)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   Raw-Unicode-Escape を使い Unicode オブジェクトをエンコードし、結果
   を bytes オブジェクトとして返します。 エラー処理は "strict" です。
   codec が例外を送出した場合には "NULL" を返します。


Latin-1 Codecs
--------------

以下は Latin-1 codec の APIです: Latin-1 は、 Unicode 序数の最初の 256
個に対応し、エンコード時にはこの 256 個だけを受理します。

PyObject *PyUnicode_DecodeLatin1(const char *str, Py_ssize_t size, const char *errors)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   Latin-1 でエンコードされた *size* バイトの文字列 *str* から Unicode
   オブジェクトを生成します。codec が例外を送出した場合には "NULL" を
   返します。

PyObject *PyUnicode_AsLatin1String(PyObject *unicode)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   Latin-1 で Unicode オブジェクトをエンコードし、結果を Python bytes
   オブジェクトとして返します。 エラー処理は "strict" です。 codec が
   例外を送出した場合には "NULL" を返します。


ASCII Codecs
------------

以下は ASCII codec の APIです。 7 ビットの ASCII データだけを受理しま
す。その他のコードはエラーになります。

PyObject *PyUnicode_DecodeASCII(const char *str, Py_ssize_t size, const char *errors)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   Create a Unicode object by decoding *size* bytes of the ASCII
   encoded string *str*.  Return "NULL" if an exception was raised by
   the codec.

PyObject *PyUnicode_AsASCIIString(PyObject *unicode)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   ASCII で Unicode オブジェクトをエンコードし、結果を Python bytes オ
   ブジェクトとして返します。 エラー処理は "strict" です。 codec が例
   外を送出した場合には "NULL" を返します。


Character Map Codecs
--------------------

この codec は、多くの様々な codec を実装する際に使われるという点で特殊
な codec です (実際、 "encodings" パッケージに入っている標準 codecs の
ほとんどは、この codec を使っています)。 この codec は、文字のエンコー
ドやデコードに対応表を使います。 提供される対応表のオブジェクトは
"__getitem__()" マッピングインターフェースをサポートしていなければなり
ません; 辞書やシーケンスがそれに適しています。

以下は mapping codec の APIです:

PyObject *PyUnicode_DecodeCharmap(const char *str, Py_ssize_t length, PyObject *mapping, const char *errors)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   与えられた *mapping* オブジェクトを使って、 *size* バイトのエンコー
   ドされた文字列 *str* をデコードして Unicode オブジェクトを作成しま
   す。 codec が例外を発生させたときは "NULL" を返します。

   If *mapping* is "NULL", Latin-1 decoding will be applied.  Else
   *mapping* must map bytes ordinals (integers in the range from 0 to
   255) to Unicode strings, integers (which are then interpreted as
   Unicode ordinals) or "None".  Unmapped data bytes -- ones which
   cause a "LookupError", as well as ones which get mapped to "None",
   "0xFFFE" or "'\ufffe'", are treated as undefined mappings and cause
   an error.

PyObject *PyUnicode_AsCharmapString(PyObject *unicode, PyObject *mapping)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   Unicode オブジェクトを *mapping* に指定されたオブジェクトを使ってエ
   ンコードし、結果を bytes オブジェクトとして返します。エラー処理は
   "strict" です。 codec が例外を送出した場合には "NULL" を返します。

   The *mapping* object must map Unicode ordinal integers to bytes
   objects, integers in the range from 0 to 255 or "None".  Unmapped
   character ordinals (ones which cause a "LookupError") as well as
   mapped to "None" are treated as "undefined mapping" and cause an
   error.

以下の codec API は Unicode から Unicode への対応付けを行う特殊なもの
です。

PyObject *PyUnicode_Translate(PyObject *unicode, PyObject *table, const char *errors)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   文字列に文字対応表 *table* を適用して変換し、変換結果を Unicode オ
   ブジェクトで返します。codec が例外を発行した場合には "NULL" を返し
   ます。

   対応表は、Unicode 序数を表す整数を Unicode 序数を表す整数または
   "None" (その文字を削除する) に対応付けなければなりません。

   Mapping tables need only provide the "__getitem__()" interface;
   dictionaries and sequences work well.  Unmapped character ordinals
   (ones which cause a "LookupError") are left untouched and are
   copied as-is.

   *errors* は codecs で通常使われるのと同じ意味を持ちます。 *errors*
   は "NULL" にしてもよく、デフォルトエラー処理の使用を意味します。


Windows 用の MBCS codec
-----------------------

以下は MBCS codec の API です。この codec は現在のところ、 Windows 上
だけで利用でき、変換の実装には Win32 MBCS 変換機構 (Win32 MBCS
converter) を使っています。 MBCS (または DBCS) はエンコード方式の種類
(class) を表す言葉で、単一のエンコード方式を表すわけでなないので注意し
てください。利用されるエンコード方式 (target encoding) は、 codec を動
作させているマシン上のユーザ設定で定義されています。

PyObject *PyUnicode_DecodeMBCS(const char *str, Py_ssize_t size, const char *errors)
    *戻り値: 新しい参照。** 次に属します: Stable ABI on Windows (バー
   ジョン 3.7 より).*

   Create a Unicode object by decoding *size* bytes of the MBCS
   encoded string *str*. Return "NULL" if an exception was raised by
   the codec.

PyObject *PyUnicode_DecodeMBCSStateful(const char *str, Py_ssize_t size, const char *errors, Py_ssize_t *consumed)
    *戻り値: 新しい参照。** 次に属します: Stable ABI on Windows (バー
   ジョン 3.7 より).*

   *consumed* が "NULL" のとき、 "PyUnicode_DecodeMBCS()" と同じ動作を
   します。 *consumed* が "NULL" でないとき、
   "PyUnicode_DecodeMBCSStateful()" は文字列の最後にあるマルチバイト文
   字の前半バイトをデコードせず、 *consumed* にデコードしたバイト数を
   格納します。

PyObject *PyUnicode_DecodeCodePageStateful(int code_page, const char *str, Py_ssize_t size, const char *errors, Py_ssize_t *consumed)
    *戻り値: 新しい参照。** 次に属します: Stable ABI on Windows (バー
   ジョン 3.7 より).*

   Similar to "PyUnicode_DecodeMBCSStateful()", except uses the code
   page specified by *code_page*.

PyObject *PyUnicode_AsMBCSString(PyObject *unicode)
    *戻り値: 新しい参照。** 次に属します: Stable ABI on Windows (バー
   ジョン 3.7 より).*

   MBCS で Unicode オブジェクトをエンコードし、結果を Python バイト列
   オブジェクトとして返します。エラー処理は "strict" です。 codec が例
   外を送出した場合には "NULL" を返します。

PyObject *PyUnicode_EncodeCodePage(int code_page, PyObject *unicode, const char *errors)
    *戻り値: 新しい参照。** 次に属します: Stable ABI on Windows (バー
   ジョン 3.7 より).*

   Encode the Unicode object using the specified code page and return
   a Python bytes object.  Return "NULL" if an exception was raised by
   the codec. Use "CP_ACP" code page to get the MBCS encoder.

   Added in version 3.3.


メソッドおよびスロット関数 (slot function)
==========================================

以下の API は Unicode オブジェクトおよび文字列を入力に取り (説明では、
どちらも文字列と表記しています)、場合に応じて Unicode オブジェクトか整
数を返す機能を持っています。

これらの関数は全て、例外が発生した場合には "NULL" または "-1" を返しま
す。

PyObject *PyUnicode_Concat(PyObject *left, PyObject *right)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   二つの文字列を結合して、新たな Unicode 文字列を生成します。

PyObject *PyUnicode_Split(PyObject *unicode, PyObject *sep, Py_ssize_t maxsplit)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   Unicode 文字列のリストを分割して、 Unicode 文字列からなるリストを返
   します。 *sep* が "NULL" の場合、全ての空白文字を使って分割を行いま
   す。それ以外の場合、指定された文字を使って分割を行います。最大で
   *maxsplit* 個までの分割を行います。 *maxsplit* が負ならば分割数に制
   限を設けません。分割結果のリスト内には分割文字は含みません。

   On error, return "NULL" with an exception set.

   Equivalent to "str.split()".

PyObject *PyUnicode_RSplit(PyObject *unicode, PyObject *sep, Py_ssize_t maxsplit)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   Similar to "PyUnicode_Split()", but splitting will be done
   beginning at the end of the string.

   On error, return "NULL" with an exception set.

   Equivalent to "str.rsplit()".

PyObject *PyUnicode_Splitlines(PyObject *unicode, int keepends)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   Split a Unicode string at line breaks, returning a list of Unicode
   strings. CRLF is considered to be one line break.  If *keepends* is
   "0", the Line break characters are not included in the resulting
   strings.

PyObject *PyUnicode_Partition(PyObject *unicode, PyObject *sep)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   Split a Unicode string at the first occurrence of *sep*, and return
   a 3-tuple containing the part before the separator, the separator
   itself, and the part after the separator. If the separator is not
   found, return a 3-tuple containing the string itself, followed by
   two empty strings.

   *sep* must not be empty.

   On error, return "NULL" with an exception set.

   Equivalent to "str.partition()".

PyObject *PyUnicode_RPartition(PyObject *unicode, PyObject *sep)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   Similar to "PyUnicode_Partition()", but split a Unicode string at
   the last occurrence of *sep*. If the separator is not found, return
   a 3-tuple containing two empty strings, followed by the string
   itself.

   *sep* must not be empty.

   On error, return "NULL" with an exception set.

   Equivalent to "str.rpartition()".

PyObject *PyUnicode_Join(PyObject *separator, PyObject *seq)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   指定した *separator* で文字列からなるシーケンスを連結 (join) し、連
   結結果を Unicode 文字列で返します。

Py_ssize_t PyUnicode_Tailmatch(PyObject *unicode, PyObject *substr, Py_ssize_t start, Py_ssize_t end, int direction)
    * 次に属します: Stable ABI.*

   Return "1" if *substr* matches "unicode[start:end]" at the given
   tail end (*direction* == "-1" means to do a prefix match,
   *direction* == "1" a suffix match), "0" otherwise. Return "-1" if
   an error occurred.

Py_ssize_t PyUnicode_Find(PyObject *unicode, PyObject *substr, Py_ssize_t start, Py_ssize_t end, int direction)
    * 次に属します: Stable ABI.*

   "unicode[start:end]" 中に *substr* が最初に出現する場所を返します。
   このとき指定された検索方向 *direction* (*direction* == "1" は順方向
   検索、 *direction* == "-1" は逆方向検索) で検索します。 戻り値は最
   初にマッチが見つかった場所のインデックスです; 戻り値 "-1" はマッチ
   が見つからなかったことを表し、 "-2" はエラーが発生して例外情報が設
   定されていることを表します。

Py_ssize_t PyUnicode_FindChar(PyObject *unicode, Py_UCS4 ch, Py_ssize_t start, Py_ssize_t end, int direction)
    * 次に属します: Stable ABI (バージョン 3.7 より).*

   "unicode[start:end]" 中に文字 *ch* が最初に出現する場所を返します。
   このとき指定された検索方向 *direction* (*direction* == "1" は順方向
   検索、 *direction* == "-1" は逆方向検索) で検索します。 戻り値は最
   初にマッチが見つかった場所のインデックスです; 戻り値 "-1" はマッチ
   が見つからなかったことを表し、 "-2" はエラーが発生して例外情報が設
   定されていることを表します。

   Added in version 3.3.

   バージョン 3.7 で変更: *start* and *end* are now adjusted to behave
   like "unicode[start:end]".

Py_ssize_t PyUnicode_Count(PyObject *unicode, PyObject *substr, Py_ssize_t start, Py_ssize_t end)
    * 次に属します: Stable ABI.*

   "unicode[start:end]" に *substr* が重複することなく出現する回数を返
   します。エラーが発生した場合には "-1" を返します。

PyObject *PyUnicode_Replace(PyObject *unicode, PyObject *substr, PyObject *replstr, Py_ssize_t maxcount)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   *unicode* 中に出現する *substr* を最大で *maxcount* 個 *replstr* に
   置換し、置換結果である Unicode オブジェクトを返します。 *maxcount*
   == "-1" にすると、文字列中に現れる全ての *substr* を置換します。

int PyUnicode_Compare(PyObject *left, PyObject *right)
    * 次に属します: Stable ABI.*

   二つの文字列を比較して、左引数が右引数より小さい場合、左右引数が等
   価の場合、左引数が右引数より大きい場合に対して、それぞれ "-1", "0",
   "1" を返します。

   この関数は、失敗したときに "-1" を返すので、 "PyErr_Occurred()" を
   呼び出して、エラーをチェックすべきです。

   参考: The "PyUnicode_Equal()" function.

int PyUnicode_Equal(PyObject *a, PyObject *b)
    * 次に属します: Stable ABI (バージョン 3.14 より).*

   Test if two strings are equal:

   * Return "1" if *a* is equal to *b*.

   * Return "0" if *a* is not equal to *b*.

   * Set a "TypeError" exception and return "-1" if *a* or *b* is not
     a "str" object.

   The function always succeeds if *a* and *b* are "str" objects.

   The function works for "str" subclasses, but does not honor custom
   "__eq__()" method.

   参考: The "PyUnicode_Compare()" function.

   Added in version 3.14.

int PyUnicode_EqualToUTF8AndSize(PyObject *unicode, const char *string, Py_ssize_t size)
    * 次に属します: Stable ABI (バージョン 3.13 より).*

   Compare a Unicode object with a char buffer which is interpreted as
   being UTF-8 or ASCII encoded and return true ("1") if they are
   equal, or false ("0") otherwise. If the Unicode object contains
   surrogate code points ("U+D800" - "U+DFFF") or the C string is not
   valid UTF-8, false ("0") is returned.

   この関数は例外を送出しません。

   Added in version 3.13.

int PyUnicode_EqualToUTF8(PyObject *unicode, const char *string)
    * 次に属します: Stable ABI (バージョン 3.13 より).*

   Similar to "PyUnicode_EqualToUTF8AndSize()", but compute *string*
   length using "strlen()". If the Unicode object contains null
   characters, false ("0") is returned.

   Added in version 3.13.

int PyUnicode_CompareWithASCIIString(PyObject *unicode, const char *string)
    * 次に属します: Stable ABI.*

   Unicode オブジェクト *unicode* と *string* を比較して、左引数が右引
   数より小さい場合、左右引数が等価の場合、左引数が右引数より大きい場
   合に対して、それぞれ "-1", "0", "1" を返します。 ASCII エンコードさ
   れた文字列だけを渡すのが最も良いですが、入力文字列に非 ASCII 文字が
   含まれている場合は ISO-8859-1 として解釈します。

   この関数は例外を送出しません。

PyObject *PyUnicode_RichCompare(PyObject *left, PyObject *right, int op)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   二つのUnicode文字列を比較して、下のうちの一つを返します:

   * "NULL" を、例外が発生したときに返します。

   * "Py_True" もしくは "Py_False" を、正しく比較できた時に返します。

   * "Py_NotImplemented" in case the type combination is unknown

   Possible values for *op* are "Py_GT", "Py_GE", "Py_EQ", "Py_NE",
   "Py_LT", and "Py_LE".

PyObject *PyUnicode_Format(PyObject *format, PyObject *args)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   新たな文字列オブジェクトを *format* および *args* から生成して返し
   ます; このメソッドは "format % args" のようなものです。

int PyUnicode_Contains(PyObject *unicode, PyObject *substr)
    * 次に属します: Stable ABI.*

   *substr* が *unicode* 内にあるか調べ、その結果に応じて真または偽を
   返します。

   *substr* は単要素の Unicode 文字に型強制できなければなりません。エ
   ラーが生じた場合には "-1" を返します。

void PyUnicode_InternInPlace(PyObject **p_unicode)
    * 次に属します: Stable ABI.*

   Intern the argument *p_unicode in place.  The argument must be the
   address of a pointer variable pointing to a Python Unicode string
   object.  If there is an existing interned string that is the same
   as *p_unicode, it sets *p_unicode to it (releasing the reference to
   the old string object and creating a new *strong reference* to the
   interned string object), otherwise it leaves *p_unicode alone and
   interns it.

   (Clarification: even though there is a lot of talk about
   references, think of this function as reference-neutral. You must
   own the object you pass in; after the call you no longer own the
   passed-in reference, but you newly own the result.)

   This function never raises an exception. On error, it leaves its
   argument unchanged without interning it.

   Instances of subclasses of "str" may not be interned, that is,
   PyUnicode_CheckExact(*p_unicode) must be true. If it is not, then
   -- as with any other error -- the argument is left unchanged.

   Note that interned strings are not “immortal”. You must keep a
   reference to the result to benefit from interning.

PyObject *PyUnicode_InternFromString(const char *str)
    *戻り値: 新しい参照。** 次に属します: Stable ABI.*

   A combination of "PyUnicode_FromString()" and
   "PyUnicode_InternInPlace()", meant for statically allocated
   strings.

   Return a new ("owned") reference to either a new Unicode string
   object that has been interned, or an earlier interned string object
   with the same value.

   Python may keep a reference to the result, or make it *immortal*,
   preventing it from being garbage-collected promptly. For interning
   an unbounded number of different strings, such as ones coming from
   user input, prefer calling "PyUnicode_FromString()" and
   "PyUnicode_InternInPlace()" directly.

unsigned int PyUnicode_CHECK_INTERNED(PyObject *str)

   Return a non-zero value if *str* is interned, zero if not. The
   *str* argument must be a string; this is not checked. This function
   always succeeds.

   **CPython 実装の詳細:** A non-zero return value may carry
   additional information about *how* the string is interned. The
   meaning of such non-zero values, as well as each specific string's
   intern-related details, may change between CPython versions.


PyUnicodeWriter
===============

The "PyUnicodeWriter" API can be used to create a Python "str" object.

Added in version 3.14.

type PyUnicodeWriter

   A Unicode writer instance.

   The instance must be destroyed by "PyUnicodeWriter_Finish()" on
   success, or "PyUnicodeWriter_Discard()" on error.

PyUnicodeWriter *PyUnicodeWriter_Create(Py_ssize_t length)

   Create a Unicode writer instance.

   *length* must be greater than or equal to "0".

   If *length* is greater than "0", preallocate an internal buffer of
   *length* characters.

   Set an exception and return "NULL" on error.

PyObject *PyUnicodeWriter_Finish(PyUnicodeWriter *writer)

   Return the final Python "str" object and destroy the writer
   instance.

   Set an exception and return "NULL" on error.

   The writer instance is invalid after this call.

void PyUnicodeWriter_Discard(PyUnicodeWriter *writer)

   Discard the internal Unicode buffer and destroy the writer
   instance.

   If *writer* is "NULL", no operation is performed.

   The writer instance is invalid after this call.

int PyUnicodeWriter_WriteChar(PyUnicodeWriter *writer, Py_UCS4 ch)

   Write the single Unicode character *ch* into *writer*.

   On success, return "0". On error, set an exception, leave the
   writer unchanged, and return "-1".

int PyUnicodeWriter_WriteUTF8(PyUnicodeWriter *writer, const char *str, Py_ssize_t size)

   Decode the string *str* from UTF-8 in strict mode and write the
   output into *writer*.

   *size* is the string length in bytes. If *size* is equal to "-1",
   call "strlen(str)" to get the string length.

   On success, return "0". On error, set an exception, leave the
   writer unchanged, and return "-1".

   See also "PyUnicodeWriter_DecodeUTF8Stateful()".

int PyUnicodeWriter_WriteASCII(PyUnicodeWriter *writer, const char *str, Py_ssize_t size)

   Write the ASCII string *str* into *writer*.

   *size* is the string length in bytes. If *size* is equal to "-1",
   call "strlen(str)" to get the string length.

   *str* must only contain ASCII characters. The behavior is undefined
   if *str* contains non-ASCII characters.

   On success, return "0". On error, set an exception, leave the
   writer unchanged, and return "-1".

   Added in version 3.14.

int PyUnicodeWriter_WriteWideChar(PyUnicodeWriter *writer, const wchar_t *str, Py_ssize_t size)

   Write the wide string *str* into *writer*.

   *size* is a number of wide characters. If *size* is equal to "-1",
   call "wcslen(str)" to get the string length.

   On success, return "0". On error, set an exception, leave the
   writer unchanged, and return "-1".

int PyUnicodeWriter_WriteUCS4(PyUnicodeWriter *writer, Py_UCS4 *str, Py_ssize_t size)

   Writer the UCS4 string *str* into *writer*.

   *size* is a number of UCS4 characters.

   On success, return "0". On error, set an exception, leave the
   writer unchanged, and return "-1".

int PyUnicodeWriter_WriteStr(PyUnicodeWriter *writer, PyObject *obj)

   Call "PyObject_Str()" on *obj* and write the output into *writer*.

   On success, return "0". On error, set an exception, leave the
   writer unchanged, and return "-1".

int PyUnicodeWriter_WriteRepr(PyUnicodeWriter *writer, PyObject *obj)

   Call "PyObject_Repr()" on *obj* and write the output into *writer*.

   On success, return "0". On error, set an exception, leave the
   writer unchanged, and return "-1".

int PyUnicodeWriter_WriteSubstring(PyUnicodeWriter *writer, PyObject *str, Py_ssize_t start, Py_ssize_t end)

   Write the substring "str[start:end]" into *writer*.

   *str* must be Python "str" object. *start* must be greater than or
   equal to 0, and less than or equal to *end*. *end* must be less
   than or equal to *str* length.

   On success, return "0". On error, set an exception, leave the
   writer unchanged, and return "-1".

int PyUnicodeWriter_Format(PyUnicodeWriter *writer, const char *format, ...)

   Similar to "PyUnicode_FromFormat()", but write the output directly
   into *writer*.

   On success, return "0". On error, set an exception, leave the
   writer unchanged, and return "-1".

int PyUnicodeWriter_DecodeUTF8Stateful(PyUnicodeWriter *writer, const char *string, Py_ssize_t length, const char *errors, Py_ssize_t *consumed)

   Decode the string *str* from UTF-8 with *errors* error handler and
   write the output into *writer*.

   *size* is the string length in bytes. If *size* is equal to "-1",
   call "strlen(str)" to get the string length.

   *errors* is an error handler name, such as ""replace"". If *errors*
   is "NULL", use the strict error handler.

   If *consumed* is not "NULL", set **consumed* to the number of
   decoded bytes on success. If *consumed* is "NULL", treat trailing
   incomplete UTF-8 byte sequences as an error.

   On success, return "0". On error, set an exception, leave the
   writer unchanged, and return "-1".

   See also "PyUnicodeWriter_WriteUTF8()".


Deprecated API
==============

The following API is deprecated.

type Py_UNICODE

   This is a typedef of "wchar_t", which is a 16-bit type or 32-bit
   type depending on the platform. Please use "wchar_t" directly
   instead.

   バージョン 3.3 で変更: 以前のバージョンでは、Pythonをビルドした際に
   "narrow" または "wide" Unicode バージョンのどちらを選択したかによっ
   て、 16ビットか32ビットのどちらかの型になっていました。

   Deprecated since version 3.13, will be removed in version 3.15.

int PyUnicode_READY(PyObject *unicode)

   Do nothing and return "0". This API is kept only for backward
   compatibility, but there are no plans to remove it.

   Added in version 3.3.

   バージョン 3.10 で非推奨: This API does nothing since Python 3.12.
   Previously, this needed to be called for each string created using
   the old API ("PyUnicode_FromUnicode()" or similar).

unsigned int PyUnicode_IS_READY(PyObject *unicode)

   Do nothing and return "1". This API is kept only for backward
   compatibility, but there are no plans to remove it.

   Added in version 3.3.

   バージョン 3.14 で非推奨: This API does nothing since Python 3.12.
   Previously, this could be called to check if "PyUnicode_READY()" is
   necessary.
