diff --git a/input.c b/input.c index 1f0c64a..a1a1775 100644 --- a/input.c +++ b/input.c @@ -21,6 +21,7 @@ #include "exec.h" #include "names.h" #include "terminal.h" +#include "utf8.h" #include "wrapper.h" #if PKCODE @@ -454,6 +455,26 @@ handle_CSI: return CTLX | c; } + if( c <= 0xC1 || c > 0xF4) + return c ; + else { + char utf[ 4] ; + + utf[ 0] = c ; + if( (c & 0xE0) == 0xC0) + utf[ 1] = get1key() ; + else if( (c & 0xF0) == 0xE0) { + utf[ 1] = get1key() ; + utf[ 2] = get1key() ; + } else if( (c & 0xF8) == 0xF0) { + utf[ 1] = get1key() ; + utf[ 2] = get1key() ; + utf[ 3] = get1key() ; + } + + utf8_to_unicode( utf, 0, sizeof utf, (unicode_t *) &c) ; + } + /* otherwise, just return it */ return c; } diff --git a/utf8.c b/utf8.c index 686e988..1ebec89 100644 --- a/utf8.c +++ b/utf8.c @@ -29,7 +29,7 @@ unsigned utf8_to_unicode(char *line, unsigned index, unsigned len, unicode_t *re * 1100000x is start of overlong encoding sequence * Sequence longer than 4 bytes are invalid */ - if( c <= 0xc0 || c > 0xF4 || c == 0xC1) + if( c <= 0xC1 || c > 0xF4) return 1; /* Ok, it's 11xxxxxx, do a stupid decode */