Guido van Rossum | 603484d | 2000-03-10 22:52:46 +0000 | [diff] [blame] | 1 | /* |
| 2 | Unicode character type helpers. |
| 3 | |
Fredrik Lundh | 9e7dd4c | 2000-09-25 21:48:13 +0000 | [diff] [blame] | 4 | Written by Marc-Andre Lemburg (mal@lemburg.com). |
| 5 | Modified for Python 2.0 by Fredrik Lundh (fredrik@pythonware.com) |
Guido van Rossum | 603484d | 2000-03-10 22:52:46 +0000 | [diff] [blame] | 6 | |
Fredrik Lundh | 9e7dd4c | 2000-09-25 21:48:13 +0000 | [diff] [blame] | 7 | Copyright (c) Corporation for National Research Initiatives. |
Guido van Rossum | 603484d | 2000-03-10 22:52:46 +0000 | [diff] [blame] | 8 | |
| 9 | */ |
| 10 | |
| 11 | #include "Python.h" |
Guido van Rossum | 603484d | 2000-03-10 22:52:46 +0000 | [diff] [blame] | 12 | |
Fredrik Lundh | 9e7dd4c | 2000-09-25 21:48:13 +0000 | [diff] [blame] | 13 | #define ALPHA_MASK 0x01 |
| 14 | #define DECIMAL_MASK 0x02 |
| 15 | #define DIGIT_MASK 0x04 |
| 16 | #define LOWER_MASK 0x08 |
| 17 | #define LINEBREAK_MASK 0x10 |
| 18 | #define SPACE_MASK 0x20 |
| 19 | #define TITLE_MASK 0x40 |
| 20 | #define UPPER_MASK 0x80 |
Martin v. Löwis | 13c3e38 | 2007-08-14 22:37:03 +0000 | [diff] [blame] | 21 | #define XID_START_MASK 0x100 |
| 22 | #define XID_CONTINUE_MASK 0x200 |
Georg Brandl | d52429f | 2008-07-04 15:55:02 +0000 | [diff] [blame] | 23 | #define PRINTABLE_MASK 0x400 |
Benjamin Peterson | b2bf01d | 2012-01-11 18:17:06 -0500 | [diff] [blame] | 24 | #define NUMERIC_MASK 0x800 |
| 25 | #define CASE_IGNORABLE_MASK 0x1000 |
| 26 | #define CASED_MASK 0x2000 |
| 27 | #define EXTENDED_CASE_MASK 0x4000 |
Jack Jansen | 56cdce3 | 2000-07-06 13:57:38 +0000 | [diff] [blame] | 28 | |
Fredrik Lundh | 9e7dd4c | 2000-09-25 21:48:13 +0000 | [diff] [blame] | 29 | typedef struct { |
Benjamin Peterson | ad9c569 | 2012-01-15 21:19:20 -0500 | [diff] [blame^] | 30 | /* |
| 31 | These are either deltas to the character or offsets in |
| 32 | _PyUnicode_ExtendedCase. |
| 33 | */ |
| 34 | const int upper; |
| 35 | const int lower; |
| 36 | const int title; |
Fredrik Lundh | 9e7dd4c | 2000-09-25 21:48:13 +0000 | [diff] [blame] | 37 | const unsigned char decimal; |
| 38 | const unsigned char digit; |
Hye-Shik Chang | 974ed7c | 2004-06-02 16:49:17 +0000 | [diff] [blame] | 39 | const unsigned short flags; |
Fredrik Lundh | 9e7dd4c | 2000-09-25 21:48:13 +0000 | [diff] [blame] | 40 | } _PyUnicode_TypeRecord; |
| 41 | |
| 42 | #include "unicodetype_db.h" |
| 43 | |
| 44 | static const _PyUnicode_TypeRecord * |
Amaury Forgeot d'Arc | 324ac65 | 2010-08-18 20:44:58 +0000 | [diff] [blame] | 45 | gettyperecord(Py_UCS4 code) |
Fredrik Lundh | 9e7dd4c | 2000-09-25 21:48:13 +0000 | [diff] [blame] | 46 | { |
| 47 | int index; |
| 48 | |
Martin v. Löwis | 9def6a3 | 2002-10-18 16:11:54 +0000 | [diff] [blame] | 49 | if (code >= 0x110000) |
Fredrik Lundh | 9e7dd4c | 2000-09-25 21:48:13 +0000 | [diff] [blame] | 50 | index = 0; |
Hye-Shik Chang | 7db07e6 | 2003-12-29 01:36:01 +0000 | [diff] [blame] | 51 | else |
Hye-Shik Chang | 7db07e6 | 2003-12-29 01:36:01 +0000 | [diff] [blame] | 52 | { |
Fredrik Lundh | 9e7dd4c | 2000-09-25 21:48:13 +0000 | [diff] [blame] | 53 | index = index1[(code>>SHIFT)]; |
| 54 | index = index2[(index<<SHIFT)+(code&((1<<SHIFT)-1))]; |
| 55 | } |
Fredrik Lundh | ee13dba | 2001-06-26 20:36:12 +0000 | [diff] [blame] | 56 | |
Fredrik Lundh | 9e7dd4c | 2000-09-25 21:48:13 +0000 | [diff] [blame] | 57 | return &_PyUnicode_TypeRecords[index]; |
| 58 | } |
Jack Jansen | 56cdce3 | 2000-07-06 13:57:38 +0000 | [diff] [blame] | 59 | |
Guido van Rossum | 603484d | 2000-03-10 22:52:46 +0000 | [diff] [blame] | 60 | /* Returns the titlecase Unicode characters corresponding to ch or just |
| 61 | ch if no titlecase mapping is known. */ |
| 62 | |
Amaury Forgeot d'Arc | 324ac65 | 2010-08-18 20:44:58 +0000 | [diff] [blame] | 63 | Py_UCS4 _PyUnicode_ToTitlecase(register Py_UCS4 ch) |
Guido van Rossum | 603484d | 2000-03-10 22:52:46 +0000 | [diff] [blame] | 64 | { |
Fredrik Lundh | 9e7dd4c | 2000-09-25 21:48:13 +0000 | [diff] [blame] | 65 | const _PyUnicode_TypeRecord *ctype = gettyperecord(ch); |
Fredrik Lundh | 9e7dd4c | 2000-09-25 21:48:13 +0000 | [diff] [blame] | 66 | |
Benjamin Peterson | ad9c569 | 2012-01-15 21:19:20 -0500 | [diff] [blame^] | 67 | return ch + ctype->title; |
Guido van Rossum | 603484d | 2000-03-10 22:52:46 +0000 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | /* Returns 1 for Unicode characters having the category 'Lt', 0 |
| 71 | otherwise. */ |
| 72 | |
Amaury Forgeot d'Arc | 324ac65 | 2010-08-18 20:44:58 +0000 | [diff] [blame] | 73 | int _PyUnicode_IsTitlecase(Py_UCS4 ch) |
Guido van Rossum | 603484d | 2000-03-10 22:52:46 +0000 | [diff] [blame] | 74 | { |
Fredrik Lundh | 9e7dd4c | 2000-09-25 21:48:13 +0000 | [diff] [blame] | 75 | const _PyUnicode_TypeRecord *ctype = gettyperecord(ch); |
| 76 | |
| 77 | return (ctype->flags & TITLE_MASK) != 0; |
Guido van Rossum | 603484d | 2000-03-10 22:52:46 +0000 | [diff] [blame] | 78 | } |
| 79 | |
Martin v. Löwis | 13c3e38 | 2007-08-14 22:37:03 +0000 | [diff] [blame] | 80 | /* Returns 1 for Unicode characters having the XID_Start property, 0 |
| 81 | otherwise. */ |
| 82 | |
Amaury Forgeot d'Arc | 324ac65 | 2010-08-18 20:44:58 +0000 | [diff] [blame] | 83 | int _PyUnicode_IsXidStart(Py_UCS4 ch) |
Martin v. Löwis | 13c3e38 | 2007-08-14 22:37:03 +0000 | [diff] [blame] | 84 | { |
| 85 | const _PyUnicode_TypeRecord *ctype = gettyperecord(ch); |
| 86 | |
| 87 | return (ctype->flags & XID_START_MASK) != 0; |
| 88 | } |
| 89 | |
| 90 | /* Returns 1 for Unicode characters having the XID_Continue property, |
| 91 | 0 otherwise. */ |
| 92 | |
Amaury Forgeot d'Arc | 324ac65 | 2010-08-18 20:44:58 +0000 | [diff] [blame] | 93 | int _PyUnicode_IsXidContinue(Py_UCS4 ch) |
Martin v. Löwis | 13c3e38 | 2007-08-14 22:37:03 +0000 | [diff] [blame] | 94 | { |
| 95 | const _PyUnicode_TypeRecord *ctype = gettyperecord(ch); |
| 96 | |
| 97 | return (ctype->flags & XID_CONTINUE_MASK) != 0; |
| 98 | } |
| 99 | |
Guido van Rossum | 603484d | 2000-03-10 22:52:46 +0000 | [diff] [blame] | 100 | /* Returns the integer decimal (0-9) for Unicode characters having |
| 101 | this property, -1 otherwise. */ |
| 102 | |
Amaury Forgeot d'Arc | 324ac65 | 2010-08-18 20:44:58 +0000 | [diff] [blame] | 103 | int _PyUnicode_ToDecimalDigit(Py_UCS4 ch) |
Guido van Rossum | 603484d | 2000-03-10 22:52:46 +0000 | [diff] [blame] | 104 | { |
Fredrik Lundh | 9e7dd4c | 2000-09-25 21:48:13 +0000 | [diff] [blame] | 105 | const _PyUnicode_TypeRecord *ctype = gettyperecord(ch); |
| 106 | |
| 107 | return (ctype->flags & DECIMAL_MASK) ? ctype->decimal : -1; |
Guido van Rossum | 603484d | 2000-03-10 22:52:46 +0000 | [diff] [blame] | 108 | } |
| 109 | |
Amaury Forgeot d'Arc | 324ac65 | 2010-08-18 20:44:58 +0000 | [diff] [blame] | 110 | int _PyUnicode_IsDecimalDigit(Py_UCS4 ch) |
Guido van Rossum | 603484d | 2000-03-10 22:52:46 +0000 | [diff] [blame] | 111 | { |
| 112 | if (_PyUnicode_ToDecimalDigit(ch) < 0) |
Alexander Belopolsky | f0f4514 | 2010-08-11 17:31:17 +0000 | [diff] [blame] | 113 | return 0; |
Guido van Rossum | 603484d | 2000-03-10 22:52:46 +0000 | [diff] [blame] | 114 | return 1; |
| 115 | } |
| 116 | |
| 117 | /* Returns the integer digit (0-9) for Unicode characters having |
| 118 | this property, -1 otherwise. */ |
| 119 | |
Amaury Forgeot d'Arc | 324ac65 | 2010-08-18 20:44:58 +0000 | [diff] [blame] | 120 | int _PyUnicode_ToDigit(Py_UCS4 ch) |
Guido van Rossum | 603484d | 2000-03-10 22:52:46 +0000 | [diff] [blame] | 121 | { |
Fredrik Lundh | 9e7dd4c | 2000-09-25 21:48:13 +0000 | [diff] [blame] | 122 | const _PyUnicode_TypeRecord *ctype = gettyperecord(ch); |
| 123 | |
| 124 | return (ctype->flags & DIGIT_MASK) ? ctype->digit : -1; |
Guido van Rossum | 603484d | 2000-03-10 22:52:46 +0000 | [diff] [blame] | 125 | } |
| 126 | |
Amaury Forgeot d'Arc | 324ac65 | 2010-08-18 20:44:58 +0000 | [diff] [blame] | 127 | int _PyUnicode_IsDigit(Py_UCS4 ch) |
Guido van Rossum | 603484d | 2000-03-10 22:52:46 +0000 | [diff] [blame] | 128 | { |
| 129 | if (_PyUnicode_ToDigit(ch) < 0) |
Alexander Belopolsky | f0f4514 | 2010-08-11 17:31:17 +0000 | [diff] [blame] | 130 | return 0; |
Guido van Rossum | 603484d | 2000-03-10 22:52:46 +0000 | [diff] [blame] | 131 | return 1; |
| 132 | } |
| 133 | |
| 134 | /* Returns the numeric value as double for Unicode characters having |
| 135 | this property, -1.0 otherwise. */ |
| 136 | |
Amaury Forgeot d'Arc | 324ac65 | 2010-08-18 20:44:58 +0000 | [diff] [blame] | 137 | int _PyUnicode_IsNumeric(Py_UCS4 ch) |
Guido van Rossum | 603484d | 2000-03-10 22:52:46 +0000 | [diff] [blame] | 138 | { |
Amaury Forgeot d'Arc | 7d52079 | 2009-10-06 21:03:20 +0000 | [diff] [blame] | 139 | const _PyUnicode_TypeRecord *ctype = gettyperecord(ch); |
| 140 | |
| 141 | return (ctype->flags & NUMERIC_MASK) != 0; |
Guido van Rossum | 603484d | 2000-03-10 22:52:46 +0000 | [diff] [blame] | 142 | } |
| 143 | |
Georg Brandl | 559e5d7 | 2008-06-11 18:37:52 +0000 | [diff] [blame] | 144 | /* Returns 1 for Unicode characters to be hex-escaped when repr()ed, |
| 145 | 0 otherwise. |
| 146 | All characters except those characters defined in the Unicode character |
| 147 | database as following categories are considered printable. |
| 148 | * Cc (Other, Control) |
| 149 | * Cf (Other, Format) |
| 150 | * Cs (Other, Surrogate) |
| 151 | * Co (Other, Private Use) |
| 152 | * Cn (Other, Not Assigned) |
| 153 | * Zl Separator, Line ('\u2028', LINE SEPARATOR) |
| 154 | * Zp Separator, Paragraph ('\u2029', PARAGRAPH SEPARATOR) |
| 155 | * Zs (Separator, Space) other than ASCII space('\x20'). |
| 156 | */ |
Amaury Forgeot d'Arc | 324ac65 | 2010-08-18 20:44:58 +0000 | [diff] [blame] | 157 | int _PyUnicode_IsPrintable(Py_UCS4 ch) |
Georg Brandl | 559e5d7 | 2008-06-11 18:37:52 +0000 | [diff] [blame] | 158 | { |
| 159 | const _PyUnicode_TypeRecord *ctype = gettyperecord(ch); |
| 160 | |
Georg Brandl | d52429f | 2008-07-04 15:55:02 +0000 | [diff] [blame] | 161 | return (ctype->flags & PRINTABLE_MASK) != 0; |
Georg Brandl | 559e5d7 | 2008-06-11 18:37:52 +0000 | [diff] [blame] | 162 | } |
| 163 | |
Guido van Rossum | 603484d | 2000-03-10 22:52:46 +0000 | [diff] [blame] | 164 | /* Returns 1 for Unicode characters having the category 'Ll', 0 |
| 165 | otherwise. */ |
| 166 | |
Amaury Forgeot d'Arc | 324ac65 | 2010-08-18 20:44:58 +0000 | [diff] [blame] | 167 | int _PyUnicode_IsLowercase(Py_UCS4 ch) |
Guido van Rossum | 603484d | 2000-03-10 22:52:46 +0000 | [diff] [blame] | 168 | { |
Fredrik Lundh | 9e7dd4c | 2000-09-25 21:48:13 +0000 | [diff] [blame] | 169 | const _PyUnicode_TypeRecord *ctype = gettyperecord(ch); |
| 170 | |
| 171 | return (ctype->flags & LOWER_MASK) != 0; |
Guido van Rossum | 603484d | 2000-03-10 22:52:46 +0000 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | /* Returns 1 for Unicode characters having the category 'Lu', 0 |
| 175 | otherwise. */ |
| 176 | |
Amaury Forgeot d'Arc | 324ac65 | 2010-08-18 20:44:58 +0000 | [diff] [blame] | 177 | int _PyUnicode_IsUppercase(Py_UCS4 ch) |
Guido van Rossum | 603484d | 2000-03-10 22:52:46 +0000 | [diff] [blame] | 178 | { |
Fredrik Lundh | 9e7dd4c | 2000-09-25 21:48:13 +0000 | [diff] [blame] | 179 | const _PyUnicode_TypeRecord *ctype = gettyperecord(ch); |
| 180 | |
| 181 | return (ctype->flags & UPPER_MASK) != 0; |
Guido van Rossum | 603484d | 2000-03-10 22:52:46 +0000 | [diff] [blame] | 182 | } |
| 183 | |
| 184 | /* Returns the uppercase Unicode characters corresponding to ch or just |
| 185 | ch if no uppercase mapping is known. */ |
| 186 | |
Amaury Forgeot d'Arc | 324ac65 | 2010-08-18 20:44:58 +0000 | [diff] [blame] | 187 | Py_UCS4 _PyUnicode_ToUppercase(Py_UCS4 ch) |
Guido van Rossum | 603484d | 2000-03-10 22:52:46 +0000 | [diff] [blame] | 188 | { |
Fredrik Lundh | 9e7dd4c | 2000-09-25 21:48:13 +0000 | [diff] [blame] | 189 | const _PyUnicode_TypeRecord *ctype = gettyperecord(ch); |
Benjamin Peterson | b2bf01d | 2012-01-11 18:17:06 -0500 | [diff] [blame] | 190 | |
| 191 | if (ctype->flags & EXTENDED_CASE_MASK) |
Benjamin Peterson | d5890c8 | 2012-01-14 13:23:30 -0500 | [diff] [blame] | 192 | return _PyUnicode_ExtendedCase[ctype->upper & 0xFFFF]; |
Benjamin Peterson | ad9c569 | 2012-01-15 21:19:20 -0500 | [diff] [blame^] | 193 | return ch + ctype->upper; |
Guido van Rossum | 603484d | 2000-03-10 22:52:46 +0000 | [diff] [blame] | 194 | } |
| 195 | |
| 196 | /* Returns the lowercase Unicode characters corresponding to ch or just |
| 197 | ch if no lowercase mapping is known. */ |
| 198 | |
Amaury Forgeot d'Arc | 324ac65 | 2010-08-18 20:44:58 +0000 | [diff] [blame] | 199 | Py_UCS4 _PyUnicode_ToLowercase(Py_UCS4 ch) |
Guido van Rossum | 603484d | 2000-03-10 22:52:46 +0000 | [diff] [blame] | 200 | { |
Fredrik Lundh | 9e7dd4c | 2000-09-25 21:48:13 +0000 | [diff] [blame] | 201 | const _PyUnicode_TypeRecord *ctype = gettyperecord(ch); |
Benjamin Peterson | b2bf01d | 2012-01-11 18:17:06 -0500 | [diff] [blame] | 202 | |
| 203 | if (ctype->flags & EXTENDED_CASE_MASK) |
Benjamin Peterson | d5890c8 | 2012-01-14 13:23:30 -0500 | [diff] [blame] | 204 | return _PyUnicode_ExtendedCase[ctype->lower & 0xFFFF]; |
Benjamin Peterson | ad9c569 | 2012-01-15 21:19:20 -0500 | [diff] [blame^] | 205 | return ch + ctype->lower; |
Benjamin Peterson | b2bf01d | 2012-01-11 18:17:06 -0500 | [diff] [blame] | 206 | } |
| 207 | |
| 208 | int _PyUnicode_ToLowerFull(Py_UCS4 ch, Py_UCS4 *res) |
| 209 | { |
| 210 | const _PyUnicode_TypeRecord *ctype = gettyperecord(ch); |
| 211 | |
| 212 | if (ctype->flags & EXTENDED_CASE_MASK) { |
Benjamin Peterson | d5890c8 | 2012-01-14 13:23:30 -0500 | [diff] [blame] | 213 | int index = ctype->lower & 0xFFFF; |
Benjamin Peterson | b2bf01d | 2012-01-11 18:17:06 -0500 | [diff] [blame] | 214 | int n = ctype->lower >> 24; |
| 215 | int i; |
| 216 | for (i = 0; i < n; i++) |
| 217 | res[i] = _PyUnicode_ExtendedCase[index + i]; |
| 218 | return n; |
| 219 | } |
Benjamin Peterson | ad9c569 | 2012-01-15 21:19:20 -0500 | [diff] [blame^] | 220 | res[0] = ch + ctype->lower; |
Benjamin Peterson | b2bf01d | 2012-01-11 18:17:06 -0500 | [diff] [blame] | 221 | return 1; |
| 222 | } |
| 223 | |
| 224 | int _PyUnicode_ToTitleFull(Py_UCS4 ch, Py_UCS4 *res) |
| 225 | { |
| 226 | const _PyUnicode_TypeRecord *ctype = gettyperecord(ch); |
| 227 | |
| 228 | if (ctype->flags & EXTENDED_CASE_MASK) { |
Benjamin Peterson | d5890c8 | 2012-01-14 13:23:30 -0500 | [diff] [blame] | 229 | int index = ctype->title & 0xFFFF; |
Benjamin Peterson | b2bf01d | 2012-01-11 18:17:06 -0500 | [diff] [blame] | 230 | int n = ctype->title >> 24; |
| 231 | int i; |
| 232 | for (i = 0; i < n; i++) |
| 233 | res[i] = _PyUnicode_ExtendedCase[index + i]; |
| 234 | return n; |
| 235 | } |
Benjamin Peterson | ad9c569 | 2012-01-15 21:19:20 -0500 | [diff] [blame^] | 236 | res[0] = ch + ctype->title; |
Benjamin Peterson | b2bf01d | 2012-01-11 18:17:06 -0500 | [diff] [blame] | 237 | return 1; |
| 238 | } |
| 239 | |
| 240 | int _PyUnicode_ToUpperFull(Py_UCS4 ch, Py_UCS4 *res) |
| 241 | { |
| 242 | const _PyUnicode_TypeRecord *ctype = gettyperecord(ch); |
| 243 | |
| 244 | if (ctype->flags & EXTENDED_CASE_MASK) { |
Benjamin Peterson | d5890c8 | 2012-01-14 13:23:30 -0500 | [diff] [blame] | 245 | int index = ctype->upper & 0xFFFF; |
Benjamin Peterson | b2bf01d | 2012-01-11 18:17:06 -0500 | [diff] [blame] | 246 | int n = ctype->upper >> 24; |
| 247 | int i; |
| 248 | for (i = 0; i < n; i++) |
| 249 | res[i] = _PyUnicode_ExtendedCase[index + i]; |
| 250 | return n; |
| 251 | } |
Benjamin Peterson | ad9c569 | 2012-01-15 21:19:20 -0500 | [diff] [blame^] | 252 | res[0] = ch + ctype->upper; |
Benjamin Peterson | b2bf01d | 2012-01-11 18:17:06 -0500 | [diff] [blame] | 253 | return 1; |
| 254 | } |
| 255 | |
Benjamin Peterson | d5890c8 | 2012-01-14 13:23:30 -0500 | [diff] [blame] | 256 | int _PyUnicode_ToFoldedFull(Py_UCS4 ch, Py_UCS4 *res) |
| 257 | { |
| 258 | const _PyUnicode_TypeRecord *ctype = gettyperecord(ch); |
| 259 | |
| 260 | if (ctype->flags & EXTENDED_CASE_MASK && (ctype->lower >> 20) & 7) { |
| 261 | int index = (ctype->lower & 0xFFFF) + (ctype->lower >> 24); |
| 262 | int n = (ctype->lower >> 20) & 7; |
| 263 | int i; |
| 264 | for (i = 0; i < n; i++) |
| 265 | res[i] = _PyUnicode_ExtendedCase[index + i]; |
| 266 | return n; |
| 267 | } |
| 268 | return _PyUnicode_ToLowerFull(ch, res); |
| 269 | } |
| 270 | |
Benjamin Peterson | b2bf01d | 2012-01-11 18:17:06 -0500 | [diff] [blame] | 271 | int _PyUnicode_IsCased(Py_UCS4 ch) |
| 272 | { |
| 273 | const _PyUnicode_TypeRecord *ctype = gettyperecord(ch); |
| 274 | |
| 275 | return (ctype->flags & CASED_MASK) != 0; |
| 276 | } |
| 277 | |
| 278 | int _PyUnicode_IsCaseIgnorable(Py_UCS4 ch) |
| 279 | { |
| 280 | const _PyUnicode_TypeRecord *ctype = gettyperecord(ch); |
| 281 | |
| 282 | return (ctype->flags & CASE_IGNORABLE_MASK) != 0; |
Guido van Rossum | 603484d | 2000-03-10 22:52:46 +0000 | [diff] [blame] | 283 | } |
| 284 | |
Marc-André Lemburg | f3938f5 | 2000-07-05 09:48:59 +0000 | [diff] [blame] | 285 | /* Returns 1 for Unicode characters having the category 'Ll', 'Lu', 'Lt', |
| 286 | 'Lo' or 'Lm', 0 otherwise. */ |
| 287 | |
Amaury Forgeot d'Arc | 324ac65 | 2010-08-18 20:44:58 +0000 | [diff] [blame] | 288 | int _PyUnicode_IsAlpha(Py_UCS4 ch) |
Marc-André Lemburg | f3938f5 | 2000-07-05 09:48:59 +0000 | [diff] [blame] | 289 | { |
Fredrik Lundh | 9e7dd4c | 2000-09-25 21:48:13 +0000 | [diff] [blame] | 290 | const _PyUnicode_TypeRecord *ctype = gettyperecord(ch); |
Marc-André Lemburg | f3938f5 | 2000-07-05 09:48:59 +0000 | [diff] [blame] | 291 | |
Fredrik Lundh | 9e7dd4c | 2000-09-25 21:48:13 +0000 | [diff] [blame] | 292 | return (ctype->flags & ALPHA_MASK) != 0; |
Marc-André Lemburg | f3938f5 | 2000-07-05 09:48:59 +0000 | [diff] [blame] | 293 | } |
| 294 | |