def onscreen_len(s):
    """Calculate the length of a unicode string on screen.

    Also account for double-width characters.
    """
    length = 0
    for ch in s:
        length += 2 if unicodedata.east_asian_width(ch) == "W" else 1

    return length
Calculate the length of a unicode string on screen.

    Also account for double-width characters.
    
src/doge/core.py