summary refs log tree commit diff
path: root/port/wcwidth/wcswidth.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--port/wcwidth/wcswidth.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/port/wcwidth/wcswidth.c b/port/wcwidth/wcswidth.c
new file mode 100644
index 00000000..5c8a5a4d
--- /dev/null
+++ b/port/wcwidth/wcswidth.c
@@ -0,0 +1,8 @@
+#include <wchar.h>
+
+int wcswidth(const wchar_t *wcs, size_t n)
+{
+	int l=0, k=0;
+	for (; n-- && *wcs && (k = wcwidth(*wcs)) >= 0; l+=k, wcs++);
+	return (k < 0) ? k : l;
+}