mirror of
https://github.com/python/cpython.git
synced 2025-10-25 18:54:53 +00:00
fix: address comments
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
This commit is contained in:
parent
30e130fa5a
commit
07aa4bcc8a
2 changed files with 9 additions and 1 deletions
|
|
@ -64,7 +64,12 @@ def str_width(c: str) -> int:
|
|||
if ord(c) < 128:
|
||||
return 1
|
||||
# gh-139246 for zero-width joiner and combining characters
|
||||
if unicodedata.combining(c) or unicodedata.category(c) == "Cf":
|
||||
category = unicodedata.category(c)
|
||||
if unicodedata.combining(c):
|
||||
return 0
|
||||
if category == "Cf" and c != "\u00ad":
|
||||
return 0
|
||||
if "\u2028" <= c <= "\u2029":
|
||||
return 0
|
||||
w = unicodedata.east_asian_width(c)
|
||||
if w in ("N", "Na", "H", "A"):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue