From 4f0bbbad69b6df008e4ae0096669070ff8b82c0e Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 30 Mar 2020 08:38:17 +0800 Subject: [PATCH] String fixes --- nel/include/nel/misc/string_common.h | 8 ++++++++ nel/src/misc/i_xml.cpp | 5 +++-- .../world_editor/world_editor/world_editor.cpp | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/nel/include/nel/misc/string_common.h b/nel/include/nel/misc/string_common.h index 3fd46b835..9f6d59aae 100644 --- a/nel/include/nel/misc/string_common.h +++ b/nel/include/nel/misc/string_common.h @@ -290,6 +290,14 @@ inline bool endsWith(const char *str, const char *suffix) { return endsWith(str, inline bool endsWith(const std::string &str, const char *suffix) { return endsWith(str.c_str(), str.size(), suffix, strlen(suffix)); } inline bool endsWith(const std::string &str, const std::string &suffix) { return endsWith(str.c_str(), str.size(), suffix.c_str(), suffix.size()); } +// **************************************************************************** +// Conversion of strings between +// - UTF-8 +// - Local codepage (UTF-8 on Linux) +// - TString (Local codepage or wide on Windows) +// - Wide (wchar_t *, UTF-16 on Windows, UTF-32 on Linux) +// **************************************************************************** + // Convert local codepage to UTF-8 // On Windows, the local codepage is undetermined // On Linux, the local codepage is always UTF-8 (no-op) diff --git a/nel/src/misc/i_xml.cpp b/nel/src/misc/i_xml.cpp index 87f848ab9..24a2b7910 100644 --- a/nel/src/misc/i_xml.cpp +++ b/nel/src/misc/i_xml.cpp @@ -171,15 +171,16 @@ bool CIXml::init (IStream &stream) // Try binary mode if (_TryBinaryMode) { - char header[4]; + char header[5]; header[0] = buffer[0]; header[1] = buffer[1]; header[2] = buffer[2]; header[3] = buffer[3]; + header[4] = '\0'; toLower(header); // Does it a xml stream ? - if (!strcmp(header, "