commit 4e3ab57537d4d6ec11af3787ff963b9d000b90a6
Author: Simon Howard <fraggle@soulsphere.org>
AuthorDate: Sun Dec 18 01:13:36 2016 -0500
Commit: Simon Howard <fraggle@soulsphere.org>
CommitDate: Sun Dec 18 01:13:36 2016 -0500
textscreen: Decode UTF8 of character from event.
It's not enough to simply return the first byte from the buffer, since
it may be a non-ASCII character. Decode the whole first character using
the UTF8 library.
---
textscreen/txt_sdl.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/textscreen/txt_sdl.c b/textscreen/txt_sdl.c
index 752e56ec..a398a8fc 100644
--- a/textscreen/txt_sdl.c
+++ b/textscreen/txt_sdl.c
@@ -26,6 +26,7 @@
#include "txt_main.h"
#include "txt_sdl.h"
+#include "txt_utf8.h"
#if defined(_MSC_VER) && !defined(__cplusplus)
#define inline __inline
@@ -668,8 +669,9 @@ signed int TXT_GetChar(void)
case SDL_TEXTINPUT:
if (input_mode == TXT_INPUT_TEXT)
{
- // TODO: Support input of more than just the first char.
- return ev.text.text[0];
+ // TODO: Support input of more than just the first char?
+ const char *p = ev.text.text;
+ return TXT_DecodeUTF8(&p);
}
break;