summaryrefslogtreecommitdiff
path: root/news_gui.c
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-11-16 22:05:33 +0000
committerpeter1138 <peter1138@openttd.org>2006-11-16 22:05:33 +0000
commit1a4f1c8177f7ee351cb0096e3456d055b97dc60a (patch)
tree4fb6c0fac873efffc85cef437baa70d50d51fdfb /news_gui.c
parent40d647ddde652bb8f1c7b4215279cc82d01ca38f (diff)
downloadopenttd-1a4f1c8177f7ee351cb0096e3456d055b97dc60a.tar.xz
(svn r7182) -Feature: Merge utf8 branch. This brings us support for Unicode/UTF-8 and the option for fonts rendered by FreeType. Language changes to come.
Diffstat (limited to 'news_gui.c')
-rw-r--r--news_gui.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/news_gui.c b/news_gui.c
index 4651ca20a..00b603047 100644
--- a/news_gui.c
+++ b/news_gui.c
@@ -15,6 +15,7 @@
#include "sound.h"
#include "variables.h"
#include "date.h"
+#include "string.h"
/* News system
* News system is realized as a FIFO queue (in an array)
@@ -569,7 +570,8 @@ static byte getNews(byte i)
static void DrawNewsString(int x, int y, uint16 color, const NewsItem *ni, uint maxw)
{
char buffer[512], buffer2[512];
- char *ptr, *dest;
+ const char *ptr;
+ char *dest;
StringID str;
if (ni->display_mode == 3) {
@@ -582,12 +584,16 @@ static void DrawNewsString(int x, int y, uint16 color, const NewsItem *ni, uint
GetString(buffer, str, lastof(buffer));
/* Copy the just gotten string to another buffer to remove any formatting
* from it such as big fonts, etc. */
- for (ptr = buffer, dest = buffer2; *ptr != '\0'; ptr++) {
- if (*ptr == '\r') {
+ ptr = buffer;
+ dest = buffer2;
+ for (;;) {
+ WChar c = Utf8Consume(&ptr);
+ if (c == 0) break;
+ if (c == '\r') {
dest[0] = dest[1] = dest[2] = dest[3] = ' ';
dest += 4;
- } else if ((byte)*ptr >= ' ' && ((byte)*ptr < 0x88 || (byte)*ptr >= 0x99)) {
- *dest++ = *ptr;
+ } else if (IsPrintable(c)) {
+ dest += Utf8Encode(dest, c);
}
}