From 28bf60e62d2d6e10b9b17f99daf57f53bb20a0a0 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sun, 6 Oct 2024 23:54:20 +0200 Subject: [PATCH] Fix compilation --- Source/Engine/Platform/Base/StringUtilsBase.cpp | 15 +++++++++++++++ Source/Engine/Platform/StringUtils.h | 7 +++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Source/Engine/Platform/Base/StringUtilsBase.cpp b/Source/Engine/Platform/Base/StringUtilsBase.cpp index 96d4fa338..5ee094a54 100644 --- a/Source/Engine/Platform/Base/StringUtilsBase.cpp +++ b/Source/Engine/Platform/Base/StringUtilsBase.cpp @@ -15,6 +15,21 @@ constexpr char DirectorySeparatorChar = '\\'; constexpr char AltDirectorySeparatorChar = '/'; constexpr char VolumeSeparatorChar = ':'; +#if PLATFORM_TEXT_IS_CHAR16 + +int32 StringUtils::Length(const wchar_t* str) +{ + int32 result = 0; + if (str) + { + while (*str) + str++; + } + return result; +} + +#endif + const Char* StringUtils::FindIgnoreCase(const Char* str, const Char* toFind) { if (toFind == nullptr || str == nullptr) diff --git a/Source/Engine/Platform/StringUtils.h b/Source/Engine/Platform/StringUtils.h index af9267e16..1bff2c2ae 100644 --- a/Source/Engine/Platform/StringUtils.h +++ b/Source/Engine/Platform/StringUtils.h @@ -115,6 +115,9 @@ public: public: // Gets the string length. Returns 0 if str is null. static int32 Length(const Char* str); +#if PLATFORM_TEXT_IS_CHAR16 + static int32 Length(const wchar_t* str); +#endif // Gets the string length. Returns 0 if str is null. static int32 Length(const char* str); @@ -224,7 +227,7 @@ public: template static bool ParseHex(const T* str, uint32* result) { - return StringUtils::ParseHex(str, StringUtils::Length((const T*)str), result); + return StringUtils::ParseHex(str, StringUtils::Length(str), result); } // Parses text to the unsigned integer value. Returns true if failed to convert the value. @@ -321,7 +324,7 @@ public: template static bool Parse(const T* str, U* result) { - return StringUtils::Parse((const T*)str, StringUtils::Length((const T*)str), (U*)result); + return StringUtils::Parse(str, StringUtils::Length(str), result); } // Parses text to the scalar value. Returns true if failed to convert the value.