diff --git a/osdep/getch2.c b/osdep/getch2.c index f421bdea7e..1eb78070c0 100644 --- a/osdep/getch2.c +++ b/osdep/getch2.c @@ -57,6 +57,7 @@ #include #include +#include "bstr.h" #include "mp_fifo.h" #include "input/keycodes.h" #include "getch2.h" @@ -202,6 +203,15 @@ void getch2(struct mp_fifo *fifo) } code = KEY_ENTER; } + int utf8len = bstr_parse_utf8_code_length(code); + if (utf8len > 0 && utf8len <= getch2_len) { + struct bstr s = { getch2_buf, utf8len }; + int unicode = bstr_decode_utf8(s, NULL); + if (unicode > 0) { + len = utf8len; + code = unicode; + } + } } else if (getch2_len > 1) { int c = getch2_buf[1];