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:
6464 if ord (c ) < 128 :
6565 return 1
6666 # 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 " :
6873 return 0
6974 w = unicodedata .east_asian_width (c )
7075 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):
1515 '\uffb9 ' ,
1616 '\N{LATIN SMALL LETTER E WITH ACUTE} ' , # é
1717 '\N{LATIN SMALL LETTER E WITH CEDILLA} ' , # ȩ
18+ '\u00ad ' ,
1819 ]
1920 for c in characters :
2021 self .assertEqual (str_width (c ), 1 )
2122
2223 zero_width_characters = [
2324 '\N{COMBINING ACUTE ACCENT} ' ,
2425 '\N{ZERO WIDTH JOINER} ' ,
26+ '\u2028 ' ,
27+ '\u2029 ' ,
2528 ]
2629 for c in zero_width_characters :
2730 with self .subTest (character = c ):
You can’t perform that action at this time.
0 commit comments