Unicode character Width

AbsoluteTelnet/SSH has three Unicode width modes: Legacy, Notcurses and Grapheme. They decide how many columns each character takes, which characters are kept together as one unit, and where the cursor lands after writing text. Applications and the terminal have to agree on these widths, or text and borders drift out of line.

Choose the mode under Connection Properties โ†’ VT Options โ†’ Width. Legacy is the default. Version 14.24 adds the Notcurses mode; the mode previously called Full is now called Grapheme, and sessions saved with Full open in Grapheme.

All three modes use the Unicode 18 character tables.

Legacy (xterm)

  • Matches xterm’s own width table (xterm -mk_width), character by character.
  • Each character takes its own width; a zero-width combining mark goes onto the cell before it.
  • Emoji sequences are not combined: each emoji in a sequence takes its own columns.
  • Best for: classic terminal applications, such as vi, vim, shells and ncurses programs.

Notcurses

  • Groups characters into clusters and gives each cluster the width of its first character, the layout the notcurses library expects.
  • Combining characters (aฬฑ), emoji with modifiers (๐Ÿ‘จ๐Ÿฟ) and ZWJ sequences (๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ) form one unit, as in Grapheme mode.
  • Differences from Grapheme mode:
    • Variation selectors don’t change the width (โŒš๏ธŽ and โŒš are the same width).
    • Spacing combining characters add no column (เค•เคพ takes one column).
    • Regional indicators and conjuncts are not combined (๐Ÿ‡ฉ๐Ÿ‡ช, เค•เฅเคค).
  • Best for: applications built on notcurses.

Grapheme (2027, wcwidth, jquast)

  • Text is interpreted as grapheme clusters, not individual code points.
  • Multi-codepoint sequences are treated as a single unit, including:
    • Combining characters (aฬฑ)
    • Emoji with modifiers (๐Ÿ‘จ๐Ÿฟ)
    • ZWJ sequences (๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ)
    • Forward joining characters (Aุœุจ)
    • Variation selectors, VS15 and VS16 (โŒš๏ธŽ vs โŒš)
    • Regional indicators (๐Ÿ‡ฉ๐Ÿ‡ช)
    • Spacing combining characters (เค•เคพ)
    • Flags and tags (๐Ÿด๓ ง๓ ข๓ ณ๓ ฃ๓ ด๓ ฟ)
    • Complex scripts and viramas (เค•เฅเคค)
  • Cursor movement and selection respect cluster boundaries.
  • Copy and paste preserve valid, complete Unicode text.
  • Follows Jeff Quast’s wcwidth, and scores 100% in ucs-detect.
  • Best for: modern applications that request it, such as Neovim, and programs using the Python wcwidth or blessed libraries.

Switching from the host

Applications switch to Grapheme mode with DEC private mode 2027:

  • Enable Grapheme: ESC [ ? 2027 h
  • Return to the configured mode: ESC [ ? 2027 l
  • Query: ESC [ ? 2027 $ p answers 1 while Grapheme is in effect, otherwise 2.

Mode 2027 changes only the current connection, not the saved setting. It is cleared by a terminal reset (RIS or DECSTR), when the connection ends, and when you change the Width setting yourself.

Summary

ModeWidthsBest for
Legacy (xterm)Per character, as xtermClassic terminal applications
NotcursesClusters at the width of their first characternotcurses applications
Grapheme (2027, wcwidth, jquast)Grapheme clusters, as wcwidthNeovim, wcwidth and blessed applications

Leave a Comment

Your email address will not be published. Required fields are marked *