Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

    $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.



Ah right. I guess we were meaning different things by width. And you're probably more correct here.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: