tools: replace wcwidth() with g_unichar_* APIs

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@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Daniel P. Berrangé 2020-01-17 13:40:54 +00:00
parent 540cf03926
commit 6485c2c0ae
2 changed files with 2 additions and 1 deletions

View File

@ -19,6 +19,7 @@
#include <config.h>
#include <locale.h>
#include <wchar.h>
#include <wctype.h>
#include "internal.h"

View File

@ -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;
}