tled: read utf-8 characters in led_readchar() - neatvi - [fork] simple vi-type editor with UTF-8 support
(HTM) git clone git://src.adamsgaard.dk/neatvi
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
(DIR) commit 337895429257494f04d100a9d28c99ca013135d4
(DIR) parent 67179ba66d7f2fd7b943722af8ae12c8a6486297
(HTM) Author: Christian Neukirchen <chneukirchen@gmail.com>
Date: Wed, 17 Jun 2015 22:58:24 +0430
led: read utf-8 characters in led_readchar()
Diffstat:
M led.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
---
(DIR) diff --git a/led.c b/led.c
t@@ -183,7 +183,7 @@ static char *led_readchar(int c, char *kmap)
{
static char buf[8];
int c1, c2;
- int i;
+ int i, n;
if (c == TK_CTL('v')) { /* literal character */
buf[0] = term_read();
buf[1] = '\0';
t@@ -201,6 +201,14 @@ static char *led_readchar(int c, char *kmap)
return digraphs[i][1];
return NULL;
}
+ if ((c & 0xc0) == 0xc0) { /* utf-8 character */
+ buf[0] = c;
+ n = uc_len(buf);
+ for (i = 1; i < n; i++)
+ buf[i] = term_read();
+ buf[n] = '\0';
+ return buf;
+ }
return kmap_map(kmap, c);
}