유니코드 객체와 코덱
********************


유니코드 객체
=============

파이썬 3.3에서 **PEP 393**을 구현한 이후, 유니코드 객체는 내부적으로
다양한 표현을 사용하여 전체 유니코드 문자 범위를 처리하면서 메모리 효
율성을 유지합니다. 모든 코드 포인트가 128, 256 또는 65536 미만인 문자
열에 대한 특별한 경우가 있습니다; 그렇지 않으면, 코드 포인트는 1114112
(전체 유니코드 범위) 미만이어야 합니다.

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.


유니코드 형
-----------

다음은 파이썬에서 유니코드 구현에 사용되는 기본 유니코드 객체 형입니다
:

type Py_UCS4
type Py_UCS2
type Py_UCS1
    * Part of the Stable ABI.*

   이 형들은 각각 32비트, 16비트 및 8비트의 문자를 포함하기에 충분한
   부호 없는 정수 형을 위한 typedef 입니다. 단일 유니코드 문자를 처리
   할 때는, "Py_UCS4"를 사용하십시오.

   Added in version 3.3.

type Py_UNICODE

   이것은 플랫폼에 따라 16비트 형이나 32비트 형인 "wchar_t"의 typedef
   입니다.

   버전 3.3에서 변경: 이전 버전에서, 이것은 빌드 시 파이썬의 "내로우
   (narrow)"나 "와이드(wide)" 유니코드 버전 중 어느 것을 선택했는지에
   따라 16비트 형이나 32비트 형이었습니다.

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

type PyASCIIObject
type PyCompactUnicodeObject
type PyUnicodeObject

   이 "PyObject" 서브 형들은 파이썬 유니코드 객체를 나타냅니다. 거의
   모든 경우에, 유니코드 객체를 처리하는 모든 API 함수가 "PyObject" 포
   인터를 취하고 반환하므로 직접 사용해서는 안 됩니다.

   Added in version 3.3.

PyTypeObject PyUnicode_Type
    * Part of the Stable ABI.*

   이 "PyTypeObject" 인스턴스는 파이썬 유니코드 형을 나타냅니다. 파이
   썬 코드에 "str"로 노출됩니다.

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)

   Return true if the object *obj* is a Unicode object or an instance
   of a Unicode subtype.  This function always succeeds.

int PyUnicode_CheckExact(PyObject *obj)

   Return true if the object *obj* is a Unicode object, but not an
   instance of a subtype.  This function always succeeds.

int PyUnicode_READY(PyObject *unicode)

   Returns "0". This API is kept only for backward compatibility.

   Added in version 3.3.

   버전 3.10부터 폐지됨: This API does nothing since Python 3.12.

Py_ssize_t PyUnicode_GET_LENGTH(PyObject *unicode)

   Return the length of the Unicode string, in code points.  *unicode*
   has to be a Unicode object in the "canonical" representation (not
   checked).

   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)

   Return a pointer to the canonical representation cast to UCS1, UCS2
   or UCS4 integer types for direct character access.  No checks are
   performed if the canonical representation has the correct character
   size; use "PyUnicode_KIND()" to select the right function.

   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" has been removed.

int PyUnicode_KIND(PyObject *unicode)

   Return one of the PyUnicode kind constants (see above) that
   indicate how many bytes per character this Unicode object uses to
   store its data.  *unicode* has to be a Unicode object in the
   "canonical" representation (not checked).

   Added in version 3.3.

void *PyUnicode_DATA(PyObject *unicode)

   Return a void pointer to the raw Unicode buffer.  *unicode* has to
   be a Unicode object in the "canonical" representation (not
   checked).

   Added in version 3.3.

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

   Write into a canonical representation *data* (as obtained with
   "PyUnicode_DATA()").  This function performs no sanity checks, and
   is intended for usage in loops.  The caller should cache the *kind*
   value and *data* pointer as obtained from other calls.  *index* is
   the index in the string (starts at 0) and *value* is the new code
   point value which should be written to that location.

   Added in version 3.3.

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

   규범적(canonical) 표현 *data*("PyUnicode_DATA()"로 얻은 대로)에서
   코드 포인트를 읽습니다. 검사나 준비(ready) 호출이 수행되지 않습니다
   .

   Added in version 3.3.

Py_UCS4 PyUnicode_READ_CHAR(PyObject *unicode, Py_ssize_t index)

   Read a character from a Unicode object *unicode*, which must be in
   the "canonical" representation.  This is less efficient than
   "PyUnicode_READ()" if you do multiple consecutive reads.

   Added in version 3.3.

