summaryrefslogtreecommitdiff
path: root/src/newgrf_text.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-12-11 21:25:48 +0000
committerrubidium <rubidium@openttd.org>2007-12-11 21:25:48 +0000
commitad022c535c438d8966db0c2f4949b5c5df9d7261 (patch)
tree5fc20d4a9bf4fa33d1b67ba1c06c10f70990d9bb /src/newgrf_text.cpp
parent745da6563f8b9ad21530110c91b6a8ee3d68aa5c (diff)
downloadopenttd-ad022c535c438d8966db0c2f4949b5c5df9d7261.tar.xz
(svn r11622) -Codechange: support the unicode version of the 'control' characters.
Diffstat (limited to 'src/newgrf_text.cpp')
-rw-r--r--src/newgrf_text.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/newgrf_text.cpp b/src/newgrf_text.cpp
index dac8300fd..1de167266 100644
--- a/src/newgrf_text.cpp
+++ b/src/newgrf_text.cpp
@@ -207,9 +207,13 @@ char *TranslateTTDPatchCodes(const char *str)
}
for (;;) {
- const char *tmp = str; // Used for UTF-8 decoding
-
- c = (byte)*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);
+ } else {
+ c = (byte)*str++;
+ }
if (c == 0) break;
switch (c) {
@@ -290,12 +294,6 @@ char *TranslateTTDPatchCodes(const char *str)
case 0xB7: d += Utf8Encode(d, SCC_PLANE); break;
case 0xB8: d += Utf8Encode(d, SCC_SHIP); break;
default:
- if (unicode) {
- d += Utf8Encode(d, Utf8Consume(&tmp));
- str = tmp;
- break;
- }
-
/* Validate any unhandled character */
if (!IsValidChar(c, CS_ALPHANUMERAL)) c = '?';
d += Utf8Encode(d, c);