From fe21b1410f3a2a0ee756a4b30dbd9ba91434cca3 Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Tue, 7 Aug 2018 15:43:49 -0400 Subject: Convert input to multibyte before handling --- ui.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'ui.c') 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; } -- cgit 1.4.1-2-gfad0