Py_UCS4 PyUnicode_MAX_CHAR_VALUE(PyObject *unicode)

   Return the maximum code point that is suitable for creating another
   string based on *unicode*, which must be in the "canonical"
   representation.  This is always an approximation but more efficient
   than iterating over the string.

   Added in version 3.3.

int PyUnicode_IsIdentifier(PyObject *unicode)
    * Part of the Stable ABI.*

   언어 정의에 따라 문자열이 유효한 식별자이면 "1"을 반환합니다, 섹션
   식별자와 키워드. 그렇지 않으면 "0"을 반환합니다.

   버전 3.9에서 변경: 문자열이 준비(ready)되지 않았을 때, 이 함수는 더
   는 "Py_FatalError()"를 호출하지 않습니다.


유니코드 문자 속성
------------------

유니코드는 다양한 문자 속성을 제공합니다. 가장 자주 필요한 것은 파이썬
구성에 따라 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*가 제목 케이스 문자인지에 따라 "1"이나 "0"을 반환합니다.

int Py_UNICODE_ISLINEBREAK(Py_UCS4 ch)

   *ch*가 줄 바꿈 문자인지에 따라 "1"이나 "0"을 반환합니다.

int Py_UNICODE_ISDECIMAL(Py_UCS4 ch)

   *ch*가 10진수 문자인지에 따라 "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)

   Return the character *ch* converted to a double. Return "-1.0" if
   this is not possible.  This function does not raise exceptions.

다음 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_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].


유니코드 문자열 생성과 액세스
-----------------------------

유니코드 객체를 만들고 기본 시퀀스 속성에 액세스하려면 다음 API를 사용
하십시오:

PyObject *PyUnicode_New(Py_ssize_t size, Py_UCS4 maxchar)
    *Return value: New reference.*

   새 유니코드 객체를 만듭니다. *maxchar*은 문자열에 배치할 실제 최대
   코드 포인트여야 합니다. 근삿값으로, 127, 255, 65535, 1114111 시퀀스
   에서 가장 가까운 값으로 올림 할 수 있습니다.

   이것은 새 유니코드 객체를 할당하는 데 권장되는 방법입니다. 이 함수
   를 사용하여 만든 객체는 크기를 조정할 수 없습니다.

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

   Added in version 3.3.

PyObject *PyUnicode_FromKindAndData(int kind, const void *buffer, Py_ssize_t size)
    *Return value: New reference.*

   주어진 *kind*(가능한 값은 "PyUnicode_KIND()"에 의해 반환된
   "PyUnicode_1BYTE_KIND" 등입니다)로 새로운 유니코드 객체를 만듭니다.
   *buffer*는 kind에 따라 문자 당 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)
    *Return value: New reference.** Part of the 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)
    *Return value: New reference.** Part of the Stable ABI.*

   Create a Unicode object from a UTF-8 encoded null-terminated char
   buffer *str*.

PyObject *PyUnicode_FromFormat(const char *format, ...)
    *Return value: New reference.** Part of the 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.

   A conversion specifier contains two or more characters and has the
   following components, which must occur in this order:

   1. The "'%'" character, which marks the start of the specifier.

   2. Conversion flags (optional), which affect the result of some
      conversion types.

   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. Length modifier (optional).

   6. Conversion type.

   The conversion flag characters are:

   +---------+---------------------------------------------------------------+
   | Flag    | Meaning                                                       |
   |=========|===============================================================|
   | "0"     | The conversion will be zero padded for numeric values.        |
   +---------+---------------------------------------------------------------+
   | "-"     | 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):

   +------------+-------------------------------------------------------+
   | Modifier   | Types                                                 |
   |============|=======================================================|
   | "l"        | long or unsigned long                                 |
   +------------+-------------------------------------------------------+
   | "ll"       | long long or 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* or const wchar_t*     | 널-종료 C 문자 배열.              |
   +-----------------------------------+-----------------------------------+-----------------------------------+
   | "p"                               | const void*                       | The hex representation of a C     |
   |                                   |                                   | pointer. Mostly equivalent to     |
   |                                   |                                   | "printf("%p")" except that it is  |
   |                                   |                                   | guaranteed to start with the      |
   |                                   |                                   | literal "0x" regardless of what   |
   |                                   |                                   | the platform's "printf" yields.   |
   +-----------------------------------+-----------------------------------+-----------------------------------+
   | "A"                               | PyObject*                         | "ascii()"를 호출한 결과.          |
   +-----------------------------------+-----------------------------------+-----------------------------------+
   | "U"                               | PyObject*                         | 유니코드 객체.                    |
   +-----------------------------------+-----------------------------------+-----------------------------------+
   | "V"                               | PyObject*, const char* or const   | 유니코드 객체("NULL"일 수 있습니  |
   |                                   | wchar_t*                          | 다)와 두 번째 매개 변수로서 널-종 |
   |                                   |                                   | 료 C 문자 배열 (첫 번째 매개 변수 |
   |                                   |                                   | 가 "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)
    *Return value: New reference.** Part of the Stable ABI.*

   정확히 두 개의 인자를 취한다는 점을 제외하면
   "PyUnicode_FromFormat()"과 동일합니다.

PyObject *PyUnicode_FromObject(PyObject *obj)
    *Return value: New reference.** Part of the 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.

   유니코드나 이의 서브 형 이외의 객체는 "TypeError"를 발생시킵니다.

PyObject *PyUnicode_FromOrdinal(int ordinal)
    *Return value: New reference.** Part of the 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)
    *Return value: New reference.** Part of the Stable ABI.*

   인코딩된 객체 *obj*를 유니코드 객체로 디코딩합니다.

   "bytes", "bytearray" 및 기타 *바이트열류 객체*는 주어진 *encoding*
   에 따라 *errors*로 정의한 에러 처리를 사용하여 디코딩됩니다. 둘 다
   "NULL"이 될 수 있고, 이 경우 인터페이스는 기본값을 사용합니다 (자세
   한 내용은 내장 코덱를 참조하십시오).

   유니코드 객체를 포함한 다른 모든 객체는 "TypeError"가 설정되도록 합
   니다.

   API는 에러가 있으면 "NULL"을 반환합니다. 호출자는 반환된 객체의 참
   조 횟수를 감소시킬 책임이 있습니다.

