Skip to content

Unicode Support โ€‹

TUI.zig is built with full Unicode support in mind.

Grapheme Clusters โ€‹

The library correctly handles grapheme clusters, meaning complex characters (like emojis with modifiers or combined accents) are treated as single visual units.

  • "e" + "ยด" = "รฉ" (1 grapheme)
  • "๐Ÿ‘จ" + "โ€" + "๐Ÿ‘ฉ" + "โ€" + "๐Ÿ‘ง" = Family emoji (1 grapheme)

Display Width โ€‹

We use the standard wcwidth logic to determine how many terminal cells a character occupies:

  • Standard Latin: 1 cell
  • CJK Characters: 2 cells
  • Emojis: 2 cells
  • Combining marks: 0 cells (rendered atop previous)

API โ€‹

The unicode module provides utilities:

zig
const width = tui.unicode.stringWidth("Hello ๐ŸŒ");
// width = 6 (Hello) + 1 (space) + 2 (๐ŸŒ) = 9

Fonts โ€‹

Note that correct rendering ultimately depends on the user's terminal emulator and font support.

Released under the MIT License.