MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _display_width

Function _display_width

tools/python-3.11.9-amd64/Lib/traceback.py:633–647  ·  view source on GitHub ↗

Calculate the extra amount of width space the given source code segment might take if it were to be displayed on a fixed width output device. Supports wide unicode characters and emojis.

(line, offset)

Source from the content-addressed store, hash-verified

631_WIDE_CHAR_SPECIFIERS = "WF"
632
633def _display_width(line, offset):
634 """Calculate the extra amount of width space the given source
635 code segment might take if it were to be displayed on a fixed
636 width output device. Supports wide unicode characters and emojis."""
637
638 # Fast track for ASCII-only strings
639 if line.isascii():
640 return offset
641
642 import unicodedata
643
644 return sum(
645 2 if unicodedata.east_asian_width(char) in _WIDE_CHAR_SPECIFIERS else 1
646 for char in line[:offset]
647 )
648
649
650

Callers 1

format_frame_summaryMethod · 0.85

Calls 2

isasciiMethod · 0.80
sumFunction · 0.50

Tested by

no test coverage detected