const char *PyUnicode_GetDefaultEncoding(void)
    * Part of the 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)
    * Part of the Stable ABI since version 3.7.*

   유니코드 객체의 길이를 코드 포인트로 반환합니다.

   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)

   Copy characters from one Unicode object into another.  This
   function performs character conversion when necessary and falls
   back to "memcpy()" if possible.  Returns "-1" and sets an exception
   on error, otherwise returns the number of copied characters.

   Added in version 3.3.

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

   문자로 문자열을 채웁니다: *fill_char*을
   "unicode[start:start+length]"에 씁니다.

   *fill_char*이 문자열 최대 문자보다 크거나, 문자열에 둘 이상의 참조
   가 있으면 실패합니다.

   기록된 문자 수를 반환하거나, 에러 시 "-1"을 반환하고 예외를 발생시
   킵니다.

   Added in version 3.3.

int PyUnicode_WriteChar(PyObject *unicode, Py_ssize_t index, Py_UCS4 character)
    * Part of the Stable ABI since version 3.7.*

   문자열에 문자를 씁니다. 문자열은 "PyUnicode_New()"를 통해 만들었어
   야 합니다. 유니코드 문자열은 불변이므로, 문자열을 공유하거나 아직
   해시 하지 않아야 합니다.

   이 함수는 *unicode*가 유니코드 객체인지, 인덱스가 범위를 벗어났는지
   , 객체가 안전하게 수정될 수 있는지 (즉, 참조 횟수가 1인지) 확인합니
   다.

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

   Added in version 3.3.

Py_UCS4 PyUnicode_ReadChar(PyObject *unicode, Py_ssize_t index)
    * Part of the Stable ABI since version 3.7.*

   Read a character from a string.  This function checks that
   *unicode* is a Unicode object and the index is not out of bounds,
   in contrast to "PyUnicode_READ_CHAR()", which performs no error
   checking.

   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)
    *Return value: New reference.** Part of the Stable ABI since
   version 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)
    * Part of the Stable ABI since version 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)
    * Part of the Stable ABI since version 3.7.*

   Copy the string *unicode* into a new UCS4 buffer that is allocated
   using "PyMem_Malloc()".  If this fails, "NULL" is returned with a
   "MemoryError" set.  The returned buffer always has an extra null
   code point appended.

   Added in version 3.3.


로케일 인코딩
-------------

현재 로케일 인코딩을 사용하여 운영 체제에서 온 텍스트를 디코딩 할 수
있습니다.

PyObject *PyUnicode_DecodeLocaleAndSize(const char *str, Py_ssize_t length, const char *errors)
    *Return value: New reference.** Part of the Stable ABI since
   version 3.7.*

   안드로이드와 VxWorks의 UTF-8이나 다른 플랫폼의 현재 로케일 인코딩의
   문자열을 디코딩합니다. 지원되는 에러 처리기는 ""strict""와
   ""surrogateescape""(**PEP 383**)입니다. 디코더는 *errors*가 "NULL"
   이면 ""strict"" 에러 처리기를 사용합니다. *str*은 널 문자로 끝나야
   하지만 널 문자를 포함할 수 없습니다.

   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에서 변경: 이 함수는 이제 안드로이드를 제외하고
   "surrogateescape" 에러 처리기에 현재 로케일 인코딩도 사용합니다. 이
   전에는, "Py_DecodeLocale()"이 "surrogateescape"에 사용되었고, 현재
   로케일 인코딩은 "strict"에 사용되었습니다.

