File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,12 @@ def str_width(c: str) -> int:
64
64
if ord (c ) < 128 :
65
65
return 1
66
66
# gh-139246 for zero-width joiner and combining characters
67
- if unicodedata .combining (c ) or unicodedata .category (c ) == "Cf" :
67
+ category = unicodedata .category (c )
68
+ if unicodedata .combining (c ):
69
+ return 0
70
+ if category == "Cf" and c != "\u00ad " :
71
+ return 0
72
+ if "\u2028 " <= c <= "\u2029 " :
68
73
return 0
69
74
w = unicodedata .east_asian_width (c )
70
75
if w in ("N" , "Na" , "H" , "A" ):
Original file line number Diff line number Diff line change @@ -15,13 +15,16 @@ def test_str_width(self):
15
15
'\uffb9 ' ,
16
16
'\N{LATIN SMALL LETTER E WITH ACUTE} ' , # é
17
17
'\N{LATIN SMALL LETTER E WITH CEDILLA} ' , # ȩ
18
+ '\u00ad ' ,
18
19
]
19
20
for c in characters :
20
21
self .assertEqual (str_width (c ), 1 )
21
22
22
23
zero_width_characters = [
23
24
'\N{COMBINING ACUTE ACCENT} ' ,
24
25
'\N{ZERO WIDTH JOINER} ' ,
26
+ '\u2028 ' ,
27
+ '\u2029 ' ,
25
28
]
26
29
for c in zero_width_characters :
27
30
with self .subTest (character = c ):
You can’t perform that action at this time.
0 commit comments