Back to Projects
TUIX v0.6Beta

Last Updated: 2026-08-14

Unicode, Interned Symbols & Text Measurement

TUIX v0.6 provides a complete Unicode text pipeline designed for zero-allocation rendering, grapheme cluster iteration, and accurate terminal cell column counting. In terminal user interfaces, character byte length, Unicode codepoint count, and visual terminal cell width often differ; TUIX resolves this natively.

Interned Symbol Architecture (TuixSymbol)

Every cell in a `TuixPixel` buffer references an immutable interned UTF-8 symbol identifier (`TuixSymbol`). Common ASCII characters use static global symbol pointers, while multi-byte UTF-8 sequences and grapheme clusters are interned in a thread-safe native pool. This completely eliminates dynamic heap allocations during frame rendering and diffing.

Grapheme Cluster Segmentation & Codepoint Classification

Classification FunctionUnicode CategoryVisual Width Impact
tuix.tuix_codepoint_cell_width(cp)Standard CodepointReturns 0 (non-printing/combining), 1 (standard Latin/symbols), or 2 (wide/CJK).
tuix.tuix_codepoint_is_combining(cp)Combining DiacriticsWidth 0; attaches directly to preceding base character cluster.
tuix.tuix_codepoint_is_wide(cp)East Asian Wide / FullwidthWidth 2; occupies two consecutive terminal screen columns.
tuix.tuix_codepoint_is_emoji(cp)Emoji / PictographsWidth 2; handles emoji modifiers, ZWJ sequences, and regional indicators.
tuix.tuix_codepoint_is_box(cp)Box-Drawing GlyphsWidth 1; participates in continuous border and frame rasterization.

128-byte UTF-8 Keyboard Payload

Keyboard event structures in v0.6 contain a dedicated 128-byte `payload_utf8` buffer. When pasting text, typing accented international characters, or using Input Method Editors (IME), multi-byte UTF-8 characters are captured and dispatched intact to interactive input widgets.

from tuix.core import tuix

text = 'TUIX 🚀 (Český text)'.encode('utf-8')

# Calculate visible terminal cell columns (not byte length!)
visible_width = tuix.tuix_text_cell_count(text)
print(f'Byte length: {len(text)}, Visual width: {visible_width}')