PyObject *PyUnicode_DecodeLocale(const char *str, const char *errors)
    *Return value: New reference.** Part of the Stable ABI since
   version 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)
    *Return value: New reference.** Part of the Stable ABI since
   version 3.7.*

   유니코드 객체를 안드로이드와 VxWorks에서 UTF-8로 인코딩하거나, 다른
   플랫폼에서 현재 로케일 인코딩으로 인코딩합니다. 지원되는 에러 처리
   기는 ""strict""와 ""surrogateescape""(**PEP 383**)입니다. 인코더는
   *errors*가 "NULL"이면 ""strict"" 에러 처리기를 사용합니다. "bytes"
   객체를 반환합니다. *unicode*는 내장된 널 문자를 포함할 수 없습니다.

   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에서 변경: 이 함수는 이제 안드로이드를 제외하고
   "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)
    * Part of the 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에서 변경: *경로류 객체*를 받아들입니다.

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)
    * Part of the 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에서 변경: *경로류 객체*를 받아들입니다.

PyObject *PyUnicode_DecodeFSDefaultAndSize(const char *str, Py_ssize_t size)
    *Return value: New reference.** Part of the 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)
    *Return value: New reference.** Part of the 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)
    *Return value: New reference.** Part of the 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" 지원:

PyObject *PyUnicode_FromWideChar(const wchar_t *wstr, Py_ssize_t size)
    *Return value: New reference.** Part of the 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)
    * Part of the 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)
    * Part of the Stable ABI since version 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.


내장 코덱
=========

파이썬은 속도를 위해 C로 작성된 내장 코덱 집합을 제공합니다. 이러한 코
덱들은 모두 다음 함수들을 통해 직접 사용할 수 있습니다.

다음 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"로 설정될 수도 있습니다. 모든 내장 코덱에 대한 기본
에러 처리는 "strict" 입니다 ("ValueError"가 발생합니다).

The codecs all use a similar interface.  Only deviations from the
following generic ones are documented for simplicity.


일반 코덱
---------

다음은 일반 코덱 API입니다:

PyObject *PyUnicode_Decode(const char *str, Py_ssize_t size, const char *encoding, const char *errors)
    *Return value: New reference.** Part of the 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)
    *Return value: New reference.** Part of the Stable ABI.*

   유니코드 객체를 인코딩하고 결과를 파이썬 bytes 객체로 반환합니다.
   *encoding*과 *errors*는 유니코드 "encode()" 메서드의 같은 이름의 매
   개 변수와 같은 의미입니다. 사용할 코덱은 파이썬 코덱 레지스트리를
   사용하여 조회됩니다. 코덱에서 예외가 발생하면 "NULL"을 반환합니다.


UTF-8 코덱
----------

다음은 UTF-8 코덱 API입니다:

PyObject *PyUnicode_DecodeUTF8(const char *str, Py_ssize_t size, const char *errors)
    *Return value: New reference.** Part of the Stable ABI.*

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

PyObject *PyUnicode_DecodeUTF8Stateful(const char *str, Py_ssize_t size, const char *errors, Py_ssize_t *consumed)
    *Return value: New reference.** Part of the Stable ABI.*

   *consumed*가 "NULL"이면, "PyUnicode_DecodeUTF8()"처럼 동작합니다.
   *consumed*가 "NULL"이 아니면, 후행 불완전한 UTF-8 바이트 시퀀스는
   에러로 처리되지 않습니다. 이러한 바이트는 디코딩되지 않으며 디코딩
   된 바이트 수는 *consumed*에 저장됩니다.

PyObject *PyUnicode_AsUTF8String(PyObject *unicode)
    *Return value: New reference.** Part of the Stable ABI.*

   UTF-8을 사용하여 유니코드 객체를 인코딩하고 결과를 파이썬 bytes 객
   체로 반환합니다. 에러 처리는 "strict" 입니다. 코덱에서 예외가 발생
   하면 "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)
    * Part of the Stable ABI since version 3.10.*

   유니코드 객체의 UTF-8 인코딩에 대한 포인터를 반환하고, 인코딩된 표
   현의 크기를 (바이트 단위로) *size*에 저장합니다. *size* 인자는
   "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 코덱
-----------

