From 7603109dce8ee07bee5ef5f8b33a8120718b3961 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Thu, 31 Jul 2025 20:04:03 +0200 Subject: [PATCH] Add `StringUtils::Copy` for `char` to `Char` --- Source/Engine/Platform/Base/StringUtilsBase.cpp | 12 ++++++++++++ Source/Engine/Platform/StringUtils.h | 3 +++ 2 files changed, 15 insertions(+) diff --git a/Source/Engine/Platform/Base/StringUtilsBase.cpp b/Source/Engine/Platform/Base/StringUtilsBase.cpp index adda1b5a7..e86968edf 100644 --- a/Source/Engine/Platform/Base/StringUtilsBase.cpp +++ b/Source/Engine/Platform/Base/StringUtilsBase.cpp @@ -28,6 +28,18 @@ int32 StringUtils::Copy(char* dst, const Char* src, int32 count) return i; } +int32 StringUtils::Copy(Char* dst, const char* src, int32 count) +{ + int32 i = 0; + while (i < count && src[i]) + { + dst[i] = (Char)src[i]; + i++; + } + dst[i] = 0; + return i; +} + 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 3e1dc5660..faa8127f8 100644 --- a/Source/Engine/Platform/StringUtils.h +++ b/Source/Engine/Platform/StringUtils.h @@ -128,6 +128,9 @@ public: // Copies the string (count is maximum amount of characters to copy). Returns amount of copied elements (excluding null terminator character). static int32 Copy(char* dst, const Char* src, int32 count); + // Copies the string (count is maximum amount of characters to copy). Returns amount of copied elements (excluding null terminator character). + static int32 Copy(Char* dst, const char* src, int32 count); + // Finds specific sub-string in the input string. Returns the first found position in the input string or nulll if failed. static const Char* Find(const Char* str, const Char* toFind);