2 ms·
$width-in-terminal = $text.chars; ^- very likely wrong. wcswidth computes the cell-width (or column-count) of a Unicode string, which is unrelated to the coun
by dom0 10y ago
$width-in-terminal = $text.chars;
^- very likely wrong.
wcswidth computes the cell-width (or column-count) of a Unicode string, which is unrelated to the count of graphemes, EGCs or code points. For example, Latin characters are one cell/column wide, while for example many CJK characters occupy two cells/columns, while they are still one EGC.
A typical application is printing CJK things to a terminal mask, progress display or similar.
- labster 10y agoAh right. I guess we were meaning different things by width. And you're probably more correct here.