From 5017bdd4700a83c1fea23baa72e607b191152617 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Fri, 28 Mar 2025 10:50:06 +0100 Subject: [PATCH] Fix parsing floating point values with `.` separator instead of `,` --- .../Engine/Platform/Base/StringUtilsBase.cpp | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/Source/Engine/Platform/Base/StringUtilsBase.cpp b/Source/Engine/Platform/Base/StringUtilsBase.cpp index 96d4fa338..90573530c 100644 --- a/Source/Engine/Platform/Base/StringUtilsBase.cpp +++ b/Source/Engine/Platform/Base/StringUtilsBase.cpp @@ -392,13 +392,20 @@ int32 StringUtils::HexDigit(Char c) bool StringUtils::Parse(const Char* str, float* result) { -#if PLATFORM_TEXT_IS_CHAR16 - std::u16string u16str = str; - std::wstring wstr(u16str.begin(), u16str.end()); - float v = wcstof(wstr.c_str(), nullptr); -#else - float v = wcstof(str, nullptr); -#endif + // Convert '.' into ',' + char buffer[64]; + char* ptr = buffer; + char* end = buffer + ARRAY_COUNT(buffer); + while (str && *str && ptr != end) + { + Char c = *str++; + if (c == '.') + c = ','; + *ptr++ = (char)c; + } + *ptr = 0; + + float v = (float)atof(buffer); *result = v; if (v == 0) {