mirror of https://gitee.com/openkylin/libvirt.git
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:
parent
540cf03926
commit
6485c2c0ae
|
@ -19,6 +19,7 @@
|
|||
#include <config.h>
|
||||
|
||||
#include <locale.h>
|
||||
#include <wchar.h>
|
||||
#include <wctype.h>
|
||||
|
||||
#include "internal.h"
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue