Skip to content
FutureBlitz

    Install

    Import std.text.unicode

    DisplayWidth

    std.text.unicode

    function

    Public Function DisplayWidth(c: Char): Int

    The columns c takes in a terminal: 2 for a wide one, like "中" or most emoji, 0 for a mark or a control character, and 1 for the rest.

    std/text/unicode.fb, line 149

    function

    Public Function DisplayWidth(text: String): Int

    The columns text takes in a terminal, each grapheme cluster as many as its widest character, so "e" with its accent is 1, and an emoji made of several is 2. A flag is 2, and so is a character that U+FE0F asks to be drawn as emoji, like "\u{2764}\u{FE0F}", though it's 1 alone.

    std/text/unicode.fb, line 154

    Report an issue with this page or with FutureBlitz on GitHub.