(c: str)
| 61 | |
| 62 | @functools.cache |
| 63 | def str_width(c: str) -> int: |
| 64 | if ord(c) < 128: |
| 65 | return 1 |
| 66 | # gh-139246 for zero-width joiner and combining characters |
| 67 | if unicodedata.combining(c): |
| 68 | return 0 |
| 69 | category = unicodedata.category(c) |
| 70 | if category == "Cf" and c != "\u00ad": |
| 71 | return 0 |
| 72 | w = unicodedata.east_asian_width(c) |
| 73 | if w in ("N", "Na", "H", "A"): |
| 74 | return 1 |
| 75 | return 2 |
| 76 | |
| 77 | |
| 78 | def wlen(s: str) -> int: |
no outgoing calls
searching dependent graphs…