From b37fda664c89a17fc739de2cb69b09e904100851 Mon Sep 17 00:00:00 2001 From: peter1138 Date: Fri, 22 May 2009 12:05:28 +0000 Subject: [PATCH] (svn r16374) -Fix (r11622): Valid UTF-8 sequences between 0x20 and 0xFF should be allowed as is instead of being treated as control codes. --- src/newgrf_text.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/newgrf_text.cpp b/src/newgrf_text.cpp index 9edd243da0..0e5e620f7a 100644 --- a/src/newgrf_text.cpp +++ b/src/newgrf_text.cpp @@ -120,7 +120,13 @@ char *TranslateTTDPatchCodes(uint32 grfid, const char *str) if (unicode && Utf8EncodedCharLen(*str) != 0) { c = Utf8Consume(&str); /* 'Magic' range of control codes. */ - if (GB(c, 8, 8) == 0xE0) c = GB(c, 0, 8); + if (GB(c, 8, 8) == 0xE0) { + c = GB(c, 0, 8); + } else if (c >= 0x20) { + if (!IsValidChar(c, CS_ALPHANUMERAL)) c = '?'; + d += Utf8Encode(d, c); + continue; + } } else { c = (byte)*str++; }