[Python-checkins] python/dist/src/Tools/unicode makeunicodedata.py,
1.18, 1.19
perky at users.sourceforge.net
perky at users.sourceforge.net
Wed Aug 4 09:38:38 CEST 2004
Update of /cvsroot/python/python/dist/src/Tools/unicode
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1744/Tools/unicode
Modified Files:
makeunicodedata.py
Log Message:
SF #989185: Drop unicode.iswide() and unicode.width() and add
unicodedata.east_asian_width(). You can still implement your own
simple width() function using it like this:
def width(u):
w = 0
for c in unicodedata.normalize('NFC', u):
cwidth = unicodedata.east_asian_width(c)
if cwidth in ('W', 'F'): w += 2
else: w += 1
return w
Index: makeunicodedata.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/unicode/makeunicodedata.py,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** makeunicodedata.py 2 Jun 2004 16:49:17 -0000 1.18
--- makeunicodedata.py 4 Aug 2004 07:38:35 -0000 1.19
***************
*** 44,47 ****
--- 44,49 ----
"ON" ]
+ EASTASIANWIDTH_NAMES = [ "F", "H", "W", "Na", "A", "N" ]
+
# note: should match definitions in Objects/unicodectype.c
ALPHA_MASK = 0x01
***************
*** 53,57 ****
TITLE_MASK = 0x40
UPPER_MASK = 0x80
- WIDE_MASK = 0x100
def maketables(trace=0):
--- 55,58 ----
***************
*** 73,77 ****
def makeunicodedata(unicode, trace):
! dummy = (0, 0, 0, 0)
table = [dummy]
cache = {0: dummy}
--- 74,78 ----
def makeunicodedata(unicode, trace):
! dummy = (0, 0, 0, 0, 0)
table = [dummy]
cache = {0: dummy}
***************
*** 92,97 ****
bidirectional = BIDIRECTIONAL_NAMES.index(record[4])
mirrored = record[9] == "Y"
item = (
! category, combining, bidirectional, mirrored
)
# add entry to index and item tables
--- 93,99 ----
bidirectional = BIDIRECTIONAL_NAMES.index(record[4])
mirrored = record[9] == "Y"
+ eastasianwidth = EASTASIANWIDTH_NAMES.index(record[15])
item = (
! category, combining, bidirectional, mirrored, eastasianwidth
)
# add entry to index and item tables
***************
*** 205,209 ****
"const _PyUnicode_DatabaseRecord _PyUnicode_Database_Records[] = {"
for item in table:
! print >>fp, " {%d, %d, %d, %d}," % item
print >>fp, "};"
print >>fp
--- 207,211 ----
"const _PyUnicode_DatabaseRecord _PyUnicode_Database_Records[] = {"
for item in table:
! print >>fp, " {%d, %d, %d, %d, %d}," % item
print >>fp, "};"
print >>fp
***************
*** 240,243 ****
--- 242,251 ----
print >>fp, "};"
+ print >>fp, "const char *_PyUnicode_EastAsianWidthNames[] = {"
+ for name in EASTASIANWIDTH_NAMES:
+ print >>fp, " \"%s\"," % name
+ print >>fp, " NULL"
+ print >>fp, "};"
+
print >>fp, "static const char *decomp_prefix[] = {"
for name in decomp_prefix:
***************
*** 335,340 ****
flags |= DIGIT_MASK
digit = int(record[7])
- if record[15] in ('W', 'F'): # Wide or Full width
- flags |= WIDE_MASK
item = (
upper, lower, title, decimal, digit, flags
--- 343,346 ----
More information about the Python-checkins
mailing list