From 915ae8ffc28aee2e0bb9d9c623a711b4fc1f7faa Mon Sep 17 00:00:00 2001 From: Darkvater Date: Mon, 5 Mar 2007 00:45:56 +0000 Subject: (svn r9012) -Fix/Feature (UTF8): When cutting strings into multiple lines also take into consideration whitespace characters of more than 1 byte length (eg IDEOGRAPHIC SPACE, IsWhitespace() function). When trimming such strings, account for multiple-byte long sequences so use *Utf8PrevChar(v) = '\0'. -Codechange: Add a function Utf8TrimString() that properly trims a string to an UTF8 encoding seperation instead of somewhere in the wild (and use it in the chat area) --- src/texteff.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/texteff.cpp') diff --git a/src/texteff.cpp b/src/texteff.cpp index 54c456364..ff2cf1b49 100644 --- a/src/texteff.cpp +++ b/src/texteff.cpp @@ -17,7 +17,7 @@ #include "date.h" enum { - MAX_TEXTMESSAGE_LENGTH = 150, + MAX_TEXTMESSAGE_LENGTH = 200, MAX_TEXT_MESSAGES = 30, MAX_CHAT_MESSAGES = 10, MAX_ANIMATED_TILES = 256, @@ -82,6 +82,9 @@ void CDECL AddTextMessage(uint16 color, uint8 duration, const char *message, ... vsnprintf(buf, lengthof(buf), message, va); va_end(va); + + Utf8TrimString(buf, MAX_TEXTMESSAGE_LENGTH); + /* Force linebreaks for strings that are too long */ lines = GB(FormatStringLinebreaks(buf, _textmsg_box.width - 8), 0, 16) + 1; if (lines >= MAX_CHAT_MESSAGES) return; -- cgit v1.2.3-54-g00ecf