File indexing completed on 2025-01-18 10:06:42
0001 #ifndef Py_CPYTHON_UNICODEOBJECT_H
0002 # error "this header file must not be included directly"
0003 #endif
0004
0005
0006
0007
0008
0009 #define PY_UNICODE_TYPE wchar_t
0010 typedef wchar_t Py_UNICODE;
0011
0012
0013
0014
0015 static inline int Py_UNICODE_IS_SURROGATE(Py_UCS4 ch) {
0016 return (0xD800 <= ch && ch <= 0xDFFF);
0017 }
0018 static inline int Py_UNICODE_IS_HIGH_SURROGATE(Py_UCS4 ch) {
0019 return (0xD800 <= ch && ch <= 0xDBFF);
0020 }
0021 static inline int Py_UNICODE_IS_LOW_SURROGATE(Py_UCS4 ch) {
0022 return (0xDC00 <= ch && ch <= 0xDFFF);
0023 }
0024
0025
0026 static inline Py_UCS4 Py_UNICODE_JOIN_SURROGATES(Py_UCS4 high, Py_UCS4 low) {
0027 assert(Py_UNICODE_IS_HIGH_SURROGATE(high));
0028 assert(Py_UNICODE_IS_LOW_SURROGATE(low));
0029 return 0x10000 + (((high & 0x03FF) << 10) | (low & 0x03FF));
0030 }
0031
0032
0033
0034 static inline Py_UCS4 Py_UNICODE_HIGH_SURROGATE(Py_UCS4 ch) {
0035 assert(0x10000 <= ch && ch <= 0x10ffff);
0036 return (0xD800 - (0x10000 >> 10) + (ch >> 10));
0037 }
0038
0039
0040
0041 static inline Py_UCS4 Py_UNICODE_LOW_SURROGATE(Py_UCS4 ch) {
0042 assert(0x10000 <= ch && ch <= 0x10ffff);
0043 return (0xDC00 + (ch & 0x3FF));
0044 }
0045
0046
0047
0048
0049
0050
0051
0052 typedef struct {
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097 PyObject_HEAD
0098 Py_ssize_t length;
0099 Py_hash_t hash;
0100 struct {
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110 unsigned int interned:2;
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133 unsigned int kind:3;
0134
0135
0136
0137
0138 unsigned int compact:1;
0139
0140
0141
0142 unsigned int ascii:1;
0143
0144 unsigned int statically_allocated:1;
0145
0146
0147 unsigned int :24;
0148 } state;
0149 } PyASCIIObject;
0150
0151
0152
0153
0154 typedef struct {
0155 PyASCIIObject _base;
0156 Py_ssize_t utf8_length;
0157
0158 char *utf8;
0159 } PyCompactUnicodeObject;
0160
0161
0162 typedef struct {
0163 PyCompactUnicodeObject _base;
0164 union {
0165 void *any;
0166 Py_UCS1 *latin1;
0167 Py_UCS2 *ucs2;
0168 Py_UCS4 *ucs4;
0169 } data;
0170 } PyUnicodeObject;
0171
0172 PyAPI_FUNC(int) _PyUnicode_CheckConsistency(
0173 PyObject *op,
0174 int check_content);
0175
0176
0177 #define _PyASCIIObject_CAST(op) \
0178 (assert(PyUnicode_Check(op)), \
0179 _Py_CAST(PyASCIIObject*, (op)))
0180 #define _PyCompactUnicodeObject_CAST(op) \
0181 (assert(PyUnicode_Check(op)), \
0182 _Py_CAST(PyCompactUnicodeObject*, (op)))
0183 #define _PyUnicodeObject_CAST(op) \
0184 (assert(PyUnicode_Check(op)), \
0185 _Py_CAST(PyUnicodeObject*, (op)))
0186
0187
0188
0189
0190
0191
0192
0193 #define SSTATE_NOT_INTERNED 0
0194 #define SSTATE_INTERNED_MORTAL 1
0195 #define SSTATE_INTERNED_IMMORTAL 2
0196 #define SSTATE_INTERNED_IMMORTAL_STATIC 3
0197
0198
0199 static inline unsigned int PyUnicode_CHECK_INTERNED(PyObject *op) {
0200 return _PyASCIIObject_CAST(op)->state.interned;
0201 }
0202 #define PyUnicode_CHECK_INTERNED(op) PyUnicode_CHECK_INTERNED(_PyObject_CAST(op))
0203
0204
0205 static inline unsigned int PyUnicode_IS_READY(PyObject* Py_UNUSED(op)) {
0206 return 1;
0207 }
0208 #define PyUnicode_IS_READY(op) PyUnicode_IS_READY(_PyObject_CAST(op))
0209
0210
0211
0212
0213 static inline unsigned int PyUnicode_IS_ASCII(PyObject *op) {
0214 return _PyASCIIObject_CAST(op)->state.ascii;
0215 }
0216 #define PyUnicode_IS_ASCII(op) PyUnicode_IS_ASCII(_PyObject_CAST(op))
0217
0218
0219
0220 static inline unsigned int PyUnicode_IS_COMPACT(PyObject *op) {
0221 return _PyASCIIObject_CAST(op)->state.compact;
0222 }
0223 #define PyUnicode_IS_COMPACT(op) PyUnicode_IS_COMPACT(_PyObject_CAST(op))
0224
0225
0226
0227 static inline int PyUnicode_IS_COMPACT_ASCII(PyObject *op) {
0228 return (_PyASCIIObject_CAST(op)->state.ascii && PyUnicode_IS_COMPACT(op));
0229 }
0230 #define PyUnicode_IS_COMPACT_ASCII(op) PyUnicode_IS_COMPACT_ASCII(_PyObject_CAST(op))
0231
0232 enum PyUnicode_Kind {
0233
0234 PyUnicode_1BYTE_KIND = 1,
0235 PyUnicode_2BYTE_KIND = 2,
0236 PyUnicode_4BYTE_KIND = 4
0237 };
0238
0239
0240
0241
0242
0243
0244
0245 #define PyUnicode_KIND(op) _Py_RVALUE(_PyASCIIObject_CAST(op)->state.kind)
0246
0247
0248 static inline void* _PyUnicode_COMPACT_DATA(PyObject *op) {
0249 if (PyUnicode_IS_ASCII(op)) {
0250 return _Py_STATIC_CAST(void*, (_PyASCIIObject_CAST(op) + 1));
0251 }
0252 return _Py_STATIC_CAST(void*, (_PyCompactUnicodeObject_CAST(op) + 1));
0253 }
0254
0255 static inline void* _PyUnicode_NONCOMPACT_DATA(PyObject *op) {
0256 void *data;
0257 assert(!PyUnicode_IS_COMPACT(op));
0258 data = _PyUnicodeObject_CAST(op)->data.any;
0259 assert(data != NULL);
0260 return data;
0261 }
0262
0263 static inline void* PyUnicode_DATA(PyObject *op) {
0264 if (PyUnicode_IS_COMPACT(op)) {
0265 return _PyUnicode_COMPACT_DATA(op);
0266 }
0267 return _PyUnicode_NONCOMPACT_DATA(op);
0268 }
0269 #define PyUnicode_DATA(op) PyUnicode_DATA(_PyObject_CAST(op))
0270
0271
0272
0273
0274
0275
0276 #define PyUnicode_1BYTE_DATA(op) _Py_STATIC_CAST(Py_UCS1*, PyUnicode_DATA(op))
0277 #define PyUnicode_2BYTE_DATA(op) _Py_STATIC_CAST(Py_UCS2*, PyUnicode_DATA(op))
0278 #define PyUnicode_4BYTE_DATA(op) _Py_STATIC_CAST(Py_UCS4*, PyUnicode_DATA(op))
0279
0280
0281 static inline Py_ssize_t PyUnicode_GET_LENGTH(PyObject *op) {
0282 return _PyASCIIObject_CAST(op)->length;
0283 }
0284 #define PyUnicode_GET_LENGTH(op) PyUnicode_GET_LENGTH(_PyObject_CAST(op))
0285
0286
0287
0288
0289
0290
0291 static inline void PyUnicode_WRITE(int kind, void *data,
0292 Py_ssize_t index, Py_UCS4 value)
0293 {
0294 assert(index >= 0);
0295 if (kind == PyUnicode_1BYTE_KIND) {
0296 assert(value <= 0xffU);
0297 _Py_STATIC_CAST(Py_UCS1*, data)[index] = _Py_STATIC_CAST(Py_UCS1, value);
0298 }
0299 else if (kind == PyUnicode_2BYTE_KIND) {
0300 assert(value <= 0xffffU);
0301 _Py_STATIC_CAST(Py_UCS2*, data)[index] = _Py_STATIC_CAST(Py_UCS2, value);
0302 }
0303 else {
0304 assert(kind == PyUnicode_4BYTE_KIND);
0305 assert(value <= 0x10ffffU);
0306 _Py_STATIC_CAST(Py_UCS4*, data)[index] = value;
0307 }
0308 }
0309 #define PyUnicode_WRITE(kind, data, index, value) \
0310 PyUnicode_WRITE(_Py_STATIC_CAST(int, kind), _Py_CAST(void*, data), \
0311 (index), _Py_STATIC_CAST(Py_UCS4, value))
0312
0313
0314
0315 static inline Py_UCS4 PyUnicode_READ(int kind,
0316 const void *data, Py_ssize_t index)
0317 {
0318 assert(index >= 0);
0319 if (kind == PyUnicode_1BYTE_KIND) {
0320 return _Py_STATIC_CAST(const Py_UCS1*, data)[index];
0321 }
0322 if (kind == PyUnicode_2BYTE_KIND) {
0323 return _Py_STATIC_CAST(const Py_UCS2*, data)[index];
0324 }
0325 assert(kind == PyUnicode_4BYTE_KIND);
0326 return _Py_STATIC_CAST(const Py_UCS4*, data)[index];
0327 }
0328 #define PyUnicode_READ(kind, data, index) \
0329 PyUnicode_READ(_Py_STATIC_CAST(int, kind), \
0330 _Py_STATIC_CAST(const void*, data), \
0331 (index))
0332
0333
0334
0335
0336
0337 static inline Py_UCS4 PyUnicode_READ_CHAR(PyObject *unicode, Py_ssize_t index)
0338 {
0339 int kind;
0340
0341 assert(index >= 0);
0342
0343 assert(index <= PyUnicode_GET_LENGTH(unicode));
0344
0345 kind = PyUnicode_KIND(unicode);
0346 if (kind == PyUnicode_1BYTE_KIND) {
0347 return PyUnicode_1BYTE_DATA(unicode)[index];
0348 }
0349 if (kind == PyUnicode_2BYTE_KIND) {
0350 return PyUnicode_2BYTE_DATA(unicode)[index];
0351 }
0352 assert(kind == PyUnicode_4BYTE_KIND);
0353 return PyUnicode_4BYTE_DATA(unicode)[index];
0354 }
0355 #define PyUnicode_READ_CHAR(unicode, index) \
0356 PyUnicode_READ_CHAR(_PyObject_CAST(unicode), (index))
0357
0358
0359
0360
0361 static inline Py_UCS4 PyUnicode_MAX_CHAR_VALUE(PyObject *op)
0362 {
0363 int kind;
0364
0365 if (PyUnicode_IS_ASCII(op)) {
0366 return 0x7fU;
0367 }
0368
0369 kind = PyUnicode_KIND(op);
0370 if (kind == PyUnicode_1BYTE_KIND) {
0371 return 0xffU;
0372 }
0373 if (kind == PyUnicode_2BYTE_KIND) {
0374 return 0xffffU;
0375 }
0376 assert(kind == PyUnicode_4BYTE_KIND);
0377 return 0x10ffffU;
0378 }
0379 #define PyUnicode_MAX_CHAR_VALUE(op) \
0380 PyUnicode_MAX_CHAR_VALUE(_PyObject_CAST(op))
0381
0382
0383
0384
0385
0386
0387
0388
0389 PyAPI_FUNC(PyObject*) PyUnicode_New(
0390 Py_ssize_t size,
0391 Py_UCS4 maxchar
0392 );
0393
0394
0395 static inline int PyUnicode_READY(PyObject* Py_UNUSED(op))
0396 {
0397 return 0;
0398 }
0399 #define PyUnicode_READY(op) PyUnicode_READY(_PyObject_CAST(op))
0400
0401
0402 PyAPI_FUNC(PyObject*) _PyUnicode_Copy(
0403 PyObject *unicode
0404 );
0405
0406
0407
0408
0409
0410
0411
0412
0413
0414
0415
0416
0417
0418
0419
0420
0421
0422
0423
0424 PyAPI_FUNC(Py_ssize_t) PyUnicode_CopyCharacters(
0425 PyObject *to,
0426 Py_ssize_t to_start,
0427 PyObject *from,
0428 Py_ssize_t from_start,
0429 Py_ssize_t how_many
0430 );
0431
0432
0433
0434
0435 PyAPI_FUNC(void) _PyUnicode_FastCopyCharacters(
0436 PyObject *to,
0437 Py_ssize_t to_start,
0438 PyObject *from,
0439 Py_ssize_t from_start,
0440 Py_ssize_t how_many
0441 );
0442
0443
0444
0445
0446
0447
0448
0449
0450
0451 PyAPI_FUNC(Py_ssize_t) PyUnicode_Fill(
0452 PyObject *unicode,
0453 Py_ssize_t start,
0454 Py_ssize_t length,
0455 Py_UCS4 fill_char
0456 );
0457
0458
0459
0460 PyAPI_FUNC(void) _PyUnicode_FastFill(
0461 PyObject *unicode,
0462 Py_ssize_t start,
0463 Py_ssize_t length,
0464 Py_UCS4 fill_char
0465 );
0466
0467
0468
0469 PyAPI_FUNC(PyObject*) PyUnicode_FromKindAndData(
0470 int kind,
0471 const void *buffer,
0472 Py_ssize_t size);
0473
0474
0475
0476 PyAPI_FUNC(PyObject*) _PyUnicode_FromASCII(
0477 const char *buffer,
0478 Py_ssize_t size);
0479
0480
0481
0482 PyAPI_FUNC(Py_UCS4) _PyUnicode_FindMaxChar (
0483 PyObject *unicode,
0484 Py_ssize_t start,
0485 Py_ssize_t end);
0486
0487
0488
0489 typedef struct {
0490 PyObject *buffer;
0491 void *data;
0492 int kind;
0493 Py_UCS4 maxchar;
0494 Py_ssize_t size;
0495 Py_ssize_t pos;
0496
0497
0498 Py_ssize_t min_length;
0499
0500
0501 Py_UCS4 min_char;
0502
0503
0504 unsigned char overallocate;
0505
0506
0507
0508 unsigned char readonly;
0509 } _PyUnicodeWriter ;
0510
0511
0512
0513
0514
0515
0516 PyAPI_FUNC(void)
0517 _PyUnicodeWriter_Init(_PyUnicodeWriter *writer);
0518
0519
0520
0521
0522
0523 #define _PyUnicodeWriter_Prepare(WRITER, LENGTH, MAXCHAR) \
0524 (((MAXCHAR) <= (WRITER)->maxchar \
0525 && (LENGTH) <= (WRITER)->size - (WRITER)->pos) \
0526 ? 0 \
0527 : (((LENGTH) == 0) \
0528 ? 0 \
0529 : _PyUnicodeWriter_PrepareInternal((WRITER), (LENGTH), (MAXCHAR))))
0530
0531
0532
0533 PyAPI_FUNC(int)
0534 _PyUnicodeWriter_PrepareInternal(_PyUnicodeWriter *writer,
0535 Py_ssize_t length, Py_UCS4 maxchar);
0536
0537
0538
0539
0540
0541
0542 #define _PyUnicodeWriter_PrepareKind(WRITER, KIND) \
0543 ((KIND) <= (WRITER)->kind \
0544 ? 0 \
0545 : _PyUnicodeWriter_PrepareKindInternal((WRITER), (KIND)))
0546
0547
0548
0549 PyAPI_FUNC(int)
0550 _PyUnicodeWriter_PrepareKindInternal(_PyUnicodeWriter *writer,
0551 int kind);
0552
0553
0554
0555 PyAPI_FUNC(int)
0556 _PyUnicodeWriter_WriteChar(_PyUnicodeWriter *writer,
0557 Py_UCS4 ch
0558 );
0559
0560
0561
0562 PyAPI_FUNC(int)
0563 _PyUnicodeWriter_WriteStr(_PyUnicodeWriter *writer,
0564 PyObject *str
0565 );
0566
0567
0568
0569 PyAPI_FUNC(int)
0570 _PyUnicodeWriter_WriteSubstring(_PyUnicodeWriter *writer,
0571 PyObject *str,
0572 Py_ssize_t start,
0573 Py_ssize_t end
0574 );
0575
0576
0577
0578 PyAPI_FUNC(int)
0579 _PyUnicodeWriter_WriteASCIIString(_PyUnicodeWriter *writer,
0580 const char *str,
0581 Py_ssize_t len
0582 );
0583
0584
0585
0586 PyAPI_FUNC(int)
0587 _PyUnicodeWriter_WriteLatin1String(_PyUnicodeWriter *writer,
0588 const char *str,
0589 Py_ssize_t len
0590 );
0591
0592
0593
0594
0595 PyAPI_FUNC(PyObject *)
0596 _PyUnicodeWriter_Finish(_PyUnicodeWriter *writer);
0597
0598
0599 PyAPI_FUNC(void)
0600 _PyUnicodeWriter_Dealloc(_PyUnicodeWriter *writer);
0601
0602
0603
0604
0605 PyAPI_FUNC(int) _PyUnicode_FormatAdvancedWriter(
0606 _PyUnicodeWriter *writer,
0607 PyObject *obj,
0608 PyObject *format_spec,
0609 Py_ssize_t start,
0610 Py_ssize_t end);
0611
0612
0613
0614
0615
0616
0617
0618
0619
0620
0621
0622
0623
0624
0625
0626
0627 PyAPI_FUNC(const char *) PyUnicode_AsUTF8(PyObject *unicode);
0628
0629 #define _PyUnicode_AsString PyUnicode_AsUTF8
0630
0631
0632
0633 PyAPI_FUNC(PyObject*) _PyUnicode_EncodeUTF7(
0634 PyObject *unicode,
0635 int base64SetO,
0636 int base64WhiteSpace,
0637 const char *errors
0638 );
0639
0640
0641
0642 PyAPI_FUNC(PyObject*) _PyUnicode_AsUTF8String(
0643 PyObject *unicode,
0644 const char *errors);
0645
0646
0647
0648 PyAPI_FUNC(PyObject*) _PyUnicode_EncodeUTF32(
0649 PyObject *object,
0650 const char *errors,
0651 int byteorder
0652 );
0653
0654
0655
0656
0657
0658
0659
0660
0661
0662
0663
0664
0665
0666
0667
0668
0669
0670 PyAPI_FUNC(PyObject*) _PyUnicode_EncodeUTF16(
0671 PyObject* unicode,
0672 const char *errors,
0673 int byteorder
0674 );
0675
0676
0677
0678
0679 PyAPI_FUNC(PyObject*) _PyUnicode_DecodeUnicodeEscapeStateful(
0680 const char *string,
0681 Py_ssize_t length,
0682 const char *errors,
0683 Py_ssize_t *consumed
0684 );
0685
0686
0687 PyAPI_FUNC(PyObject*) _PyUnicode_DecodeUnicodeEscapeInternal(
0688 const char *string,
0689 Py_ssize_t length,
0690 const char *errors,
0691 Py_ssize_t *consumed,
0692 const char **first_invalid_escape
0693
0694
0695 );
0696
0697
0698
0699
0700 PyAPI_FUNC(PyObject*) _PyUnicode_DecodeRawUnicodeEscapeStateful(
0701 const char *string,
0702 Py_ssize_t length,
0703 const char *errors,
0704 Py_ssize_t *consumed
0705 );
0706
0707
0708
0709 PyAPI_FUNC(PyObject*) _PyUnicode_AsLatin1String(
0710 PyObject* unicode,
0711 const char* errors);
0712
0713
0714
0715 PyAPI_FUNC(PyObject*) _PyUnicode_AsASCIIString(
0716 PyObject* unicode,
0717 const char* errors);
0718
0719
0720
0721
0722
0723
0724
0725
0726
0727
0728
0729
0730
0731 PyAPI_FUNC(PyObject*) _PyUnicode_EncodeCharmap(
0732 PyObject *unicode,
0733 PyObject *mapping,
0734 const char *errors
0735 );
0736
0737
0738
0739
0740
0741
0742
0743
0744
0745
0746 PyAPI_FUNC(PyObject*) _PyUnicode_TransformDecimalAndSpaceToASCII(
0747 PyObject *unicode
0748 );
0749
0750
0751
0752 PyAPI_FUNC(PyObject *) _PyUnicode_JoinArray(
0753 PyObject *separator,
0754 PyObject *const *items,
0755 Py_ssize_t seqlen
0756 );
0757
0758
0759
0760
0761 PyAPI_FUNC(int) _PyUnicode_EqualToASCIIId(
0762 PyObject *left,
0763 _Py_Identifier *right
0764 );
0765
0766
0767
0768
0769 PyAPI_FUNC(int) _PyUnicode_EqualToASCIIString(
0770 PyObject *left,
0771 const char *right
0772 );
0773
0774
0775 PyAPI_FUNC(PyObject *) _PyUnicode_XStrip(
0776 PyObject *self,
0777 int striptype,
0778 PyObject *sepobj
0779 );
0780
0781
0782
0783
0784 PyAPI_FUNC(Py_ssize_t) _PyUnicode_InsertThousandsGrouping(
0785 _PyUnicodeWriter *writer,
0786 Py_ssize_t n_buffer,
0787 PyObject *digits,
0788 Py_ssize_t d_pos,
0789 Py_ssize_t n_digits,
0790 Py_ssize_t min_width,
0791 const char *grouping,
0792 PyObject *thousands_sep,
0793 Py_UCS4 *maxchar);
0794
0795
0796
0797
0798
0799
0800
0801
0802
0803
0804 PyAPI_FUNC(int) _PyUnicode_IsLowercase(
0805 Py_UCS4 ch
0806 );
0807
0808 PyAPI_FUNC(int) _PyUnicode_IsUppercase(
0809 Py_UCS4 ch
0810 );
0811
0812 PyAPI_FUNC(int) _PyUnicode_IsTitlecase(
0813 Py_UCS4 ch
0814 );
0815
0816 PyAPI_FUNC(int) _PyUnicode_IsXidStart(
0817 Py_UCS4 ch
0818 );
0819
0820 PyAPI_FUNC(int) _PyUnicode_IsXidContinue(
0821 Py_UCS4 ch
0822 );
0823
0824 PyAPI_FUNC(int) _PyUnicode_IsWhitespace(
0825 const Py_UCS4 ch
0826 );
0827
0828 PyAPI_FUNC(int) _PyUnicode_IsLinebreak(
0829 const Py_UCS4 ch
0830 );
0831
0832 PyAPI_FUNC(Py_UCS4) _PyUnicode_ToLowercase(
0833 Py_UCS4 ch
0834 );
0835
0836 PyAPI_FUNC(Py_UCS4) _PyUnicode_ToUppercase(
0837 Py_UCS4 ch
0838 );
0839
0840 Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UCS4) _PyUnicode_ToTitlecase(
0841 Py_UCS4 ch
0842 );
0843
0844 PyAPI_FUNC(int) _PyUnicode_ToLowerFull(
0845 Py_UCS4 ch,
0846 Py_UCS4 *res
0847 );
0848
0849 PyAPI_FUNC(int) _PyUnicode_ToTitleFull(
0850 Py_UCS4 ch,
0851 Py_UCS4 *res
0852 );
0853
0854 PyAPI_FUNC(int) _PyUnicode_ToUpperFull(
0855 Py_UCS4 ch,
0856 Py_UCS4 *res
0857 );
0858
0859 PyAPI_FUNC(int) _PyUnicode_ToFoldedFull(
0860 Py_UCS4 ch,
0861 Py_UCS4 *res
0862 );
0863
0864 PyAPI_FUNC(int) _PyUnicode_IsCaseIgnorable(
0865 Py_UCS4 ch
0866 );
0867
0868 PyAPI_FUNC(int) _PyUnicode_IsCased(
0869 Py_UCS4 ch
0870 );
0871
0872 PyAPI_FUNC(int) _PyUnicode_ToDecimalDigit(
0873 Py_UCS4 ch
0874 );
0875
0876 PyAPI_FUNC(int) _PyUnicode_ToDigit(
0877 Py_UCS4 ch
0878 );
0879
0880 PyAPI_FUNC(double) _PyUnicode_ToNumeric(
0881 Py_UCS4 ch
0882 );
0883
0884 PyAPI_FUNC(int) _PyUnicode_IsDecimalDigit(
0885 Py_UCS4 ch
0886 );
0887
0888 PyAPI_FUNC(int) _PyUnicode_IsDigit(
0889 Py_UCS4 ch
0890 );
0891
0892 PyAPI_FUNC(int) _PyUnicode_IsNumeric(
0893 Py_UCS4 ch
0894 );
0895
0896 PyAPI_FUNC(int) _PyUnicode_IsPrintable(
0897 Py_UCS4 ch
0898 );
0899
0900 PyAPI_FUNC(int) _PyUnicode_IsAlpha(
0901 Py_UCS4 ch
0902 );
0903
0904
0905 PyAPI_DATA(const unsigned char) _Py_ascii_whitespace[];
0906
0907
0908
0909
0910
0911 static inline int Py_UNICODE_ISSPACE(Py_UCS4 ch) {
0912 if (ch < 128) {
0913 return _Py_ascii_whitespace[ch];
0914 }
0915 return _PyUnicode_IsWhitespace(ch);
0916 }
0917
0918 #define Py_UNICODE_ISLOWER(ch) _PyUnicode_IsLowercase(ch)
0919 #define Py_UNICODE_ISUPPER(ch) _PyUnicode_IsUppercase(ch)
0920 #define Py_UNICODE_ISTITLE(ch) _PyUnicode_IsTitlecase(ch)
0921 #define Py_UNICODE_ISLINEBREAK(ch) _PyUnicode_IsLinebreak(ch)
0922
0923 #define Py_UNICODE_TOLOWER(ch) _PyUnicode_ToLowercase(ch)
0924 #define Py_UNICODE_TOUPPER(ch) _PyUnicode_ToUppercase(ch)
0925 #define Py_UNICODE_TOTITLE(ch) _PyUnicode_ToTitlecase(ch)
0926
0927 #define Py_UNICODE_ISDECIMAL(ch) _PyUnicode_IsDecimalDigit(ch)
0928 #define Py_UNICODE_ISDIGIT(ch) _PyUnicode_IsDigit(ch)
0929 #define Py_UNICODE_ISNUMERIC(ch) _PyUnicode_IsNumeric(ch)
0930 #define Py_UNICODE_ISPRINTABLE(ch) _PyUnicode_IsPrintable(ch)
0931
0932 #define Py_UNICODE_TODECIMAL(ch) _PyUnicode_ToDecimalDigit(ch)
0933 #define Py_UNICODE_TODIGIT(ch) _PyUnicode_ToDigit(ch)
0934 #define Py_UNICODE_TONUMERIC(ch) _PyUnicode_ToNumeric(ch)
0935
0936 #define Py_UNICODE_ISALPHA(ch) _PyUnicode_IsAlpha(ch)
0937
0938 static inline int Py_UNICODE_ISALNUM(Py_UCS4 ch) {
0939 return (Py_UNICODE_ISALPHA(ch)
0940 || Py_UNICODE_ISDECIMAL(ch)
0941 || Py_UNICODE_ISDIGIT(ch)
0942 || Py_UNICODE_ISNUMERIC(ch));
0943 }
0944
0945
0946
0947
0948 PyAPI_FUNC(PyObject*) _PyUnicode_FormatLong(PyObject *, int, int, int);
0949
0950
0951 PyAPI_FUNC(PyObject*) _PyUnicode_FromId(_Py_Identifier*);
0952
0953
0954
0955 PyAPI_FUNC(int) _PyUnicode_EQ(PyObject *, PyObject *);
0956
0957
0958 PyAPI_FUNC(int) _PyUnicode_Equal(PyObject *, PyObject *);
0959
0960 PyAPI_FUNC(int) _PyUnicode_WideCharString_Converter(PyObject *, void *);
0961 PyAPI_FUNC(int) _PyUnicode_WideCharString_Opt_Converter(PyObject *, void *);
0962
0963 PyAPI_FUNC(Py_ssize_t) _PyUnicode_ScanIdentifier(PyObject *);