summaryrefslogtreecommitdiff
path: root/src/textfile_gui.cpp
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2020-12-14 20:25:01 +0100
committerGitHub <noreply@github.com>2020-12-14 20:25:01 +0100
commit68f9925cd4c8b29dbdac301e86bd9fc6f5a7fb27 (patch)
tree7089a650e6372e6ea37b3d6a60e9359e19120ae1 /src/textfile_gui.cpp
parentb14e3b9b9df2294e1f0b7fab8b2c23381e32ade7 (diff)
downloadopenttd-68f9925cd4c8b29dbdac301e86bd9fc6f5a7fb27.tar.xz
Codechange: use \u to indicate unicode chars in strings (#8379)
With \x, we sometimes had to do the "" trick, as the length is not predefined. With C++11 bringing \u to the specs, which has a preset length, we no longer need the "" trick. We set the strings to u8, to ensure all compilers use UTF-8 encoding for the \u characters. This was triggered by newer CLangs, which start to warn if you use "" in the middle of a string, wondering if that was your intention. It is a good question. And this is our answer :)
Diffstat (limited to 'src/textfile_gui.cpp')
-rw-r--r--src/textfile_gui.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/textfile_gui.cpp b/src/textfile_gui.cpp
index e44d9178d..3519c2750 100644
--- a/src/textfile_gui.cpp
+++ b/src/textfile_gui.cpp
@@ -359,7 +359,7 @@ static void Xunzip(byte **bufp, size_t *sizep)
}
/* Check for the byte-order-mark, and skip it if needed. */
- char *p = this->text + (strncmp("\xEF\xBB\xBF", this->text, 3) == 0 ? 3 : 0);
+ char *p = this->text + (strncmp(u8"\ufeff", this->text, 3) == 0 ? 3 : 0);
/* Make sure the string is a valid UTF-8 sequence. */
str_validate(p, this->text + filesize, SVS_REPLACE_WITH_QUESTION_MARK | SVS_ALLOW_NEWLINE);