qemu-char: add support for U-prefixed symbols

This patch adds support for Unicode symbols in keymap files. This
feature was already used in some keyboard layouts in QEMU generated
from XKB (e.g. Arabic) but it wasn't implemented in QEMU source code.

There is no need for check of validity of the hex string after U character
because strtol returns 0 in case the conversion was unsuccessful.

Signed-off-by: Jan Krupa <jkrupa@suse.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
This commit is contained in:
Jan Krupa 2013-10-16 14:40:05 +02:00 committed by Michael Tokarev
parent 3751e72246
commit 8280715924

View File

@ -33,6 +33,12 @@ static int get_keysym(const name2keysym_t *table,
if (!strcmp(p->name, name))
return p->keysym;
}
if (name[0] == 'U' && strlen(name) == 5) { /* try unicode Uxxxx */
char *end;
int ret = (int)strtoul(name + 1, &end, 16);
if (*end == '\0' && ret > 0)
return ret;
}
return 0;
}