File indexing completed on 2025-11-19 09:50:51
0001 #ifndef Py_INTERNAL_UNICODEOBJECT_H
0002 #define Py_INTERNAL_UNICODEOBJECT_H
0003 #ifdef __cplusplus
0004 extern "C" {
0005 #endif
0006
0007 #ifndef Py_BUILD_CORE
0008 # error "this header requires Py_BUILD_CORE define"
0009 #endif
0010
0011 #include "pycore_lock.h" // PyMutex
0012 #include "pycore_fileutils.h" // _Py_error_handler
0013 #include "pycore_identifier.h" // _Py_Identifier
0014 #include "pycore_ucnhash.h" // _PyUnicode_Name_CAPI
0015 #include "pycore_global_objects.h" // _Py_SINGLETON
0016
0017
0018
0019 extern int _PyUnicode_IsXidStart(Py_UCS4 ch);
0020 extern int _PyUnicode_IsXidContinue(Py_UCS4 ch);
0021 extern int _PyUnicode_ToLowerFull(Py_UCS4 ch, Py_UCS4 *res);
0022 extern int _PyUnicode_ToTitleFull(Py_UCS4 ch, Py_UCS4 *res);
0023 extern int _PyUnicode_ToUpperFull(Py_UCS4 ch, Py_UCS4 *res);
0024 extern int _PyUnicode_ToFoldedFull(Py_UCS4 ch, Py_UCS4 *res);
0025 extern int _PyUnicode_IsCaseIgnorable(Py_UCS4 ch);
0026 extern int _PyUnicode_IsCased(Py_UCS4 ch);
0027
0028
0029
0030
0031 PyAPI_FUNC(int) _PyUnicode_CheckConsistency(
0032 PyObject *op,
0033 int check_content);
0034
0035 PyAPI_FUNC(void) _PyUnicode_ExactDealloc(PyObject *op);
0036 extern Py_ssize_t _PyUnicode_InternedSize(void);
0037 extern Py_ssize_t _PyUnicode_InternedSize_Immortal(void);
0038
0039
0040
0041 PyAPI_FUNC(PyObject*) _PyUnicode_Copy(
0042 PyObject *unicode);
0043
0044
0045
0046 extern void _PyUnicode_FastFill(
0047 PyObject *unicode,
0048 Py_ssize_t start,
0049 Py_ssize_t length,
0050 Py_UCS4 fill_char
0051 );
0052
0053
0054
0055
0056 extern void _PyUnicode_FastCopyCharacters(
0057 PyObject *to,
0058 Py_ssize_t to_start,
0059 PyObject *from,
0060 Py_ssize_t from_start,
0061 Py_ssize_t how_many
0062 );
0063
0064
0065
0066 extern PyObject* _PyUnicode_FromASCII(
0067 const char *buffer,
0068 Py_ssize_t size);
0069
0070
0071
0072 extern Py_UCS4 _PyUnicode_FindMaxChar (
0073 PyObject *unicode,
0074 Py_ssize_t start,
0075 Py_ssize_t end);
0076
0077
0078
0079
0080
0081 extern int _PyUnicode_FormatAdvancedWriter(
0082 _PyUnicodeWriter *writer,
0083 PyObject *obj,
0084 PyObject *format_spec,
0085 Py_ssize_t start,
0086 Py_ssize_t end);
0087
0088
0089
0090 extern PyObject* _PyUnicode_EncodeUTF7(
0091 PyObject *unicode,
0092 int base64SetO,
0093 int base64WhiteSpace,
0094 const char *errors);
0095
0096
0097
0098
0099 PyAPI_FUNC(PyObject*) _PyUnicode_AsUTF8String(
0100 PyObject *unicode,
0101 const char *errors);
0102
0103
0104
0105
0106 PyAPI_FUNC(PyObject*) _PyUnicode_EncodeUTF32(
0107 PyObject *object,
0108 const char *errors,
0109 int byteorder);
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128 PyAPI_FUNC(PyObject*) _PyUnicode_EncodeUTF16(
0129 PyObject* unicode,
0130 const char *errors,
0131 int byteorder);
0132
0133
0134
0135
0136 extern PyObject* _PyUnicode_DecodeUnicodeEscapeStateful(
0137 const char *string,
0138 Py_ssize_t length,
0139 const char *errors,
0140 Py_ssize_t *consumed);
0141
0142
0143
0144
0145 PyAPI_FUNC(PyObject*) _PyUnicode_DecodeUnicodeEscapeInternal2(
0146 const char *string,
0147 Py_ssize_t length,
0148 const char *errors,
0149 Py_ssize_t *consumed,
0150 int *first_invalid_escape_char,
0151
0152
0153 const char **first_invalid_escape_ptr);
0154
0155
0156
0157
0158 PyAPI_FUNC(PyObject*) _PyUnicode_DecodeUnicodeEscapeInternal(
0159 const char *string,
0160 Py_ssize_t length,
0161 const char *errors,
0162 Py_ssize_t *consumed,
0163 const char **first_invalid_escape);
0164
0165
0166
0167
0168
0169
0170 extern PyObject* _PyUnicode_DecodeRawUnicodeEscapeStateful(
0171 const char *string,
0172 Py_ssize_t length,
0173 const char *errors,
0174 Py_ssize_t *consumed);
0175
0176
0177
0178 extern PyObject* _PyUnicode_AsLatin1String(
0179 PyObject* unicode,
0180 const char* errors);
0181
0182
0183
0184 extern PyObject* _PyUnicode_AsASCIIString(
0185 PyObject* unicode,
0186 const char* errors);
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200 extern PyObject* _PyUnicode_EncodeCharmap(
0201 PyObject *unicode,
0202 PyObject *mapping,
0203 const char *errors);
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215 PyAPI_FUNC(PyObject*) _PyUnicode_TransformDecimalAndSpaceToASCII(
0216 PyObject *unicode);
0217
0218
0219
0220 PyAPI_FUNC(PyObject*) _PyUnicode_JoinArray(
0221 PyObject *separator,
0222 PyObject *const *items,
0223 Py_ssize_t seqlen
0224 );
0225
0226
0227
0228
0229 extern int _PyUnicode_EqualToASCIIId(
0230 PyObject *left,
0231 _Py_Identifier *right
0232 );
0233
0234
0235
0236
0237
0238 PyAPI_FUNC(int) _PyUnicode_EqualToASCIIString(
0239 PyObject *left,
0240 const char *right
0241 );
0242
0243
0244 extern PyObject* _PyUnicode_XStrip(
0245 PyObject *self,
0246 int striptype,
0247 PyObject *sepobj
0248 );
0249
0250
0251
0252
0253
0254 extern Py_ssize_t _PyUnicode_InsertThousandsGrouping(
0255 _PyUnicodeWriter *writer,
0256 Py_ssize_t n_buffer,
0257 PyObject *digits,
0258 Py_ssize_t d_pos,
0259 Py_ssize_t n_digits,
0260 Py_ssize_t min_width,
0261 const char *grouping,
0262 PyObject *thousands_sep,
0263 Py_UCS4 *maxchar);
0264
0265
0266
0267 extern PyObject* _PyUnicode_FormatLong(PyObject *, int, int, int);
0268
0269
0270
0271 extern int _PyUnicode_EQ(PyObject *, PyObject *);
0272
0273
0274
0275 PyAPI_FUNC(int) _PyUnicode_Equal(PyObject *, PyObject *);
0276
0277 extern int _PyUnicode_WideCharString_Converter(PyObject *, void *);
0278 extern int _PyUnicode_WideCharString_Opt_Converter(PyObject *, void *);
0279
0280
0281 PyAPI_FUNC(Py_ssize_t) _PyUnicode_ScanIdentifier(PyObject *);
0282
0283
0284
0285 extern void _PyUnicode_InitState(PyInterpreterState *);
0286 extern PyStatus _PyUnicode_InitGlobalObjects(PyInterpreterState *);
0287 extern PyStatus _PyUnicode_InitTypes(PyInterpreterState *);
0288 extern void _PyUnicode_Fini(PyInterpreterState *);
0289 extern void _PyUnicode_FiniTypes(PyInterpreterState *);
0290
0291 extern PyTypeObject _PyUnicodeASCIIIter_Type;
0292
0293
0294
0295
0296
0297
0298 PyAPI_FUNC(void) _PyUnicode_InternMortal(PyInterpreterState *interp, PyObject **);
0299 PyAPI_FUNC(void) _PyUnicode_InternImmortal(PyInterpreterState *interp, PyObject **);
0300
0301 PyAPI_FUNC(void) _PyUnicode_InternInPlace(PyInterpreterState *interp, PyObject **p);
0302
0303 extern void _PyUnicode_InternStatic(PyInterpreterState *interp, PyObject **);
0304
0305
0306
0307 struct _Py_unicode_runtime_ids {
0308 PyMutex mutex;
0309
0310
0311 Py_ssize_t next_index;
0312 };
0313
0314 struct _Py_unicode_runtime_state {
0315 struct _Py_unicode_runtime_ids ids;
0316 };
0317
0318
0319
0320 struct _Py_unicode_fs_codec {
0321 char *encoding;
0322 int utf8;
0323 char *errors;
0324 _Py_error_handler error_handler;
0325 };
0326
0327 struct _Py_unicode_ids {
0328 Py_ssize_t size;
0329 PyObject **array;
0330 };
0331
0332 struct _Py_unicode_state {
0333 struct _Py_unicode_fs_codec fs_codec;
0334
0335 _PyUnicode_Name_CAPI *ucnhash_capi;
0336
0337
0338 struct _Py_unicode_ids ids;
0339 };
0340
0341 extern void _PyUnicode_ClearInterned(PyInterpreterState *interp);
0342
0343
0344
0345 PyAPI_FUNC(const char *) _PyUnicode_AsUTF8NoNUL(PyObject *);
0346
0347
0348 #ifdef __cplusplus
0349 }
0350 #endif
0351 #endif