The combination of g_unichar_iszerowidth and g_unichar_iswide is sufficient to replicate the logic of wcwidth() for libvirt. Reviewed-by: Pavel Hrdina <phrdina@xxxxxxxxxx> Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx> --- tests/vshtabletest.c | 1 + tools/vsh-table.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/vshtabletest.c b/tests/vshtabletest.c index f2e0554f0a..0feda90b52 100644 --- a/tests/vshtabletest.c +++ b/tests/vshtabletest.c @@ -19,6 +19,7 @@ #include <config.h> #include <locale.h> +#include <wchar.h> #include <wctype.h> #include "internal.h" diff --git a/tools/vsh-table.c b/tools/vsh-table.c index a2365b2c32..e21514e86f 100644 --- a/tools/vsh-table.c +++ b/tools/vsh-table.c @@ -261,7 +261,7 @@ vshTableSafeEncode(const char *s, size_t *width) } else { memcpy(buf, p, len); buf += len; - *width += wcwidth(wc); + *width += g_unichar_iszerowidth(wc) ? 0 : (g_unichar_iswide(wc) ? 2 : 1); } p += len; } -- 2.24.1