From 91206f12be85cd6a1690c9fb5d1fafbcaea650cb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 19 Feb 2019 00:27:47 +0100 Subject: [PATCH] - changed zstrformat to allow %c to emit non-ASCII characters as UTF-8. --- src/utility/zstrformat.cpp | 8 ++++++-- wadsrc/static/zscript/menu/textentermenu.txt | 4 +--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/utility/zstrformat.cpp b/src/utility/zstrformat.cpp index 2bec17803..bf61ce282 100644 --- a/src/utility/zstrformat.cpp +++ b/src/utility/zstrformat.cpp @@ -89,6 +89,7 @@ #include "zstring.h" #include "gdtoa.h" +#include "utf8.h" /* @@ -557,8 +558,11 @@ namespace StringFormat else if (type == 'c') { intarg = va_arg (arglist, int); - buffer[0] = char(intarg); - bufflen = 1; + if (utf8_encode(intarg, (uint8_t*)buffer, &bufflen) != 0) + { + buffer[0] = '?'; + bufflen = 1; + } obuff = buffer; } else if (type == 's') diff --git a/wadsrc/static/zscript/menu/textentermenu.txt b/wadsrc/static/zscript/menu/textentermenu.txt index a7cbdb517..328c7aa94 100644 --- a/wadsrc/static/zscript/menu/textentermenu.txt +++ b/wadsrc/static/zscript/menu/textentermenu.txt @@ -209,9 +209,7 @@ class TextEnterMenu : Menu private void AppendChar(int ch) { - String newstring = mEnterString; - newstring.AppendCharacter(ch); - newstring = newstring .. displayFont.GetCursor(); + String newstring = String.Format("%s%c%s", mEnterString, ch, displayFont.GetCursor()); if (mEnterSize < 0 || displayFont.StringWidth(newstring) < mEnterSize) { mEnterString.AppendCharacter(ch);