다음은 UTF-32 코덱 API입니다:

PyObject *PyUnicode_DecodeUTF32(const char *str, Py_ssize_t size, const char *errors, int *byteorder)
    *Return value: New reference.** Part of the Stable ABI.*

   UTF-32로 인코딩된 버퍼 문자열에서 *size* 바이트를 디코딩하고 해당
   유니코드 객체를 반환합니다. *errors*("NULL"이 아니면)는 에러 처리를
   정의합니다. 기본값은 "strict"입니다.

   *byteorder*가 "NULL"이 아니면, 디코더는 지정된 바이트 순서를 사용하
   여 디코딩을 시작합니다:

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

   "*byteorder"가 0이고, 입력 데이터의 처음 4바이트가 바이트 순서 표시
   (BOM)이면, 디코더가 이 바이트 순서로 전환되고 BOM은 결과 유니코드
   문자열에 복사되지 않습니다. "*byteorder"가 "-1"이나 "1"이면, 모든
   바이트 순서 표시가 출력에 복사됩니다.

   완료 후, **byteorder*는 입력 데이터의 끝에서 현재 바이트 순서로 설
   정됩니다.

   *byteorder*가 "NULL"이면, 코덱은 네이티브 순서 모드로 시작합니다.

   코덱에서 예외가 발생하면 "NULL"을 반환합니다.

PyObject *PyUnicode_DecodeUTF32Stateful(const char *str, Py_ssize_t size, const char *errors, int *byteorder, Py_ssize_t *consumed)
    *Return value: New reference.** Part of the Stable ABI.*

   *consumed*가 "NULL"이면, "PyUnicode_DecodeUTF32()"처럼 동작합니다.
   *consumed*가 "NULL"이 아니면, "PyUnicode_DecodeUTF32Stateful()" 은
   후행 불완전 UTF-32 바이트 시퀀스(가령 4로 나누어떨어지지 않는 바이
   트 수)를 에러로 처리하지 않습니다. 이러한 바이트는 디코딩되지 않으
   며 디코딩된 바이트 수는 *consumed*에 저장됩니다.

PyObject *PyUnicode_AsUTF32String(PyObject *unicode)
    *Return value: New reference.** Part of the Stable ABI.*

   네이티브 바이트 순서로 UTF-32 인코딩을 사용하여 파이썬 바이트 문자
   열을 반환합니다. 문자열은 항상 BOM 마크로 시작합니다. 에러 처리는
   "strict"입니다. 코덱에서 예외가 발생하면 "NULL"을 반환합니다.


UTF-16 코덱
-----------

다음은 UTF-16 코덱 API입니다:

PyObject *PyUnicode_DecodeUTF16(const char *str, Py_ssize_t size, const char *errors, int *byteorder)
    *Return value: New reference.** Part of the Stable ABI.*

   UTF-16으로 인코딩된 버퍼 문자열에서 *size* 바이트를 디코딩하고 해당
   유니코드 객체를 반환합니다. *errors*("NULL"이 아니면)는 에러 처리를
   정의합니다. 기본값은 "strict"입니다.

   *byteorder*가 "NULL"이 아니면, 디코더는 지정된 바이트 순서를 사용하
   여 디코딩을 시작합니다:

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

   "*byteorder"가 0이고, 입력 데이터의 처음 2바이트가 바이트 순서 표시
   (BOM)이면, 디코더는 이 바이트 순서로 전환되고 BOM은 결과 유니코드
   문자열에 복사되지 않습니다. "*byteorder"가 "-1"이나 "1"이면 모든 바
   이트 순서 표시가 출력에 복사됩니다 ("\ufeff"나 "\ufffe" 문자가 됩니
   다).

   After completion, "*byteorder" is set to the current byte order at
   the end of input data.

   *byteorder*가 "NULL"이면, 코덱은 네이티브 순서 모드로 시작합니다.

   코덱에서 예외가 발생하면 "NULL"을 반환합니다.

PyObject *PyUnicode_DecodeUTF16Stateful(const char *str, Py_ssize_t size, const char *errors, int *byteorder, Py_ssize_t *consumed)
    *Return value: New reference.** Part of the Stable ABI.*

   *consumed*가 "NULL"이면, "PyUnicode_DecodeUTF16()"처럼 동작합니다.
   *consumed*가 "NULL"이 아니면, "PyUnicode_DecodeUTF16Stateful()" 은
   후행 불완전 UTF-16 바이트 시퀀스(가령 홀수 바이트 수나 분할 서로게
   이트 쌍)를 에러로 처리하지 않습니다. 이러한 바이트는 디코딩되지 않
   으며 디코딩된 바이트 수는 *consumed*에 저장됩니다.

