The POSIX function wcwidth()
computes the width of a given wchar_t
when printed on a terminal. For instance, wcwidth(L'A')
returns 1
, wcwidth(L'字')
returns 2
, etc. There is also a function wcswidth()
which computes the width of an entire string—this is useful if combining accents are present.
Does a similar function exist in the Go standard library or the supplementary libraries? If not, is there an easy way to make something sufficiently similar?