MCPcopy Index your code
hub / github.com/RustPython/RustPython / str_width

Function str_width

Lib/_pyrepl/utils.py:9–15  ·  view source on GitHub ↗
(c: str)

Source from the content-addressed store, hash-verified

7
8@functools.cache
9def str_width(c: str) -> int:
10 if ord(c) < 128:
11 return 1
12 w = unicodedata.east_asian_width(c)
13 if w in ('N', 'Na', 'H', 'A'):
14 return 1
15 return 2
16
17
18def wlen(s: str) -> int:

Callers 3

disp_strFunction · 0.85
wlenMethod · 0.85
wlenFunction · 0.85

Calls 2

ordFunction · 0.85
east_asian_widthMethod · 0.80

Tested by

no test coverage detected