import Object import t, c # --- Unicode Type ------------------------------------------------------- # ASCII-only strings created through PyUnicode_New use the PyASCIIObject # structure. state.ascii and state.compact are set, and the data # immediately follow the structure. utf8_length can be found # in the length field; the utf8 pointer is equal to the data pointer. */ class PyASCIIObject: ob_base: Object.PyObject length: Object.Py_ssize_t # Number of code points in the string hash: Object.Py_hash_t # Hash value; -1 if not set class state: interned: t.CUnsignedInt | t.Bit[2] kind: t.CUnsignedInt | t.Bit[3] compact: t.CUnsignedInt | t.Bit[1] ascii: t.CUnsignedInt | t.Bit[1] _: t.CUnsignedInt | t.Bit[25] class PyCompactUnicodeObject: _base: PyASCIIObject utf8_length: Object.Py_ssize_t # Number of bytes in utf8, excluding the * terminating \0. utf8: str # UTF-8 representation (null-terminated) Py_UCS4: t.CTypedef = t.CUInt32T Py_UCS2: t.CTypedef = t.CUInt16T Py_UCS1: t.CTypedef = t.CUInt8T # Object format for Unicode subclasses. class PyUnicodeObject: _base: PyCompactUnicodeObject class data(t.CUnion): any: t.CVoid | t.CPtr latin1: Py_UCS1 | t.CPtr ucs2: Py_UCS2 | t.CPtr ucs4: Py_UCS4 | t.CPtr # Canonical, smallest-form Unicode buffer