PyObject *PyUnicode_AsUTF16String(PyObject *unicode)
    *Return value: New reference.** Part of the Stable ABI.*

   네이티브 바이트 순서로 UTF-16 인코딩을 사용하여 파이썬 바이트 문자
   열을 반환합니다. 문자열은 항상 BOM 마크로 시작합니다. 에러 처리는
   "strict"입니다. 코덱에서 예외가 발생하면 "NULL"을 반환합니다.


UTF-7 코덱
----------

다음은 UTF-7 코덱 API입니다:

PyObject *PyUnicode_DecodeUTF7(const char *str, Py_ssize_t size, const char *errors)
    *Return value: New reference.** Part of the 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)
    *Return value: New reference.** Part of the Stable ABI.*

   *consumed*가 "NULL"이면, "PyUnicode_DecodeUTF7()"처럼 동작합니다.
   *consumed*가 "NULL"이 아니면, 후행 불완전한 UTF-7 base-64 섹션은 에
   러로 처리되지 않습니다. 이러한 바이트는 디코딩되지 않으며 디코딩된
   바이트 수는 *consumed*에 저장됩니다.


유니코드 이스케이프 코덱
------------------------

다음은 "유니코드 이스케이프(Unicode Escape)" 코덱 API입니다:

PyObject *PyUnicode_DecodeUnicodeEscape(const char *str, Py_ssize_t size, const char *errors)
    *Return value: New reference.** Part of the 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)
    *Return value: New reference.** Part of the Stable ABI.*

   유니코드 이스케이프를 사용하여 유니코드 객체를 인코딩하고 결과를
   bytes 객체로 반환합니다. 에러 처리는 "strict"입니다. 코덱에서 예외
   가 발생하면 "NULL"을 반환합니다.


원시 유니코드 이스케이프 코덱
-----------------------------

다음은 "원시 유니코드 이스케이프(Raw Unicode Escape)" 코덱 API입니다:

PyObject *PyUnicode_DecodeRawUnicodeEscape(const char *str, Py_ssize_t size, const char *errors)
    *Return value: New reference.** Part of the 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)
    *Return value: New reference.** Part of the Stable ABI.*

   원시 유니코드 이스케이프를 사용하여 유니코드 객체를 인코딩하고 결과
   를 bytes 객체로 반환합니다. 에러 처리는 "strict"입니다. 코덱에서 예
   외가 발생하면 "NULL"을 반환합니다.


Latin-1 코덱
------------

다음은 Latin-1 코덱 API입니다: Latin-1은 처음 256개의 유니코드 서수에
해당하며 인코딩 중에 코덱에서 이들만 허용됩니다.

PyObject *PyUnicode_DecodeLatin1(const char *str, Py_ssize_t size, const char *errors)
    *Return value: New reference.** Part of the Stable ABI.*

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

PyObject *PyUnicode_AsLatin1String(PyObject *unicode)
    *Return value: New reference.** Part of the Stable ABI.*

   Latin-1을 사용하여 유니코드 객체를 인코딩하고 결과를 파이썬 bytes
   객체로 반환합니다. 에러 처리는 "strict"입니다. 코덱에서 예외가 발생
   하면 "NULL"을 반환합니다.


ASCII 코덱
----------

다음은 ASCII 코덱 API입니다. 7비트 ASCII 데이터만 허용됩니다. 다른 모
든 코드는 에러를 생성합니다.

PyObject *PyUnicode_DecodeASCII(const char *str, Py_ssize_t size, const char *errors)
    *Return value: New reference.** Part of the 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)
    *Return value: New reference.** Part of the Stable ABI.*

   ASCII를 사용하여 유니코드 객체를 인코딩하고 결과를 파이썬 bytes 객
   체로 반환합니다. 에러 처리는 "strict"입니다. 코덱에서 예외가 발생하
   면 "NULL"을 반환합니다.


문자 맵 코덱
------------

This codec is special in that it can be used to implement many
different codecs (and this is in fact what was done to obtain most of
the standard codecs included in the "encodings" package). The codec
uses mappings to encode and decode characters.  The mapping objects
provided must support the "__getitem__()" mapping interface;
dictionaries and sequences work well.

다음은 매핑 코덱 API입니다:

