2000-03-10 18:52:46 -04:00
|
|
|
/*
|
|
|
|
Unicode character type helpers.
|
|
|
|
|
2000-09-25 18:48:13 -03:00
|
|
|
Written by Marc-Andre Lemburg (mal@lemburg.com).
|
|
|
|
Modified for Python 2.0 by Fredrik Lundh (fredrik@pythonware.com)
|
2000-03-10 18:52:46 -04:00
|
|
|
|
2000-09-25 18:48:13 -03:00
|
|
|
Copyright (c) Corporation for National Research Initiatives.
|
2000-03-10 18:52:46 -04:00
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "Python.h"
|
|
|
|
#include "unicodeobject.h"
|
|
|
|
|
2000-09-25 18:48:13 -03:00
|
|
|
#define ALPHA_MASK 0x01
|
|
|
|
#define DECIMAL_MASK 0x02
|
|
|
|
#define DIGIT_MASK 0x04
|
|
|
|
#define LOWER_MASK 0x08
|
|
|
|
#define LINEBREAK_MASK 0x10
|
|
|
|
#define SPACE_MASK 0x20
|
|
|
|
#define TITLE_MASK 0x40
|
|
|
|
#define UPPER_MASK 0x80
|
2008-09-10 10:38:12 -03:00
|
|
|
#define NODELTA_MASK 0x100
|
2000-09-25 18:48:13 -03:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
const Py_UNICODE upper;
|
|
|
|
const Py_UNICODE lower;
|
|
|
|
const Py_UNICODE title;
|
|
|
|
const unsigned char decimal;
|
|
|
|
const unsigned char digit;
|
2004-06-02 13:49:17 -03:00
|
|
|
const unsigned short flags;
|
2000-09-25 18:48:13 -03:00
|
|
|
} _PyUnicode_TypeRecord;
|
|
|
|
|
|
|
|
#include "unicodetype_db.h"
|
|
|
|
|
|
|
|
static const _PyUnicode_TypeRecord *
|
2001-06-26 17:36:12 -03:00
|
|
|
gettyperecord(Py_UNICODE code)
|
2000-09-25 18:48:13 -03:00
|
|
|
{
|
|
|
|
int index;
|
2000-07-06 10:57:38 -03:00
|
|
|
|
2003-12-28 21:36:01 -04:00
|
|
|
#ifdef Py_UNICODE_WIDE
|
2002-10-18 13:11:54 -03:00
|
|
|
if (code >= 0x110000)
|
2010-05-09 12:15:40 -03:00
|
|
|
index = 0;
|
2003-12-28 21:36:01 -04:00
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
2010-05-09 12:15:40 -03:00
|
|
|
index = index1[(code>>SHIFT)];
|
|
|
|
index = index2[(index<<SHIFT)+(code&((1<<SHIFT)-1))];
|
2000-09-25 18:48:13 -03:00
|
|
|
}
|
2001-06-26 17:36:12 -03:00
|
|
|
|
2000-09-25 18:48:13 -03:00
|
|
|
return &_PyUnicode_TypeRecords[index];
|
|
|
|
}
|
2000-07-06 10:57:38 -03:00
|
|
|
|
2005-10-20 16:06:35 -03:00
|
|
|
/* Returns 1 for Unicode characters having the category 'Zl', 'Zp' or
|
|
|
|
type 'B', 0 otherwise. */
|
2000-03-10 18:52:46 -04:00
|
|
|
|
2005-10-20 16:06:35 -03:00
|
|
|
int _PyUnicode_IsLinebreak(register const Py_UNICODE ch)
|
2000-03-10 18:52:46 -04:00
|
|
|
{
|
2005-10-20 16:06:35 -03:00
|
|
|
switch (ch) {
|
|
|
|
case 0x000A: /* LINE FEED */
|
|
|
|
case 0x000D: /* CARRIAGE RETURN */
|
|
|
|
case 0x001C: /* FILE SEPARATOR */
|
|
|
|
case 0x001D: /* GROUP SEPARATOR */
|
|
|
|
case 0x001E: /* RECORD SEPARATOR */
|
|
|
|
case 0x0085: /* NEXT LINE */
|
|
|
|
case 0x2028: /* LINE SEPARATOR */
|
|
|
|
case 0x2029: /* PARAGRAPH SEPARATOR */
|
2010-05-09 12:15:40 -03:00
|
|
|
return 1;
|
2005-10-20 16:06:35 -03:00
|
|
|
default:
|
2010-05-09 12:15:40 -03:00
|
|
|
return 0;
|
2005-10-20 16:06:35 -03:00
|
|
|
}
|
2000-03-10 18:52:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Returns the titlecase Unicode characters corresponding to ch or just
|
|
|
|
ch if no titlecase mapping is known. */
|
|
|
|
|
2001-06-27 03:28:56 -03:00
|
|
|
Py_UNICODE _PyUnicode_ToTitlecase(register Py_UNICODE ch)
|
2000-03-10 18:52:46 -04:00
|
|
|
{
|
2000-09-25 18:48:13 -03:00
|
|
|
const _PyUnicode_TypeRecord *ctype = gettyperecord(ch);
|
2009-04-25 22:01:58 -03:00
|
|
|
int delta = ctype->title;
|
2001-06-27 03:28:56 -03:00
|
|
|
|
2008-09-10 10:38:12 -03:00
|
|
|
if (ctype->flags & NODELTA_MASK)
|
2010-05-09 12:15:40 -03:00
|
|
|
return delta;
|
2008-09-10 10:38:12 -03:00
|
|
|
|
2002-10-18 13:40:36 -03:00
|
|
|
if (delta >= 32768)
|
2010-05-09 12:15:40 -03:00
|
|
|
delta -= 65536;
|
2002-10-18 13:40:36 -03:00
|
|
|
|
|
|
|
return ch + delta;
|
2000-03-10 18:52:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Returns 1 for Unicode characters having the category 'Lt', 0
|
|
|
|
otherwise. */
|
|
|
|
|
2001-06-27 19:08:26 -03:00
|
|
|
int _PyUnicode_IsTitlecase(Py_UNICODE ch)
|
2000-03-10 18:52:46 -04:00
|
|
|
{
|
2000-09-25 18:48:13 -03:00
|
|
|
const _PyUnicode_TypeRecord *ctype = gettyperecord(ch);
|
|
|
|
|
|
|
|
return (ctype->flags & TITLE_MASK) != 0;
|
2000-03-10 18:52:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Returns the integer decimal (0-9) for Unicode characters having
|
|
|
|
this property, -1 otherwise. */
|
|
|
|
|
2001-06-27 19:08:26 -03:00
|
|
|
int _PyUnicode_ToDecimalDigit(Py_UNICODE ch)
|
2000-03-10 18:52:46 -04:00
|
|
|
{
|
2000-09-25 18:48:13 -03:00
|
|
|
const _PyUnicode_TypeRecord *ctype = gettyperecord(ch);
|
|
|
|
|
|
|
|
return (ctype->flags & DECIMAL_MASK) ? ctype->decimal : -1;
|
2000-03-10 18:52:46 -04:00
|
|
|
}
|
|
|
|
|
2001-06-27 19:08:26 -03:00
|
|
|
int _PyUnicode_IsDecimalDigit(Py_UNICODE ch)
|
2000-03-10 18:52:46 -04:00
|
|
|
{
|
|
|
|
if (_PyUnicode_ToDecimalDigit(ch) < 0)
|
2010-05-09 12:15:40 -03:00
|
|
|
return 0;
|
2000-03-10 18:52:46 -04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Returns the integer digit (0-9) for Unicode characters having
|
|
|
|
this property, -1 otherwise. */
|
|
|
|
|
2001-06-27 19:08:26 -03:00
|
|
|
int _PyUnicode_ToDigit(Py_UNICODE ch)
|
2000-03-10 18:52:46 -04:00
|
|
|
{
|
2000-09-25 18:48:13 -03:00
|
|
|
const _PyUnicode_TypeRecord *ctype = gettyperecord(ch);
|
|
|
|
|
|
|
|
return (ctype->flags & DIGIT_MASK) ? ctype->digit : -1;
|
2000-03-10 18:52:46 -04:00
|
|
|
}
|
|
|
|
|
2001-06-27 19:08:26 -03:00
|
|
|
int _PyUnicode_IsDigit(Py_UNICODE ch)
|
2000-03-10 18:52:46 -04:00
|
|
|
{
|
|
|
|
if (_PyUnicode_ToDigit(ch) < 0)
|
2010-05-09 12:15:40 -03:00
|
|
|
return 0;
|
2000-03-10 18:52:46 -04:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Returns the numeric value as double for Unicode characters having
|
|
|
|
this property, -1.0 otherwise. */
|
|
|
|
|
2000-09-25 18:48:13 -03:00
|
|
|
/* TODO: replace with unicodetype_db.h table */
|
|
|
|
|
2001-06-27 19:08:26 -03:00
|
|
|
double _PyUnicode_ToNumeric(Py_UNICODE ch)
|
2000-03-10 18:52:46 -04:00
|
|
|
{
|
|
|
|
switch (ch) {
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x0F33:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) -1 / 2;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x17F0:
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x3007:
|
2006-05-27 05:36:52 -03:00
|
|
|
#ifdef Py_UNICODE_WIDE
|
|
|
|
case 0x1018A:
|
|
|
|
#endif
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 0;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x09F4:
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x17F1:
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x215F:
|
|
|
|
case 0x2160:
|
|
|
|
case 0x2170:
|
|
|
|
case 0x3021:
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x3192:
|
|
|
|
case 0x3220:
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x3280:
|
2006-05-27 05:36:52 -03:00
|
|
|
#ifdef Py_UNICODE_WIDE
|
|
|
|
case 0x10107:
|
|
|
|
case 0x10142:
|
|
|
|
case 0x10158:
|
|
|
|
case 0x10159:
|
|
|
|
case 0x1015A:
|
|
|
|
case 0x10320:
|
|
|
|
case 0x103D1:
|
|
|
|
#endif
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 1;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x00BD:
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x0F2A:
|
|
|
|
case 0x2CFD:
|
|
|
|
#ifdef Py_UNICODE_WIDE
|
|
|
|
case 0x10141:
|
|
|
|
case 0x10175:
|
|
|
|
case 0x10176:
|
|
|
|
#endif
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 1 / 2;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x2153:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 1 / 3;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x00BC:
|
2006-05-27 05:36:52 -03:00
|
|
|
#ifdef Py_UNICODE_WIDE
|
|
|
|
case 0x10140:
|
|
|
|
#endif
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 1 / 4;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x2155:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 1 / 5;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x2159:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 1 / 6;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x215B:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 1 / 8;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x0BF0:
|
|
|
|
case 0x1372:
|
|
|
|
case 0x2169:
|
|
|
|
case 0x2179:
|
|
|
|
case 0x2469:
|
|
|
|
case 0x247D:
|
|
|
|
case 0x2491:
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x24FE:
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x277F:
|
|
|
|
case 0x2789:
|
|
|
|
case 0x2793:
|
|
|
|
case 0x3038:
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x3229:
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x3289:
|
2006-05-27 05:36:52 -03:00
|
|
|
#ifdef Py_UNICODE_WIDE
|
|
|
|
case 0x10110:
|
|
|
|
case 0x10149:
|
|
|
|
case 0x10150:
|
|
|
|
case 0x10157:
|
|
|
|
case 0x10160:
|
|
|
|
case 0x10161:
|
|
|
|
case 0x10162:
|
|
|
|
case 0x10163:
|
|
|
|
case 0x10164:
|
|
|
|
case 0x10322:
|
|
|
|
case 0x103D3:
|
|
|
|
case 0x10A44:
|
|
|
|
#endif
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 10;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x0BF1:
|
|
|
|
case 0x137B:
|
|
|
|
case 0x216D:
|
|
|
|
case 0x217D:
|
2006-05-27 05:36:52 -03:00
|
|
|
#ifdef Py_UNICODE_WIDE
|
|
|
|
case 0x10119:
|
|
|
|
case 0x1014B:
|
|
|
|
case 0x10152:
|
|
|
|
case 0x1016A:
|
|
|
|
case 0x103D5:
|
|
|
|
case 0x10A46:
|
|
|
|
#endif
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 100;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x0BF2:
|
|
|
|
case 0x216F:
|
|
|
|
case 0x217F:
|
|
|
|
case 0x2180:
|
2006-05-27 05:36:52 -03:00
|
|
|
#ifdef Py_UNICODE_WIDE
|
|
|
|
case 0x10122:
|
|
|
|
case 0x1014D:
|
|
|
|
case 0x10154:
|
|
|
|
case 0x10171:
|
|
|
|
case 0x10A47:
|
|
|
|
#endif
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 1000;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x137C:
|
|
|
|
case 0x2182:
|
2006-05-27 05:36:52 -03:00
|
|
|
#ifdef Py_UNICODE_WIDE
|
|
|
|
case 0x1012B:
|
|
|
|
case 0x10155:
|
|
|
|
#endif
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 10000;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x216A:
|
|
|
|
case 0x217A:
|
|
|
|
case 0x246A:
|
|
|
|
case 0x247E:
|
|
|
|
case 0x2492:
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x24EB:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 11;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x0F2F:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 11 / 2;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x216B:
|
|
|
|
case 0x217B:
|
|
|
|
case 0x246B:
|
|
|
|
case 0x247F:
|
|
|
|
case 0x2493:
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x24EC:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 12;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x246C:
|
|
|
|
case 0x2480:
|
|
|
|
case 0x2494:
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x24ED:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 13;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x0F30:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 13 / 2;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x246D:
|
|
|
|
case 0x2481:
|
|
|
|
case 0x2495:
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x24EE:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 14;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x246E:
|
|
|
|
case 0x2482:
|
|
|
|
case 0x2496:
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x24EF:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 15;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x0F31:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 15 / 2;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x09F9:
|
|
|
|
case 0x246F:
|
|
|
|
case 0x2483:
|
|
|
|
case 0x2497:
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x24F0:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 16;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x16EE:
|
|
|
|
case 0x2470:
|
|
|
|
case 0x2484:
|
|
|
|
case 0x2498:
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x24F1:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 17;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x0F32:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 17 / 2;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x16EF:
|
|
|
|
case 0x2471:
|
|
|
|
case 0x2485:
|
|
|
|
case 0x2499:
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x24F2:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 18;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x16F0:
|
|
|
|
case 0x2472:
|
|
|
|
case 0x2486:
|
|
|
|
case 0x249A:
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x24F3:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 19;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x09F5:
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x17F2:
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x2161:
|
|
|
|
case 0x2171:
|
|
|
|
case 0x3022:
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x3193:
|
|
|
|
case 0x3221:
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x3281:
|
2006-05-27 05:36:52 -03:00
|
|
|
#ifdef Py_UNICODE_WIDE
|
|
|
|
case 0x10108:
|
|
|
|
case 0x1015B:
|
|
|
|
case 0x1015C:
|
|
|
|
case 0x1015D:
|
|
|
|
case 0x1015E:
|
|
|
|
case 0x103D2:
|
|
|
|
#endif
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 2;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x2154:
|
2006-05-27 05:36:52 -03:00
|
|
|
#ifdef Py_UNICODE_WIDE
|
|
|
|
case 0x10177:
|
|
|
|
#endif
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 2 / 3;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x2156:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 2 / 5;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x1373:
|
|
|
|
case 0x2473:
|
|
|
|
case 0x2487:
|
|
|
|
case 0x249B:
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x24F4:
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x3039:
|
2006-05-27 05:36:52 -03:00
|
|
|
#ifdef Py_UNICODE_WIDE
|
|
|
|
case 0x10111:
|
|
|
|
case 0x103D4:
|
|
|
|
case 0x10A45:
|
|
|
|
#endif
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 20;
|
2006-05-27 05:36:52 -03:00
|
|
|
#ifdef Py_UNICODE_WIDE
|
|
|
|
case 0x1011A:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 200;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x10123:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 2000;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x1012C:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 20000;
|
2006-05-27 05:36:52 -03:00
|
|
|
#endif
|
|
|
|
case 0x3251:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 21;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x3252:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 22;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x3253:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 23;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x3254:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 24;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x3255:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 25;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x3256:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 26;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x3257:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 27;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x3258:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 28;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x3259:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 29;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x09F6:
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x17F3:
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x2162:
|
|
|
|
case 0x2172:
|
|
|
|
case 0x3023:
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x3194:
|
|
|
|
case 0x3222:
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x3282:
|
2006-05-27 05:36:52 -03:00
|
|
|
#ifdef Py_UNICODE_WIDE
|
|
|
|
case 0x10109:
|
|
|
|
#endif
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 3;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x0F2B:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 3 / 2;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x00BE:
|
2006-05-27 05:36:52 -03:00
|
|
|
#ifdef Py_UNICODE_WIDE
|
|
|
|
case 0x10178:
|
|
|
|
#endif
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 3 / 4;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x2157:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 3 / 5;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x215C:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 3 / 8;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x1374:
|
|
|
|
case 0x303A:
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x325A:
|
|
|
|
#ifdef Py_UNICODE_WIDE
|
|
|
|
case 0x10112:
|
|
|
|
case 0x10165:
|
|
|
|
#endif
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 30;
|
2006-05-27 05:36:52 -03:00
|
|
|
#ifdef Py_UNICODE_WIDE
|
|
|
|
case 0x1011B:
|
|
|
|
case 0x1016B:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 300;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x10124:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 3000;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x1012D:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 30000;
|
2006-05-27 05:36:52 -03:00
|
|
|
#endif
|
|
|
|
case 0x325B:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 31;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x325C:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 32;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x325D:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 33;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x325E:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 34;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x325F:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 35;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x32B1:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 36;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x32B2:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 37;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x32B3:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 38;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x32B4:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 39;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x09F7:
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x17F4:
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x2163:
|
|
|
|
case 0x2173:
|
|
|
|
case 0x3024:
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x3195:
|
|
|
|
case 0x3223:
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x3283:
|
2006-05-27 05:36:52 -03:00
|
|
|
#ifdef Py_UNICODE_WIDE
|
|
|
|
case 0x1010A:
|
|
|
|
#endif
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 4;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x2158:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 4 / 5;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x1375:
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x32B5:
|
|
|
|
#ifdef Py_UNICODE_WIDE
|
|
|
|
case 0x10113:
|
|
|
|
#endif
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 40;
|
2006-05-27 05:36:52 -03:00
|
|
|
#ifdef Py_UNICODE_WIDE
|
|
|
|
case 0x1011C:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 400;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x10125:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 4000;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x1012E:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 40000;
|
2006-05-27 05:36:52 -03:00
|
|
|
#endif
|
|
|
|
case 0x32B6:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 41;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x32B7:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 42;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x32B8:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 43;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x32B9:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 44;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x32BA:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 45;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x32BB:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 46;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x32BC:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 47;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x32BD:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 48;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x32BE:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 49;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x17F5:
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x2164:
|
|
|
|
case 0x2174:
|
|
|
|
case 0x3025:
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x3224:
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x3284:
|
2006-05-27 05:36:52 -03:00
|
|
|
#ifdef Py_UNICODE_WIDE
|
|
|
|
case 0x1010B:
|
|
|
|
case 0x10143:
|
|
|
|
case 0x10148:
|
|
|
|
case 0x1014F:
|
|
|
|
case 0x1015F:
|
|
|
|
case 0x10173:
|
|
|
|
case 0x10321:
|
|
|
|
#endif
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 5;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x0F2C:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 5 / 2;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x215A:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 5 / 6;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x215D:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 5 / 8;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x1376:
|
|
|
|
case 0x216C:
|
|
|
|
case 0x217C:
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x32BF:
|
|
|
|
#ifdef Py_UNICODE_WIDE
|
|
|
|
case 0x10114:
|
|
|
|
case 0x10144:
|
|
|
|
case 0x1014A:
|
|
|
|
case 0x10151:
|
|
|
|
case 0x10166:
|
|
|
|
case 0x10167:
|
|
|
|
case 0x10168:
|
|
|
|
case 0x10169:
|
|
|
|
case 0x10174:
|
|
|
|
case 0x10323:
|
|
|
|
#endif
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 50;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x216E:
|
|
|
|
case 0x217E:
|
2006-05-27 05:36:52 -03:00
|
|
|
#ifdef Py_UNICODE_WIDE
|
|
|
|
case 0x1011D:
|
|
|
|
case 0x10145:
|
|
|
|
case 0x1014C:
|
|
|
|
case 0x10153:
|
|
|
|
case 0x1016C:
|
|
|
|
case 0x1016D:
|
|
|
|
case 0x1016E:
|
|
|
|
case 0x1016F:
|
|
|
|
case 0x10170:
|
|
|
|
#endif
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 500;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x2181:
|
2006-05-27 05:36:52 -03:00
|
|
|
#ifdef Py_UNICODE_WIDE
|
|
|
|
case 0x10126:
|
|
|
|
case 0x10146:
|
|
|
|
case 0x1014E:
|
|
|
|
case 0x10172:
|
|
|
|
#endif
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 5000;
|
2006-05-27 05:36:52 -03:00
|
|
|
#ifdef Py_UNICODE_WIDE
|
|
|
|
case 0x1012F:
|
|
|
|
case 0x10147:
|
|
|
|
case 0x10156:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 50000;
|
2006-05-27 05:36:52 -03:00
|
|
|
#endif
|
|
|
|
case 0x17F6:
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x2165:
|
|
|
|
case 0x2175:
|
|
|
|
case 0x3026:
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x3225:
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x3285:
|
2006-05-27 05:36:52 -03:00
|
|
|
#ifdef Py_UNICODE_WIDE
|
|
|
|
case 0x1010C:
|
|
|
|
#endif
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 6;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x1377:
|
2006-05-27 05:36:52 -03:00
|
|
|
#ifdef Py_UNICODE_WIDE
|
|
|
|
case 0x10115:
|
|
|
|
#endif
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 60;
|
2006-05-27 05:36:52 -03:00
|
|
|
#ifdef Py_UNICODE_WIDE
|
|
|
|
case 0x1011E:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 600;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x10127:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 6000;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x10130:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 60000;
|
2006-05-27 05:36:52 -03:00
|
|
|
#endif
|
|
|
|
case 0x17F7:
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x2166:
|
|
|
|
case 0x2176:
|
|
|
|
case 0x3027:
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x3226:
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x3286:
|
2006-05-27 05:36:52 -03:00
|
|
|
#ifdef Py_UNICODE_WIDE
|
|
|
|
case 0x1010D:
|
|
|
|
#endif
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 7;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x0F2D:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 7 / 2;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x215E:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 7 / 8;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x1378:
|
2006-05-27 05:36:52 -03:00
|
|
|
#ifdef Py_UNICODE_WIDE
|
|
|
|
case 0x10116:
|
|
|
|
#endif
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 70;
|
2006-05-27 05:36:52 -03:00
|
|
|
#ifdef Py_UNICODE_WIDE
|
|
|
|
case 0x1011F:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 700;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x10128:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 7000;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x10131:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 70000;
|
2006-05-27 05:36:52 -03:00
|
|
|
#endif
|
|
|
|
case 0x17F8:
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x2167:
|
|
|
|
case 0x2177:
|
|
|
|
case 0x3028:
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x3227:
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x3287:
|
2006-05-27 05:36:52 -03:00
|
|
|
#ifdef Py_UNICODE_WIDE
|
|
|
|
case 0x1010E:
|
|
|
|
#endif
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 8;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x1379:
|
2006-05-27 05:36:52 -03:00
|
|
|
#ifdef Py_UNICODE_WIDE
|
|
|
|
case 0x10117:
|
|
|
|
#endif
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 80;
|
2006-05-27 05:36:52 -03:00
|
|
|
#ifdef Py_UNICODE_WIDE
|
|
|
|
case 0x10120:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 800;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x10129:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 8000;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x10132:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 80000;
|
2006-05-27 05:36:52 -03:00
|
|
|
#endif
|
|
|
|
case 0x17F9:
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x2168:
|
|
|
|
case 0x2178:
|
|
|
|
case 0x3029:
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x3228:
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x3288:
|
2006-05-27 05:36:52 -03:00
|
|
|
#ifdef Py_UNICODE_WIDE
|
|
|
|
case 0x1010F:
|
|
|
|
#endif
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 9;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x0F2E:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 9 / 2;
|
2000-03-10 18:52:46 -04:00
|
|
|
case 0x137A:
|
2006-05-27 05:36:52 -03:00
|
|
|
#ifdef Py_UNICODE_WIDE
|
|
|
|
case 0x10118:
|
|
|
|
#endif
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 90;
|
2006-05-27 05:36:52 -03:00
|
|
|
#ifdef Py_UNICODE_WIDE
|
|
|
|
case 0x10121:
|
|
|
|
case 0x1034A:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 900;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x1012A:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 9000;
|
2006-05-27 05:36:52 -03:00
|
|
|
case 0x10133:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) 90000;
|
2006-05-27 05:36:52 -03:00
|
|
|
#endif
|
2000-03-10 18:52:46 -04:00
|
|
|
default:
|
2010-05-09 12:15:40 -03:00
|
|
|
return (double) _PyUnicode_ToDigit(ch);
|
2000-03-10 18:52:46 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-06-27 19:08:26 -03:00
|
|
|
int _PyUnicode_IsNumeric(Py_UNICODE ch)
|
2000-03-10 18:52:46 -04:00
|
|
|
{
|
2006-05-27 05:36:52 -03:00
|
|
|
return _PyUnicode_ToNumeric(ch) != -1.0;
|
2000-03-10 18:52:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef WANT_WCTYPE_FUNCTIONS
|
|
|
|
|
2000-04-11 12:39:02 -03:00
|
|
|
/* Returns 1 for Unicode characters having the bidirectional type
|
|
|
|
'WS', 'B' or 'S' or the category 'Zs', 0 otherwise. */
|
2000-03-10 18:52:46 -04:00
|
|
|
|
2005-10-20 16:06:35 -03:00
|
|
|
int _PyUnicode_IsWhitespace(register const Py_UNICODE ch)
|
2000-03-10 18:52:46 -04:00
|
|
|
{
|
2005-10-20 16:06:35 -03:00
|
|
|
switch (ch) {
|
|
|
|
case 0x0009: /* HORIZONTAL TABULATION */
|
|
|
|
case 0x000A: /* LINE FEED */
|
|
|
|
case 0x000B: /* VERTICAL TABULATION */
|
|
|
|
case 0x000C: /* FORM FEED */
|
|
|
|
case 0x000D: /* CARRIAGE RETURN */
|
|
|
|
case 0x001C: /* FILE SEPARATOR */
|
|
|
|
case 0x001D: /* GROUP SEPARATOR */
|
|
|
|
case 0x001E: /* RECORD SEPARATOR */
|
|
|
|
case 0x001F: /* UNIT SEPARATOR */
|
|
|
|
case 0x0020: /* SPACE */
|
|
|
|
case 0x0085: /* NEXT LINE */
|
|
|
|
case 0x00A0: /* NO-BREAK SPACE */
|
|
|
|
case 0x1680: /* OGHAM SPACE MARK */
|
|
|
|
case 0x2000: /* EN QUAD */
|
|
|
|
case 0x2001: /* EM QUAD */
|
|
|
|
case 0x2002: /* EN SPACE */
|
|
|
|
case 0x2003: /* EM SPACE */
|
|
|
|
case 0x2004: /* THREE-PER-EM SPACE */
|
|
|
|
case 0x2005: /* FOUR-PER-EM SPACE */
|
|
|
|
case 0x2006: /* SIX-PER-EM SPACE */
|
|
|
|
case 0x2007: /* FIGURE SPACE */
|
|
|
|
case 0x2008: /* PUNCTUATION SPACE */
|
|
|
|
case 0x2009: /* THIN SPACE */
|
|
|
|
case 0x200A: /* HAIR SPACE */
|
|
|
|
case 0x200B: /* ZERO WIDTH SPACE */
|
|
|
|
case 0x2028: /* LINE SEPARATOR */
|
|
|
|
case 0x2029: /* PARAGRAPH SEPARATOR */
|
|
|
|
case 0x202F: /* NARROW NO-BREAK SPACE */
|
|
|
|
case 0x205F: /* MEDIUM MATHEMATICAL SPACE */
|
|
|
|
case 0x3000: /* IDEOGRAPHIC SPACE */
|
2010-05-09 12:15:40 -03:00
|
|
|
return 1;
|
2005-10-20 16:06:35 -03:00
|
|
|
default:
|
2010-05-09 12:15:40 -03:00
|
|
|
return 0;
|
2005-10-20 16:06:35 -03:00
|
|
|
}
|
2000-03-10 18:52:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Returns 1 for Unicode characters having the category 'Ll', 0
|
|
|
|
otherwise. */
|
|
|
|
|
2001-06-27 19:08:26 -03:00
|
|
|
int _PyUnicode_IsLowercase(Py_UNICODE ch)
|
2000-03-10 18:52:46 -04:00
|
|
|
{
|
2000-09-25 18:48:13 -03:00
|
|
|
const _PyUnicode_TypeRecord *ctype = gettyperecord(ch);
|
|
|
|
|
|
|
|
return (ctype->flags & LOWER_MASK) != 0;
|
2000-03-10 18:52:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Returns 1 for Unicode characters having the category 'Lu', 0
|
|
|
|
otherwise. */
|
|
|
|
|
2001-06-27 19:08:26 -03:00
|
|
|
int _PyUnicode_IsUppercase(Py_UNICODE ch)
|
2000-03-10 18:52:46 -04:00
|
|
|
{
|
2000-09-25 18:48:13 -03:00
|
|
|
const _PyUnicode_TypeRecord *ctype = gettyperecord(ch);
|
|
|
|
|
|
|
|
return (ctype->flags & UPPER_MASK) != 0;
|
2000-03-10 18:52:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Returns the uppercase Unicode characters corresponding to ch or just
|
|
|
|
ch if no uppercase mapping is known. */
|
|
|
|
|
2001-06-27 19:08:26 -03:00
|
|
|
Py_UNICODE _PyUnicode_ToUppercase(Py_UNICODE ch)
|
2000-03-10 18:52:46 -04:00
|
|
|
{
|
2000-09-25 18:48:13 -03:00
|
|
|
const _PyUnicode_TypeRecord *ctype = gettyperecord(ch);
|
2002-10-18 13:40:36 -03:00
|
|
|
int delta = ctype->upper;
|
2008-09-10 10:38:12 -03:00
|
|
|
if (ctype->flags & NODELTA_MASK)
|
2010-05-09 12:15:40 -03:00
|
|
|
return delta;
|
2002-10-18 13:40:36 -03:00
|
|
|
if (delta >= 32768)
|
2010-05-09 12:15:40 -03:00
|
|
|
delta -= 65536;
|
2002-10-18 13:40:36 -03:00
|
|
|
return ch + delta;
|
2000-03-10 18:52:46 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Returns the lowercase Unicode characters corresponding to ch or just
|
|
|
|
ch if no lowercase mapping is known. */
|
|
|
|
|
2001-06-27 19:08:26 -03:00
|
|
|
Py_UNICODE _PyUnicode_ToLowercase(Py_UNICODE ch)
|
2000-03-10 18:52:46 -04:00
|
|
|
{
|
2000-09-25 18:48:13 -03:00
|
|
|
const _PyUnicode_TypeRecord *ctype = gettyperecord(ch);
|
2002-10-18 13:40:36 -03:00
|
|
|
int delta = ctype->lower;
|
2008-09-10 10:38:12 -03:00
|
|
|
if (ctype->flags & NODELTA_MASK)
|
2010-05-09 12:15:40 -03:00
|
|
|
return delta;
|
2002-10-18 13:40:36 -03:00
|
|
|
if (delta >= 32768)
|
2010-05-09 12:15:40 -03:00
|
|
|
delta -= 65536;
|
2002-10-18 13:40:36 -03:00
|
|
|
return ch + delta;
|
2000-03-10 18:52:46 -04:00
|
|
|
}
|
|
|
|
|
2000-07-05 06:48:59 -03:00
|
|
|
/* Returns 1 for Unicode characters having the category 'Ll', 'Lu', 'Lt',
|
|
|
|
'Lo' or 'Lm', 0 otherwise. */
|
|
|
|
|
2001-06-27 19:08:26 -03:00
|
|
|
int _PyUnicode_IsAlpha(Py_UNICODE ch)
|
2000-07-05 06:48:59 -03:00
|
|
|
{
|
2000-09-25 18:48:13 -03:00
|
|
|
const _PyUnicode_TypeRecord *ctype = gettyperecord(ch);
|
2000-07-05 06:48:59 -03:00
|
|
|
|
2000-09-25 18:48:13 -03:00
|
|
|
return (ctype->flags & ALPHA_MASK) != 0;
|
2000-07-05 06:48:59 -03:00
|
|
|
}
|
|
|
|
|
2000-03-10 18:52:46 -04:00
|
|
|
#else
|
|
|
|
|
|
|
|
/* Export the interfaces using the wchar_t type for portability
|
|
|
|
reasons: */
|
|
|
|
|
2001-06-27 19:08:26 -03:00
|
|
|
int _PyUnicode_IsWhitespace(Py_UNICODE ch)
|
2000-03-10 18:52:46 -04:00
|
|
|
{
|
|
|
|
return iswspace(ch);
|
|
|
|
}
|
|
|
|
|
2001-06-27 19:08:26 -03:00
|
|
|
int _PyUnicode_IsLowercase(Py_UNICODE ch)
|
2000-03-10 18:52:46 -04:00
|
|
|
{
|
|
|
|
return iswlower(ch);
|
|
|
|
}
|
|
|
|
|
2001-06-27 19:08:26 -03:00
|
|
|
int _PyUnicode_IsUppercase(Py_UNICODE ch)
|
2000-03-10 18:52:46 -04:00
|
|
|
{
|
|
|
|
return iswupper(ch);
|
|
|
|
}
|
|
|
|
|
2001-06-27 19:08:26 -03:00
|
|
|
Py_UNICODE _PyUnicode_ToLowercase(Py_UNICODE ch)
|
2000-03-10 18:52:46 -04:00
|
|
|
{
|
|
|
|
return towlower(ch);
|
|
|
|
}
|
|
|
|
|
2001-06-27 19:08:26 -03:00
|
|
|
Py_UNICODE _PyUnicode_ToUppercase(Py_UNICODE ch)
|
2000-03-10 18:52:46 -04:00
|
|
|
{
|
|
|
|
return towupper(ch);
|
|
|
|
}
|
|
|
|
|
2001-06-27 19:08:26 -03:00
|
|
|
int _PyUnicode_IsAlpha(Py_UNICODE ch)
|
2000-07-05 06:48:59 -03:00
|
|
|
{
|
|
|
|
return iswalpha(ch);
|
|
|
|
}
|
|
|
|
|
2000-03-10 18:52:46 -04:00
|
|
|
#endif
|