about summary refs log tree commit diff
path: root/ui.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2018-08-07 15:43:49 -0400
committerJune McEnroe <june@causal.agency>2018-08-07 15:46:04 -0400
commitfe21b1410f3a2a0ee756a4b30dbd9ba91434cca3 (patch)
tree6d47583bd0234fb1107781a641ce666bb2fc9b61 /ui.c
parentPopulate tab-complete list (diff)
downloadcatgirl-fe21b1410f3a2a0ee756a4b30dbd9ba91434cca3.tar.gz
catgirl-fe21b1410f3a2a0ee756a4b30dbd9ba91434cca3.zip
Convert input to multibyte before handling
Diffstat (limited to 'ui.c')
-rw-r--r--ui.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/ui.c b/ui.c
index 5cf62a1..2e028ff 100644
--- a/ui.c
+++ b/ui.c
@@ -350,7 +350,16 @@ static void delete(void) {
 static void enter(void) {
 	if (line.end == line.buf) return;
 	*line.end = L'\0';
-	input(line.buf);
+
+	const wchar_t *src = line.buf;
+	size_t len = wcsrtombs(NULL, &src, 0, NULL);
+	if (len == (size_t)-1) err(EX_DATAERR, "wcsrtombs");
+
+	char buf[1 + len];
+	len = wcsrtombs(buf, &src, sizeof(buf), NULL);
+	if (len == (size_t)-1) err(EX_DATAERR, "wcsrtombs");
+
+	input(buf);
 	line.ptr = line.buf;
 	line.end = line.buf;
 }