- SF #962502: Add two more methods for unicode type; width() and

iswide() for east asian width manipulation. (Inspired by David
Goodger, Reviewed by Martin v. Loewis)
- Move _PyUnicode_TypeRecord.flags to the end of the struct so that
no padding is added for UCS-4 builds. (Suggested by Martin v. Loewis)
This commit is contained in:
Hye-Shik Chang 2004-06-02 16:49:17 +00:00
parent b6568b91fd
commit 974ed7cfa5
11 changed files with 683 additions and 459 deletions

View file

@ -19,14 +19,15 @@
#define SPACE_MASK 0x20
#define TITLE_MASK 0x40
#define UPPER_MASK 0x80
#define WIDE_MASK 0x100
typedef struct {
const unsigned short flags;
const Py_UNICODE upper;
const Py_UNICODE lower;
const Py_UNICODE title;
const unsigned char decimal;
const unsigned char digit;
const unsigned short flags;
} _PyUnicode_TypeRecord;
#include "unicodetype_db.h"
@ -322,6 +323,15 @@ int _PyUnicode_IsNumeric(Py_UNICODE ch)
return 1;
}
/* Returns 1 for Unicode characters having Full or Wide width, 0 otherwise */
int _PyUnicode_IsWide(Py_UNICODE ch)
{
const _PyUnicode_TypeRecord *ctype = gettyperecord(ch);
return (ctype->flags & WIDE_MASK) != 0;
}
#ifndef WANT_WCTYPE_FUNCTIONS
/* Returns 1 for Unicode characters having the bidirectional type