summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2009-05-22 12:05:28 +0000
committerpeter1138 <peter1138@openttd.org>2009-05-22 12:05:28 +0000
commitb37fda664c89a17fc739de2cb69b09e904100851 (patch)
treebbe9262729ae8d4eed9e132e58e712938c8a94d5
parent6afce484bb9643510fbe51bd2127ed37961099a4 (diff)
downloadopenttd-b37fda664c89a17fc739de2cb69b09e904100851.tar.xz
(svn r16374) -Fix (r11622): Valid UTF-8 sequences between 0x20 and 0xFF should be allowed as is instead of being treated as control codes.
-rw-r--r--src/newgrf_text.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/newgrf_text.cpp b/src/newgrf_text.cpp
index 9edd243da..0e5e620f7 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++;
}