PyObject *PyUnicode_DecodeCharmap(const char *str, Py_ssize_t length, PyObject *mapping, const char *errors)
    *Return value: New reference.** Part of the Stable ABI.*

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

   *mapping*이 "NULL"이면, Latin-1 디코딩이 적용됩니다. 그렇지 않으면
   *mapping*은 바이트 서수(0에서 255 사이의 정수)를 유니코드 문자열,
   정수(유니코드 서수로 해석됩니다) 또는 "None"으로 매핑해야합니다. 매
   핑되지 않은 데이터 바이트("None", "0xFFFE" 또는 "'\ufffe'"로 매핑되
   는 것뿐만 아니라, "LookupError"를 유발하는 것)은 정의되지 않은 매핑
   으로 처리되어 에러를 발생시킵니다.

PyObject *PyUnicode_AsCharmapString(PyObject *unicode, PyObject *mapping)
    *Return value: New reference.** Part of the Stable ABI.*

   주어진 *mapping* 객체를 사용하여 유니코드 객체를 인코딩하고 결과를
   bytes 객체로 반환합니다. 에러 처리는 "strict"입니다. 코덱에서 예외
   가 발생하면 "NULL"을 반환합니다.

   *mapping* 객체는 유니코드 서수 정수를 bytes 객체, 0에서 255 사이의
   정수 또는 "None"으로 매핑해야 합니다. "None"에 매핑되는 것뿐만 아니
   라 매핑되지 않은 문자 서수("LookupError"를 유발하는 것)는 "정의되지
   않은 매핑"으로 처리되어 에러가 발생합니다.

다음 코덱 API는 유니코드를 유니코드로 매핑한다는 점에서 특별합니다.

PyObject *PyUnicode_Translate(PyObject *unicode, PyObject *table, const char *errors)
    *Return value: New reference.** Part of the Stable ABI.*

   문자 매핑 테이블을 적용하여 문자열을 변환하고 결과 유니코드 객체를
   반환합니다. 코덱에서 예외가 발생하면 "NULL"을 반환합니다.

   매핑 테이블은 유니코드 서수 정수를 유니코드 서수 정수나 "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*는 코덱에서의 일반적인 의미입니다. 기본 에러 처리를 사용함
   을 나타내는 "NULL"일 수 있습니다.


윈도우 용 MBCS 코덱
-------------------

다음은 MBCS 코덱 API입니다. 현재 윈도우에서만 사용할 수 있으며 Win32
MBCS 변환기를 사용하여 변환을 구현합니다. MBCS(또는 DBCS)는 단지 하나
가 아니라 인코딩 클래스임에 유의하십시오. 대상 인코딩은 코덱을 실행하
는 기계의 사용자 설정에 의해 정의됩니다.

PyObject *PyUnicode_DecodeMBCS(const char *str, Py_ssize_t size, const char *errors)
    *Return value: New reference.** Part of the Stable ABI on Windows
   since version 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)
    *Return value: New reference.** Part of the Stable ABI on Windows
   since version 3.7.*

   *consumed*가 "NULL"이면, "PyUnicode_DecodeMBCS()"처럼 동작합니다.
   *consumed*가 "NULL"이 아니면, "PyUnicode_DecodeMBCSStateful()" 은
   후행 선행(lead) 바이트를 디코딩하지 않고 디코딩된 바이트 수가
   *consumed*에 저장됩니다.

PyObject *PyUnicode_DecodeCodePageStateful(int code_page, const char *str, Py_ssize_t size, const char *errors, Py_ssize_t *consumed)
    *Return value: New reference.** Part of the Stable ABI on Windows
   since version 3.7.*

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

PyObject *PyUnicode_AsMBCSString(PyObject *unicode)
    *Return value: New reference.** Part of the Stable ABI on Windows
   since version 3.7.*

   MBCS를 사용하여 유니코드 객체를 인코딩하고 결과를 파이썬 bytes 객체
   로 반환합니다. 에러 처리는 "strict"입니다. 코덱에서 예외가 발생하면
   "NULL"을 반환합니다.

PyObject *PyUnicode_EncodeCodePage(int code_page, PyObject *unicode, const char *errors)
    *Return value: New reference.** Part of the Stable ABI on Windows
   since version 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.


메서드와 슬롯
-------------


메서드와 슬롯 함수
==================

다음 API는 입력의 유니코드 객체와 문자열을 (설명에서 문자열이라고 하겠
습니다) 처리할 수 있으며 적절하게 유니코드 객체나 정수를 반환합니다.

예외가 발생하면 모두 "NULL"이나 "-1"을 반환합니다.

PyObject *PyUnicode_Concat(PyObject *left, PyObject *right)
    *Return value: New reference.** Part of the Stable ABI.*

   두 문자열을 이어붙여 하나의 새로운 유니코드 문자열을 제공합니다.

