mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-10-31 15:20:10 +00:00
(svn r9083) -Codechange: Be more lenient when trimming UTF-8 strings and don't terminate the string when an invalid encoding is encountered, but only focus on maximum length.
This commit is contained in:
parent
6fe5620876
commit
a59eec1c36
@ -282,7 +282,8 @@ size_t Utf8TrimString(char *s, size_t maxlen)
|
||||
|
||||
for (const char *ptr = strchr(s, '\0'); *s != '\0';) {
|
||||
size_t len = Utf8EncodedCharLen(*s);
|
||||
if (len == 0) break; // invalid encoding
|
||||
/* Silently ignore invalid UTF8 sequences, our only concern trimming */
|
||||
if (len == 0) len = 1;
|
||||
|
||||
/* Take care when a hard cutoff was made for the string and
|
||||
* the last UTF8 sequence is invalid */
|
||||
|
Loading…
Reference in New Issue
Block a user