Modern uniwidth v0.1.0-beta - High-performance Unicode width calculation (3.9-46x faster)
reddit.com·1d·
Discuss: r/golang
Flag this post

Hi everyone! I’m excited to share uniwidth, a Unicode width calculation library I built for the Phoenix TUI Framework.

Why I built this

While working on Phoenix TUI, I hit a performance bottleneck with existing width calculation libraries. Terminal rendering needs to calculate character widths millions of times per second, and the overhead was noticeable. So I built uniwidth from scratch with performance as the primary goal.

What makes it fast

The library uses a tiered lookup strategy that handles ~95% of cases in O(1):

ASCII fast path (simple range check, no binary search)

Common CJK ranges (Unified Ideographs, Hangul, Hiragana/Katakana)

Common emoji ranges (Emoticons, Pictographs)

Binary search fallback…

Similar Posts

Loading similar posts...