PyObject *PyUnicode_Split(PyObject *unicode, PyObject *sep, Py_ssize_t maxsplit)
    *Return value: New reference.** Part of the Stable ABI.*

   문자열을 분할하여 유니코드 문자열 리스트를 제공합니다. *sep*이
   "NULL"이면, 모든 공백 부분 문자열에서 분할이 수행됩니다. 그렇지 않
   으면, 주어진 구분자에서 분할이 일어납니다. 최대 *maxsplit* 분할이
   수행됩니다. 음수이면, 제한이 설정되지 않습니다. 구분자는 결과 리스
   트에 포함되지 않습니다.

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

   Equivalent to "str.split()".

PyObject *PyUnicode_RSplit(PyObject *unicode, PyObject *sep, Py_ssize_t maxsplit)
    *Return value: New reference.** Part of the 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)
    *Return value: New reference.** Part of the 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)
    *Return value: New reference.** Part of the 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)
    *Return value: New reference.** Part of the 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)
    *Return value: New reference.** Part of the Stable ABI.*

   주어진 *separator*를 사용하여 문자열 시퀀스를 연결하고 결과 유니코
   드 문자열을 반환합니다.

Py_ssize_t PyUnicode_Tailmatch(PyObject *unicode, PyObject *substr, Py_ssize_t start, Py_ssize_t end, int direction)
    * Part of the 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)
    * Part of the Stable ABI.*

   Return the first position of *substr* in "unicode[start:end]" using
   the given *direction* (*direction* == "1" means to do a forward
   search, *direction* == "-1" a backward search).  The return value
   is the index of the first match; a value of "-1" indicates that no
   match was found, and "-2" indicates that an error occurred and an
   exception has been set.

Py_ssize_t PyUnicode_FindChar(PyObject *unicode, Py_UCS4 ch, Py_ssize_t start, Py_ssize_t end, int direction)
    * Part of the Stable ABI since version 3.7.*

   Return the first position of the character *ch* in
   "unicode[start:end]" using the given *direction* (*direction* ==
   "1" means to do a forward search, *direction* == "-1" a backward
   search).  The return value is the index of the first match; a value
   of "-1" indicates that no match was found, and "-2" indicates that
   an error occurred and an exception has been set.

   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)
    * Part of the Stable ABI.*

   Return the number of non-overlapping occurrences of *substr* in
   "unicode[start:end]".  Return "-1" if an error occurred.

PyObject *PyUnicode_Replace(PyObject *unicode, PyObject *substr, PyObject *replstr, Py_ssize_t maxcount)
    *Return value: New reference.** Part of the Stable ABI.*

   Replace at most *maxcount* occurrences of *substr* in *unicode*
   with *replstr* and return the resulting Unicode object. *maxcount*
   == "-1" means replace all occurrences.

int PyUnicode_Compare(PyObject *left, PyObject *right)
    * Part of the Stable ABI.*

   두 문자열을 비교하고 각각 작음, 같음, 큼에 대해 "-1", "0", "1"을 반
   환합니다.

   이 함수는 실패 시 "-1"을 반환하므로, 에러를 확인하기 위해
   "PyErr_Occurred()"를 호출해야 합니다.

int PyUnicode_EqualToUTF8AndSize(PyObject *unicode, const char *string, Py_ssize_t size)
    * Part of the Stable ABI since version 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)
    * Part of the Stable ABI since version 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)
    * Part of the Stable ABI.*

   Compare a Unicode object, *unicode*, with *string* and return "-1",
   "0", "1" for less than, equal, and greater than, respectively. It
   is best to pass only ASCII-encoded strings, but the function
   interprets the input string as ISO-8859-1 if it contains non-ASCII
   characters.

   이 함수는 예외를 발생시키지 않습니다.

PyObject *PyUnicode_RichCompare(PyObject *left, PyObject *right, int op)
    *Return value: New reference.** Part of the Stable ABI.*

   두 유니코드 문자열을 풍부한 비교(rich comparison) 하고 다음 중 하나
   를 반환합니다:

   * 예외가 발생하면 "NULL"

   * "Py_True" or "Py_False" for successful comparisons

   * "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)
    *Return value: New reference.** Part of the Stable ABI.*

   *format*과 *args*에서 새 문자열 객체를 반환합니다; 이것은 "format %
   args"와 유사합니다.

int PyUnicode_Contains(PyObject *unicode, PyObject *substr)
    * Part of the Stable ABI.*

   Check whether *substr* is contained in *unicode* and return true or
   false accordingly.

   *substr* has to coerce to a one element Unicode string. "-1" is
   returned if there was an error.

void PyUnicode_InternInPlace(PyObject **p_unicode)
    * Part of the 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)
    *Return value: New reference.** Part of the 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.

   **CPython 구현 상세:** Strings interned this way are made
   *immortal*.
