(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)
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user