| OLD | NEW |
| 1 /* | 1 /* |
| 2 Unicode character type helpers. | 2 Unicode character type helpers. |
| 3 | 3 |
| 4 Written by Marc-Andre Lemburg (mal@lemburg.com). | 4 Written by Marc-Andre Lemburg (mal@lemburg.com). |
| 5 Modified for Python 2.0 by Fredrik Lundh (fredrik@pythonware.com) | 5 Modified for Python 2.0 by Fredrik Lundh (fredrik@pythonware.com) |
| 6 | 6 |
| 7 Copyright (c) Corporation for National Research Initiatives. | 7 Copyright (c) Corporation for National Research Initiatives. |
| 8 | 8 |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #include "Python.h" | 11 #include "Python.h" |
| 12 #include "unicodeobject.h" | 12 #include "unicodeobject.h" |
| 13 | 13 |
| 14 #define ALPHA_MASK 0x01 | 14 #define ALPHA_MASK 0x01 |
| 15 #define DECIMAL_MASK 0x02 | 15 #define DECIMAL_MASK 0x02 |
| 16 #define DIGIT_MASK 0x04 | 16 #define DIGIT_MASK 0x04 |
| 17 #define LOWER_MASK 0x08 | 17 #define LOWER_MASK 0x08 |
| 18 #define LINEBREAK_MASK 0x10 | 18 #define LINEBREAK_MASK 0x10 |
| 19 #define SPACE_MASK 0x20 | 19 #define SPACE_MASK 0x20 |
| 20 #define TITLE_MASK 0x40 | 20 #define TITLE_MASK 0x40 |
| 21 #define UPPER_MASK 0x80 | 21 #define UPPER_MASK 0x80 |
| 22 #define XID_START_MASK 0x100 | 22 #define XID_START_MASK 0x100 |
| 23 #define XID_CONTINUE_MASK 0x200 | 23 #define XID_CONTINUE_MASK 0x200 |
| 24 #define HEX_ESCAPE_MASK 0x400 |
| 24 | 25 |
| 25 typedef struct { | 26 typedef struct { |
| 26 const Py_UNICODE upper; | 27 const Py_UNICODE upper; |
| 27 const Py_UNICODE lower; | 28 const Py_UNICODE lower; |
| 28 const Py_UNICODE title; | 29 const Py_UNICODE title; |
| 29 const unsigned char decimal; | 30 const unsigned char decimal; |
| 30 const unsigned char digit; | 31 const unsigned char digit; |
| 31 const unsigned short flags; | 32 const unsigned short flags; |
| 32 } _PyUnicode_TypeRecord; | 33 } _PyUnicode_TypeRecord; |
| 33 | 34 |
| (...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 #endif | 668 #endif |
| 668 default: | 669 default: |
| 669 return (double) _PyUnicode_ToDigit(ch); | 670 return (double) _PyUnicode_ToDigit(ch); |
| 670 } | 671 } |
| 671 } | 672 } |
| 672 | 673 |
| 673 int _PyUnicode_IsNumeric(Py_UNICODE ch) | 674 int _PyUnicode_IsNumeric(Py_UNICODE ch) |
| 674 { | 675 { |
| 675 return _PyUnicode_ToNumeric(ch) != -1.0; | 676 return _PyUnicode_ToNumeric(ch) != -1.0; |
| 676 } | 677 } |
| 678 |
| 679 /* Returns 1 for Unicode characters to be hex-escaped when repr()ed, |
| 680 0 otherwise. */ |
| 681 |
| 682 int _PyUnicode_IsHexEscaped(Py_UNICODE ch) |
| 683 { |
| 684 const _PyUnicode_TypeRecord *ctype = gettyperecord(ch); |
| 685 |
| 686 return (ctype->flags & HEX_ESCAPE_MASK) != 0; |
| 687 } |
| 688 |
| 677 | 689 |
| 678 #ifndef WANT_WCTYPE_FUNCTIONS | 690 #ifndef WANT_WCTYPE_FUNCTIONS |
| 679 | 691 |
| 680 /* Returns 1 for Unicode characters having the bidirectional type | 692 /* Returns 1 for Unicode characters having the bidirectional type |
| 681 'WS', 'B' or 'S' or the category 'Zs', 0 otherwise. */ | 693 'WS', 'B' or 'S' or the category 'Zs', 0 otherwise. */ |
| 682 | 694 |
| 683 int _PyUnicode_IsWhitespace(register const Py_UNICODE ch) | 695 int _PyUnicode_IsWhitespace(register const Py_UNICODE ch) |
| 684 { | 696 { |
| 685 switch (ch) { | 697 switch (ch) { |
| 686 case 0x0009: /* HORIZONTAL TABULATION */ | 698 case 0x0009: /* HORIZONTAL TABULATION */ |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 { | 814 { |
| 803 return towupper(ch); | 815 return towupper(ch); |
| 804 } | 816 } |
| 805 | 817 |
| 806 int _PyUnicode_IsAlpha(Py_UNICODE ch) | 818 int _PyUnicode_IsAlpha(Py_UNICODE ch) |
| 807 { | 819 { |
| 808 return iswalpha(ch); | 820 return iswalpha(ch); |
| 809 } | 821 } |
| 810 | 822 |
| 811 #endif | 823 #endif |
| OLD | NEW |