diff --git a/src/game.c b/src/game.c index 649bd29e74..d58214672c 100644 --- a/src/game.c +++ b/src/game.c @@ -696,7 +696,7 @@ void game_convert_strings_to_utf8() if (!str_is_null_or_empty(userString)) { rct2_to_utf8_self(userString, 32); - utf8_remove_formatting(userString); + utf8_remove_formatting(userString, true); } } diff --git a/src/localisation/localisation.c b/src/localisation/localisation.c index fc632365fe..7d95ea4822 100644 --- a/src/localisation/localisation.c +++ b/src/localisation/localisation.c @@ -186,7 +186,7 @@ int utf8_get_format_code_arg_length(int codepoint) } } -void utf8_remove_formatting(utf8* string) { +void utf8_remove_formatting(utf8* string, bool allowColours) { utf8* readPtr = string; utf8* writePtr = string; @@ -196,8 +196,7 @@ void utf8_remove_formatting(utf8* string) { if (code == 0) { *writePtr = 0; break; - } - else if (!utf8_is_format_code(code)) { + } else if (!utf8_is_format_code(code) || (allowColours && utf8_is_colour_code(code))) { writePtr = utf8_write_codepoint(writePtr, code); } } diff --git a/src/localisation/localisation.h b/src/localisation/localisation.h index 29770ea46f..fbf1eaf53b 100644 --- a/src/localisation/localisation.h +++ b/src/localisation/localisation.h @@ -27,7 +27,7 @@ bool utf8_is_colour_code(int codepoint); bool utf8_should_use_sprite_for_codepoint(int codepoint); int font_sprite_get_codepoint_offset(int codepoint); int utf8_get_format_code_arg_length(int codepoint); -void utf8_remove_formatting(utf8* string); +void utf8_remove_formatting(utf8* string, bool allowColours); void format_string(char *dest, rct_string_id format, void *args); void format_string_raw(char *dest, char *src, void *args); diff --git a/src/network/network.cpp b/src/network/network.cpp index 4016479ff9..d237d9ac7a 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -920,7 +920,7 @@ void Network::AppendChatLog(const utf8 *text) strftime(buffer, sizeof(buffer), "[%Y/%m/%d %H:%M:%S] ", tmInfo); String::Append(buffer, sizeof(buffer), text); - utf8_remove_formatting(buffer); + utf8_remove_formatting(buffer, false); String::Append(buffer, sizeof(buffer), platform_get_new_line()); SDL_RWwrite(_chatLogStream, buffer, strlen(buffer), 1); diff --git a/src/platform/shared.c b/src/platform/shared.c index 0cb44eaba6..076f9d1aff 100644 --- a/src/platform/shared.c +++ b/src/platform/shared.c @@ -489,7 +489,7 @@ void platform_process_messages() if (SDL_HasClipboardText()) { utf8* text = SDL_GetClipboardText(); - utf8_remove_formatting(text); + utf8_remove_formatting(text, false); textinputbuffer_insert(&gTextInput, text); SDL_free(text); @@ -538,7 +538,7 @@ void platform_process_messages() utf8* newText = e.text.text; - utf8_remove_formatting(newText); + utf8_remove_formatting(newText, false); textinputbuffer_insert(&gTextInput, newText); console_refresh_caret();